mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
Started to integrate vcards with gtk ui
This commit is contained in:
parent
528fc0a026
commit
6703bd2079
5 changed files with 130 additions and 16 deletions
|
|
@ -207,12 +207,23 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
|
|||
}
|
||||
|
||||
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){
|
||||
LinphoneAddress *fr=lf->uri;
|
||||
if (fr==NULL){
|
||||
LinphoneAddress *fr = lf->uri;
|
||||
LinphoneVCard *vcard = NULL;
|
||||
|
||||
if (fr == NULL){
|
||||
ms_error("linphone_friend_set_sip_addr() must be called before linphone_friend_set_name().");
|
||||
return -1;
|
||||
}
|
||||
linphone_address_set_display_name(fr,name);
|
||||
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
linphone_friend_create_vcard(lf, name);
|
||||
} else {
|
||||
linphone_vcard_set_full_name(vcard, name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -739,6 +750,44 @@ void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVCard *vcard) {
|
|||
fr->vcard = vcard;
|
||||
}
|
||||
|
||||
bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
|
||||
LinphoneVCard *vcard = NULL;
|
||||
const char *fullName = NULL;
|
||||
LinphoneAddress *addr = NULL;
|
||||
|
||||
if (!fr || fr->vcard) {
|
||||
ms_error("Friend is either null or already has a vcard");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addr = fr->uri;
|
||||
if (!addr && !name) {
|
||||
ms_error("friend doesn't have an URI and name parameter is null");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
fullName = name;
|
||||
} else {
|
||||
const char *displayName = linphone_address_get_display_name(addr);
|
||||
if (!displayName) {
|
||||
ms_error("Friend's URI doesn't have a display name");
|
||||
return FALSE;
|
||||
}
|
||||
fullName = displayName;
|
||||
}
|
||||
|
||||
if (!fullName) {
|
||||
ms_error("Couldn't determine the name to use for the vCard");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
vcard = linphone_vcard_new();
|
||||
linphone_vcard_set_full_name(vcard, fullName);
|
||||
fr->vcard = vcard;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriend);
|
||||
|
||||
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriend, belle_sip_object_t,
|
||||
|
|
|
|||
|
|
@ -404,24 +404,36 @@ LINPHONE_PUBLIC LinphoneFriend * linphone_friend_ref(LinphoneFriend *lf);
|
|||
|
||||
/**
|
||||
* Release a reference to the linphone friend.
|
||||
* @param[in] lf LinohoneFriend object
|
||||
* @param[in] lf LinphoneFriend object
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_friend_unref(LinphoneFriend *lf);
|
||||
|
||||
/**
|
||||
* Returns the LinphoneCore object managing this friend, if any.
|
||||
* @param[in] fr LinphoneFriend object
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr);
|
||||
|
||||
/**
|
||||
* Returns the VCard object associated to this friend, if any
|
||||
* @param[in] fr LinphoneFriend object
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneVCard* linphone_friend_get_vcard(LinphoneFriend *fr);
|
||||
|
||||
/**
|
||||
* Returns the VCard object associated to this friend, if any
|
||||
* Binds a VCard object to a friend
|
||||
* @param[in] fr LinphoneFriend object
|
||||
* @param[in] vcard The VCard object to bind
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVCard *vcard);
|
||||
|
||||
/**
|
||||
* Creates a VCard object associated to this friend if there isn't one yet and if the full name is available, either by the parameter or the one in the friend's SIP URI
|
||||
* @param[in] fr LinphoneFriend object
|
||||
* @param[in] name The full name of the friend or NULL to use the one from the friend's SIP URI
|
||||
* @return true if the vCard has been created, false if it wasn't possible (for exemple if name and the friend's SIP URI are null or if the friend's SIP URI doesn't have a display name), or if there is already one vcard
|
||||
*/
|
||||
LINPHONE_PUBLIC bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
vcard.cc
|
||||
Copyright (C) 2015 Belledonne Communications SARL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "vcard.h"
|
||||
#include "belcard/belcard.hpp"
|
||||
|
||||
|
|
@ -6,14 +25,14 @@ struct _LinphoneVCard {
|
|||
};
|
||||
|
||||
extern "C" LinphoneVCard* linphone_vcard_new(void) {
|
||||
LinphoneVCard* vcard = (LinphoneVCard*) malloc(sizeof(LinphoneVCard));
|
||||
LinphoneVCard* vcard = (LinphoneVCard*) ms_new0(LinphoneVCard, 1);
|
||||
vcard->belcard = belcard::BelCardGeneric::create<belcard::BelCard>();
|
||||
return vcard;
|
||||
}
|
||||
|
||||
extern "C" void linphone_vcard_free(LinphoneVCard *vcard) {
|
||||
vcard->belcard.reset();
|
||||
free(vcard);
|
||||
ms_free(vcard);
|
||||
}
|
||||
|
||||
extern "C" void linphone_vcard_set_full_name(LinphoneVCard *vcard, const char *name) {
|
||||
|
|
@ -23,5 +42,6 @@ extern "C" void linphone_vcard_set_full_name(LinphoneVCard *vcard, const char *n
|
|||
}
|
||||
|
||||
extern "C" const char* linphone_vcard_get_full_name(LinphoneVCard *vcard) {
|
||||
return vcard->belcard->getFullName() ? vcard->belcard->getFullName()->getValue().c_str() : NULL;
|
||||
const char *result = vcard->belcard->getFullName() ? vcard->belcard->getFullName()->getValue().c_str() : NULL;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,6 +1,31 @@
|
|||
/*
|
||||
vcard.h
|
||||
Copyright (C) 2015 Belledonne Communications SARL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef LINPHONE_VCARD_H
|
||||
#define LINPHONE_VCARD_H
|
||||
|
||||
#include <mediastreamer2/mscommon.h>
|
||||
|
||||
#ifndef LINPHONE_PUBLIC
|
||||
#define LINPHONE_PUBLIC MS2_PUBLIC
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
@ -8,11 +33,11 @@ extern "C"
|
|||
|
||||
typedef struct _LinphoneVCard LinphoneVCard;
|
||||
|
||||
LinphoneVCard* linphone_vcard_new(void);
|
||||
void linphone_vcard_free(LinphoneVCard *vcard);
|
||||
LINPHONE_PUBLIC LinphoneVCard* linphone_vcard_new(void);
|
||||
LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVCard *vcard);
|
||||
|
||||
void linphone_vcard_set_full_name(LinphoneVCard *vcard, const char *name);
|
||||
const char* linphone_vcard_get_full_name(LinphoneVCard *vcard);
|
||||
LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVCard *vcard, const char *name);
|
||||
LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(LinphoneVCard *vcard);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -716,19 +716,28 @@ void linphone_gtk_show_friends(void){
|
|||
}
|
||||
|
||||
void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){
|
||||
GtkWidget *w=linphone_gtk_create_window("contact", parent);
|
||||
GtkWidget *w = linphone_gtk_create_window("contact", parent);
|
||||
char *uri;
|
||||
const char *name;
|
||||
const LinphoneAddress *f_uri=linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *f_uri = linphone_friend_get_address(lf);
|
||||
LinphoneVCard *vcard = linphone_friend_get_vcard(lf);
|
||||
|
||||
if (vcard) {
|
||||
name = linphone_vcard_get_full_name(vcard);
|
||||
} else {
|
||||
name = linphone_address_get_display_name(f_uri);
|
||||
}
|
||||
|
||||
uri=linphone_address_as_string_uri_only(f_uri);
|
||||
name=linphone_address_get_display_name(f_uri);
|
||||
if (uri) {
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address")),uri);
|
||||
ms_free(uri);
|
||||
}
|
||||
|
||||
if (name){
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"name")),name);
|
||||
}
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"show_presence")),
|
||||
linphone_friend_get_send_subscribe(lf));
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"allow_presence")),
|
||||
|
|
@ -772,9 +781,8 @@ void linphone_gtk_contact_ok(GtkWidget *button){
|
|||
return ;
|
||||
}
|
||||
|
||||
linphone_address_set_display_name(friend_address,name);
|
||||
linphone_friend_set_name(lf,name);
|
||||
linphone_friend_set_address(lf,friend_address);
|
||||
linphone_friend_set_name(lf,name);
|
||||
linphone_friend_send_subscribe(lf,show_presence);
|
||||
linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny);
|
||||
if (linphone_friend_in_list(lf)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue