Changeset 739:55ae5c895436 in mediastreamer2
- Timestamp:
- Oct 21, 2009 9:21:07 PM (4 years ago)
- Branch:
- default
- Location:
- linphone
- Files:
-
- 8 edited
-
coreapi/friend.c (modified) (5 diffs)
-
coreapi/linphonecore.c (modified) (3 diffs)
-
coreapi/linphonecore.h (modified) (5 diffs)
-
coreapi/plugins/buddylookup/src/lookup.c (modified) (14 diffs)
-
coreapi/sipsetup.c (modified) (3 diffs)
-
coreapi/sipsetup.h (modified) (4 diffs)
-
gtk-glade/buddylookup.c (modified) (4 diffs)
-
gtk-glade/friendlist.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/coreapi/friend.c
r297 r739 3 3 * 4 4 * Sat May 15 15:25:16 2004 5 * Copyright 2004 Simon Morlat5 * Copyright 2004-2009 Simon Morlat 6 6 * Email 7 7 ****************************************************************************/ … … 562 562 linphone_friend_unsubscribe(lf); 563 563 if (lf->url!=NULL) osip_from_free(lf->url); 564 if (lf->info!=NULL) buddy_info_free(lf->info); 564 565 ms_free(lf); 565 566 } … … 607 608 } 608 609 610 BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf){ 611 return lf->info; 612 } 609 613 610 614 void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc){ … … 639 643 } 640 644 ms_message("linphone_friend_apply() done."); 645 lc->bl_refresh=TRUE; 641 646 } 642 647 … … 666 671 linphone_core_write_friends_config(lc); 667 672 } 673 } 674 675 static bool_t username_match(const char *u1, const char *u2){ 676 if (u1==NULL && u2==NULL) return TRUE; 677 if (u1 && u2 && strcasecmp(u1,u2)==0) return TRUE; 678 return FALSE; 679 } 680 681 LinphoneFriend *linphone_core_get_friend_by_uri(const LinphoneCore *lc, const char *uri){ 682 osip_from_t *from; 683 osip_from_init(&from); 684 const MSList *elem; 685 if (osip_from_parse(from,uri)!=0){ 686 osip_from_free(from); 687 return NULL; 688 } 689 for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){ 690 LinphoneFriend *lf=(LinphoneFriend*)elem->data; 691 const char *it_username=lf->url->url->username; 692 const char *it_host=lf->url->url->host; 693 if (strcasecmp(from->url->host,it_host)==0 && username_match(from->url->username,it_username)){ 694 return lf; 695 } 696 } 697 return NULL; 668 698 } 669 699 -
linphone/coreapi/linphonecore.c
r728 r739 1037 1037 } 1038 1038 1039 static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){ 1040 LinphoneFriend *lf=linphone_core_get_friend_by_uri(lc,info->sip_uri); 1041 if (lf!=NULL){ 1042 lf->info=info; 1043 ms_message("%s has a BuddyInfo assigned.",info->sip_uri); 1044 }else{ 1045 ms_warning("Could not any friend with uri %s",info->sip_uri); 1046 } 1047 } 1048 1049 static void analyze_buddy_lookup_results(LinphoneCore *lc, LinphoneProxyConfig *cfg){ 1050 MSList *elem; 1051 SipSetupContext *ctx=linphone_proxy_config_get_sip_setup_context(cfg); 1052 for (elem=lc->bl_reqs;elem!=NULL;elem=ms_list_next(elem)){ 1053 BuddyLookupRequest *req=(BuddyLookupRequest *)elem->data; 1054 if (req->status==BuddyLookupDone || req->status==BuddyLookupFailure){ 1055 if (req->results!=NULL){ 1056 BuddyInfo *i=(BuddyInfo*)req->results->data; 1057 ms_list_free(req->results); 1058 req->results=NULL; 1059 assign_buddy_info(lc,i); 1060 } 1061 sip_setup_context_buddy_lookup_free(ctx,req); 1062 elem->data=NULL; 1063 } 1064 } 1065 /*purge completed requests */ 1066 while((elem=ms_list_find(lc->bl_reqs,NULL))!=NULL){ 1067 lc->bl_reqs=ms_list_remove_link(lc->bl_reqs,elem); 1068 } 1069 } 1070 1071 static void linphone_core_grab_buddy_infos(LinphoneCore *lc, LinphoneProxyConfig *cfg){ 1072 const MSList *elem; 1073 SipSetupContext *ctx=linphone_proxy_config_get_sip_setup_context(cfg); 1074 for(elem=linphone_core_get_friend_list(lc);elem!=NULL;elem=elem->next){ 1075 LinphoneFriend *lf=(LinphoneFriend*)elem->data; 1076 if (lf->info==NULL){ 1077 char *url=linphone_friend_get_url(lf); 1078 if (linphone_core_lookup_known_proxy(lc,url)==cfg){ 1079 char *name=linphone_friend_get_name(lf); 1080 if (name!=NULL && strlen(name)>0){ 1081 BuddyLookupRequest *req; 1082 req=sip_setup_context_create_buddy_lookup_request(ctx); 1083 buddy_lookup_request_set_key(req,name); 1084 buddy_lookup_request_set_max_results(req,1); 1085 sip_setup_context_buddy_lookup_submit(ctx,req); 1086 lc->bl_reqs=ms_list_append(lc->bl_reqs,req); 1087 } 1088 ms_free(name); 1089 } 1090 ms_free(url); 1091 } 1092 } 1093 } 1094 1095 static void linphone_core_do_plugin_tasks(LinphoneCore *lc){ 1096 LinphoneProxyConfig *cfg=NULL; 1097 linphone_core_get_default_proxy(lc,&cfg); 1098 if (cfg){ 1099 if (lc->bl_refresh){ 1100 SipSetupContext *ctx=linphone_proxy_config_get_sip_setup_context(cfg); 1101 if (ctx && (sip_setup_context_get_capabilities(ctx) & SIP_SETUP_CAP_BUDDY_LOOKUP)){ 1102 linphone_core_grab_buddy_infos(lc,cfg); 1103 lc->bl_refresh=FALSE; 1104 } 1105 } 1106 if (lc->bl_reqs) analyze_buddy_lookup_results(lc,cfg); 1107 } 1108 } 1109 1039 1110 void linphone_core_iterate(LinphoneCore *lc) 1040 1111 { … … 1110 1181 if (disconnected) 1111 1182 linphone_core_disconnected(lc); 1183 1184 linphone_core_do_plugin_tasks(lc); 1185 1112 1186 if (one_second_elapsed && lp_config_needs_commit(lc->config)){ 1113 1187 lp_config_sync(lc->config); … … 1198 1272 return FALSE; 1199 1273 } 1200 sipaddr=ortp_strdup_printf("sip:%s@%s",url,uri->url->host); 1274 if (uri->url->port!=NULL && uri->url->port[0]!='\0') 1275 sipaddr=ortp_strdup_printf("sip:%s@%s:%s",url,uri->url->host,uri->url->port); 1276 else 1277 sipaddr=ortp_strdup_printf("sip:%s@%s",url,uri->url->host); 1201 1278 if (real_parsed_url!=NULL) *real_parsed_url=osip_to_create(sipaddr); 1202 1279 if (real_url!=NULL) *real_url=sipaddr; -
linphone/coreapi/linphonecore.h
r685 r739 213 213 struct _LinphoneProxyConfig *proxy; 214 214 struct _LinphoneCore *lc; 215 BuddyInfo *info; 215 216 bool_t subscribe; 216 217 bool_t inc_subscribe_pending; … … 234 235 LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf); 235 236 LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); 237 BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf); 236 238 #define linphone_friend_in_list(lf) ((lf)->lc!=NULL) 237 239 … … 478 480 struct _VideoStream *previewstream; 479 481 struct _RtpProfile *local_profile; 482 MSList *bl_reqs; 480 483 MSList *subscribers; /* unknown subscribers */ 481 484 int minutes_away; … … 502 505 bool_t apply_nat_settings; 503 506 bool_t ready; 507 bool_t bl_refresh; 504 508 #ifdef VINCENT_MAURY_RSVP 505 509 /* QoS parameters*/ … … 696 700 /* notify all friends that have subscribed */ 697 701 void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os); 702 LinphoneFriend *linphone_core_get_friend_by_uri(const LinphoneCore *lc, const char *uri); 698 703 699 704 /* returns a list of LinphoneCallLog */ -
linphone/coreapi/plugins/buddylookup/src/lookup.c
r738 r739 10 10 static bool_t buddy_lookup_init(void){ 11 11 return TRUE; 12 } 13 14 typedef struct _BuddyLookupState{ 12 }; 13 14 typedef struct _BLReq{ 15 BuddyLookupRequest base; 16 SoupMessage *msg; 15 17 SoupSession *session; 16 BuddyLookupStatus status;17 SoupMessage *msg;18 18 ortp_thread_t th; 19 MSList *results; 20 bool_t processing; 21 }BuddyLookupState; 22 23 #define get_buddy_lookup_state(ctx) ((BuddyLookupState*)((ctx)->data)) 19 }BLReq; 20 24 21 25 22 void set_proxy(SoupSession *session, const char *proxy){ … … 30 27 31 28 static void buddy_lookup_instance_init(SipSetupContext *ctx){ 32 BuddyLookupState *s=ms_new0(BuddyLookupState,1);33 const char *proxy=NULL;34 s->session=soup_session_sync_new();35 proxy=getenv("http_proxy");36 if (proxy && strlen(proxy)>0) set_proxy(s->session,proxy);37 ctx->data=s;38 29 } 39 30 40 31 static void buddy_lookup_instance_uninit(SipSetupContext *ctx){ 41 BuddyLookupState *s=get_buddy_lookup_state(ctx); 42 g_object_unref(G_OBJECT(s->session)); 43 ms_free(s); 44 } 45 46 static SoupMessage * build_xmlrpc_request(const char *identity, const char *password, const char *key, const char *domain, const char *url){ 32 } 33 34 static SoupMessage * build_xmlrpc_request(const char *identity, const char *password, const char *key, const char *domain, const char *url, int max_results){ 47 35 SoupMessage * msg; 48 36 … … 52 40 G_TYPE_STRING, password ? password : "", 53 41 G_TYPE_STRING, key, 54 G_TYPE_INT , 100,42 G_TYPE_INT , max_results, 55 43 G_TYPE_INT , 0, 56 44 G_TYPE_STRING, domain, … … 66 54 } 67 55 68 static void got_headers(SipSetupContext *ctx, SoupMessage*msg){ 69 BuddyLookupState *s=get_buddy_lookup_state(ctx); 56 static void got_headers(BLReq *blreq, SoupMessage*msg){ 70 57 ms_message("Got headers !"); 71 s->status=BuddyLookupConnected;58 blreq->base.status=BuddyLookupConnected; 72 59 } 73 60 … … 82 69 } 83 70 84 static void fill_buddy_info(B uddyLookupState *s, BuddyInfo *bi, GHashTable *ht){71 static void fill_buddy_info(BLReq *blreq, BuddyInfo *bi, GHashTable *ht){ 85 72 char tmp[256]; 86 73 fill_item(ht,"first_name",bi->firstname,sizeof(bi->firstname)); … … 106 93 ms_message("This buddy has an image, let's download it: %s",tmp); 107 94 msg=soup_message_new("GET",tmp); 108 if ((status=soup_session_send_message( s->session,msg))==200){95 if ((status=soup_session_send_message(blreq->session,msg))==200){ 109 96 SoupMessageBody *body=msg->response_body; 110 97 ms_message("Received %i bytes",body->length); … … 120 107 } 121 108 122 static MSList * make_buddy_list(B uddyLookupState *s, GValue *retval){109 static MSList * make_buddy_list(BLReq *blreq, GValue *retval){ 123 110 MSList *ret=NULL; 124 111 if (G_VALUE_TYPE(retval)==G_TYPE_VALUE_ARRAY){ … … 131 118 GHashTable *ht=(GHashTable*)g_value_get_boxed(gelem); 132 119 BuddyInfo *bi=buddy_info_new(); 133 fill_buddy_info( s,bi,ht);120 fill_buddy_info(blreq,bi,ht); 134 121 ret=ms_list_append(ret,bi); 135 122 }else{ … … 142 129 143 130 144 static int xml_rpc_parse_response(SipSetupContext *ctx, SoupMessage *sm){ 145 BuddyLookupState *s=get_buddy_lookup_state(ctx); 131 static int xml_rpc_parse_response(BLReq *blreq, SoupMessage *sm){ 146 132 SoupBuffer *sb; 147 133 GValue retval; … … 156 142 ms_error("Could not parse xml-rpc response !"); 157 143 } 158 s->status=BuddyLookupFailure;144 blreq->base.status=BuddyLookupFailure; 159 145 }else{ 160 146 ms_message("Extracting values from return type..."); 161 s->results=make_buddy_list(s,&retval);147 blreq->base.results=make_buddy_list(blreq,&retval); 162 148 g_value_unset(&retval); 163 s->status=BuddyLookupDone;149 blreq->base.status=BuddyLookupDone; 164 150 } 165 151 soup_buffer_free(sb); 166 return s->status==BuddyLookupDone ? 0 : -1;152 return blreq->base.status==BuddyLookupDone ? 0 : -1; 167 153 } 168 154 169 155 static void * process_xml_rpc_request(void *up){ 170 SipSetupContext *ctx=(SipSetupContext*)up; 171 BuddyLookupState *s=get_buddy_lookup_state(ctx); 172 SoupMessage *sm=s->msg; 156 BLReq *blreq=(BLReq*)up; 157 SoupMessage *sm=blreq->msg; 173 158 int code; 174 g_signal_connect_swapped(G_OBJECT(sm),"got-headers",(GCallback)got_headers, ctx);175 s->status=BuddyLookupConnecting;176 code=soup_session_send_message( s->session,sm);159 g_signal_connect_swapped(G_OBJECT(sm),"got-headers",(GCallback)got_headers,blreq); 160 blreq->base.status=BuddyLookupConnecting; 161 code=soup_session_send_message(blreq->session,sm); 177 162 if (code==200){ 178 163 ms_message("Got a response from server, yeah !"); 179 xml_rpc_parse_response( ctx,sm);164 xml_rpc_parse_response(blreq,sm); 180 165 }else{ 181 166 ms_error("request failed, error-code=%i (%s)",code,soup_status_get_phrase(code)); 182 s->status=BuddyLookupFailure; 183 } 184 s->processing=FALSE; 167 blreq->base.status=BuddyLookupFailure; 168 } 185 169 return NULL; 186 170 } 187 171 188 static int lookup_buddy(SipSetupContext *ctx, const char *key){ 189 BuddyLookupState *s=get_buddy_lookup_state(ctx); 172 static int lookup_buddy(SipSetupContext *ctx, BLReq *req){ 190 173 LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx); 191 174 LinphoneCore *lc=linphone_proxy_config_get_core(cfg); … … 200 183 return -1; 201 184 } 202 if (s->th!=0){203 if (s->processing){204 ms_message("Canceling previous request...");205 soup_session_cancel_message(s->session,s->msg, SOUP_STATUS_CANCELLED);206 }207 ortp_thread_join(s->th,NULL);208 s->th=0;209 g_object_unref(G_OBJECT(s->msg));210 }211 185 212 186 osip_from_t *from; … … 220 194 if (aa) ms_message("There is a password: %s",aa->passwd); 221 195 else ms_message("No password for %s on %s",from->url->username,from->url->host); 222 sm=build_xmlrpc_request(identity, aa ? aa->passwd : NULL, key, from->url->host, url);196 sm=build_xmlrpc_request(identity, aa ? aa->passwd : NULL, req->base.key, from->url->host, url, req->base.max_results); 223 197 osip_from_free(from); 224 s->msg=sm; 225 s->processing=TRUE; 226 ortp_thread_create(&s->th,NULL,process_xml_rpc_request,ctx); 198 req->msg=sm; 199 ortp_thread_create(&req->th,NULL,process_xml_rpc_request,req); 227 200 if (!sm) return -1; 228 201 return 0; 229 202 } 230 203 231 static BuddyLookupStatus get_buddy_lookup_status(SipSetupContext *ctx){ 232 BuddyLookupState *s=get_buddy_lookup_state(ctx); 233 return s->status; 234 } 235 236 static int get_buddy_lookup_results(SipSetupContext *ctx, MSList **results){ 237 BuddyLookupState *s=get_buddy_lookup_state(ctx); 238 if (s->results){ 239 *results=s->results; 240 s->results=NULL; 241 } 204 static BuddyLookupRequest * create_request(SipSetupContext *ctx){ 205 BLReq *req=ms_new0(BLReq,1); 206 const char *proxy=NULL; 207 req->session=soup_session_sync_new(); 208 proxy=getenv("http_proxy"); 209 if (proxy && strlen(proxy)>0) set_proxy(req->session,proxy); 210 return (BuddyLookupRequest*)req; 211 } 212 213 static int submit_request(SipSetupContext *ctx, BuddyLookupRequest *req){ 214 BLReq *blreq=(BLReq*)req; 215 return lookup_buddy(ctx,blreq); 216 } 217 218 static int free_request(SipSetupContext *ctx, BuddyLookupRequest *req){ 219 BLReq *blreq=(BLReq*)req; 220 if (blreq->th!=0){ 221 soup_session_cancel_message(blreq->session,blreq->msg, SOUP_STATUS_CANCELLED); 222 ortp_thread_join(blreq->th,NULL); 223 blreq->th=0; 224 g_object_unref(G_OBJECT(blreq->msg)); 225 } 226 if (blreq->session) 227 g_object_unref(G_OBJECT(blreq->session)); 228 buddy_lookup_request_free(req); 242 229 return 0; 243 230 } … … 245 232 static void buddy_lookup_exit(void){ 246 233 } 234 235 static BuddyLookupFuncs bl_funcs={ 236 .request_create=create_request, 237 .request_submit=submit_request, 238 .request_free=free_request 239 }; 240 241 247 242 248 243 static SipSetup buddy_lookup_funcs={ … … 251 246 .init=buddy_lookup_init, 252 247 .init_instance=buddy_lookup_instance_init, 253 .lookup_buddy=lookup_buddy,254 .get_buddy_lookup_status=get_buddy_lookup_status,255 .get_buddy_lookup_results=get_buddy_lookup_results,256 248 .uninit_instance=buddy_lookup_instance_uninit, 257 .exit=buddy_lookup_exit 249 .exit=buddy_lookup_exit, 250 .buddy_lookup_funcs=&bl_funcs, 258 251 }; 259 252 -
linphone/coreapi/sipsetup.c
r738 r739 80 80 } 81 81 82 void buddy_lookup_request_set_key(BuddyLookupRequest *req, const char *key){ 83 if (req->key!=NULL) { 84 ms_free(req->key); 85 req->key=NULL; 86 } 87 if (key) req->key=ms_strdup(key); 88 } 89 90 void buddy_lookup_request_set_max_results(BuddyLookupRequest *req, int ncount){ 91 req->max_results=ncount; 92 } 93 94 void buddy_lookup_request_free(BuddyLookupRequest *req){ 95 if (req->key) ms_free(req->key); 96 if (req->results){ 97 ms_list_for_each(req->results,(void (*)(void*))buddy_info_free); 98 ms_list_free(req->results); 99 } 100 ms_free(req); 101 } 102 82 103 LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx){ 83 104 return ctx->cfg; … … 145 166 } 146 167 147 int sip_setup_context_lookup_buddy(SipSetupContext *ctx, const char *key){148 if (ctx->funcs-> lookup_buddy)149 return ctx->funcs-> lookup_buddy(ctx,key);150 return -1;151 } 152 153 BuddyLookupStatus sip_setup_context_get_buddy_lookup_status(SipSetupContext *ctx){154 if (ctx->funcs-> get_buddy_lookup_status)155 return ctx->funcs-> get_buddy_lookup_status(ctx);156 return BuddyLookupFailure;157 } 158 159 int sip_setup_context_ get_buddy_lookup_results(SipSetupContext *ctx, MSList **results /*of BuddyInfo */){160 if (ctx->funcs-> get_buddy_lookup_results)161 return ctx->funcs-> get_buddy_lookup_results(ctx,results);168 BuddyLookupRequest *sip_setup_context_create_buddy_lookup_request(SipSetupContext *ctx){ 169 if (ctx->funcs->buddy_lookup_funcs) 170 return ctx->funcs->buddy_lookup_funcs->request_create(ctx); 171 return NULL; 172 } 173 174 int sip_setup_context_buddy_lookup_submit(SipSetupContext *ctx , BuddyLookupRequest *req){ 175 if (ctx->funcs->buddy_lookup_funcs) 176 return ctx->funcs->buddy_lookup_funcs->request_submit(ctx,req); 177 return -1; 178 } 179 180 int sip_setup_context_buddy_lookup_free(SipSetupContext *ctx , BuddyLookupRequest *req){ 181 if (ctx->funcs->buddy_lookup_funcs) 182 return ctx->funcs->buddy_lookup_funcs->request_free(ctx,req); 162 183 return -1; 163 184 } … … 175 196 } 176 197 177 178 void sip_setup_context_free_results(MSList *results){179 ms_list_for_each(results,(void (*)(void*))&buddy_info_free);180 ms_list_free(results);181 }182 198 183 199 int sip_setup_context_logout(SipSetupContext *ctx){ -
linphone/coreapi/sipsetup.h
r738 r739 74 74 }BuddyInfo; 75 75 76 typedef struct _BuddyLookupRequest { 77 char *key; 78 int max_results; 79 BuddyLookupStatus status; 80 MSList *results; /*of BuddyInfo */ 81 }BuddyLookupRequest; 82 83 84 typedef struct _BuddyLookupFuncs{ 85 BuddyLookupRequest * (*request_create)(SipSetupContext *ctx); 86 int (*request_submit)(SipSetupContext *ctx, BuddyLookupRequest *req); 87 int (*request_free)(SipSetupContext *ctx, BuddyLookupRequest *req); 88 }BuddyLookupFuncs; 89 76 90 77 91 struct _SipSetup{ … … 89 103 int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); 90 104 int (*get_relay)(SipSetupContext *ctx, char *relay, size_t size); 91 int (*lookup_buddy)(SipSetupContext *ctx, const char *key);92 BuddyLookupStatus (*get_buddy_lookup_status)(SipSetupContext *ctx);93 int (*get_buddy_lookup_results)(SipSetupContext *ctx, MSList **results);94 105 const char * (*get_notice)(SipSetupContext *ctx); 95 106 const char ** (*get_domains)(SipSetupContext *ctx); 96 107 int (*logout_account)(SipSetupContext *ctx); 108 BuddyLookupFuncs *buddy_lookup_funcs; 97 109 }; 98 110 99 111 typedef struct _SipSetup SipSetup; 112 100 113 101 114 … … 106 119 BuddyInfo *buddy_info_new(); 107 120 void buddy_info_free(BuddyInfo *info); 121 122 void buddy_lookup_request_set_key(BuddyLookupRequest *req, const char *key); 123 void buddy_lookup_request_set_max_results(BuddyLookupRequest *req, int ncount); 108 124 109 125 … … 122 138 int sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); 123 139 int sip_setup_context_get_relay(SipSetupContext *ctx, char *relay, size_t size); 124 int sip_setup_context_lookup_buddy(SipSetupContext *ctx, const char *key); 125 BuddyLookupStatus sip_setup_context_get_buddy_lookup_status(SipSetupContext *ctx); 126 int sip_setup_context_get_buddy_lookup_results(SipSetupContext *ctx, MSList **results /*of BuddyInfo */); 140 141 BuddyLookupRequest *sip_setup_context_create_buddy_lookup_request(SipSetupContext *ctx); 142 int sip_setup_context_buddy_lookup_submit(SipSetupContext *ctx , BuddyLookupRequest *req); 143 int sip_setup_context_buddy_lookup_free(SipSetupContext *ctx , BuddyLookupRequest *req); 144 127 145 const char * sip_setup_context_get_notice(SipSetupContext *ctx); 128 146 const char ** sip_setup_context_get_domains(SipSetupContext *ctx); 129 147 130 void sip_setup_context_free_results(MSList *results);131 148 void sip_setup_context_free(SipSetupContext *ctx); 132 149 133 150 int sip_setup_context_logout(SipSetupContext *ctx); 134 151 135 /*internal methods */152 /*internal methods for use WITHIN plugins: do not use elsewhere*/ 136 153 struct _LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx); 137 154 void buddy_lookup_request_free(BuddyLookupRequest *req); 138 155 139 156 #ifdef __cplusplus -
linphone/gtk-glade/buddylookup.c
r738 r739 139 139 MSList *results=NULL; 140 140 GtkProgressBar *pb=GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")); 141 ctx=(SipSetupContext*)g_object_get_data(G_OBJECT(w),"SipSetupContext"); 141 BuddyLookupRequest *req=(BuddyLookupRequest*)g_object_get_data(G_OBJECT(w),"buddylookup_request"); 142 143 ctx=(SipSetupContext*)g_object_get_data(G_OBJECT(w),"SipSetupContext"); 142 144 last_state=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"last_state")); 143 bls=sip_setup_context_get_buddy_lookup_status(ctx); 145 146 if (req==NULL) return FALSE; 147 bls=req->status; 144 148 if (last_state==bls) return TRUE; 145 149 switch(bls){ … … 165 169 break; 166 170 case BuddyLookupDone: 167 sip_setup_context_get_buddy_lookup_results(ctx,&results);171 results=req->results; 168 172 linphone_gtk_display_lookup_results( 169 173 linphone_gtk_get_widget(w,"search_results"), … … 175 179 gtk_progress_bar_set_text(pb,tmp); 176 180 g_free(tmp); 177 if (results) sip_setup_context_free_results(results); 181 sip_setup_context_buddy_lookup_free(ctx,req); 182 g_object_set_data(G_OBJECT(w),"buddylookup_request",NULL); 178 183 break; 179 184 } … … 191 196 keyword=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"keyword"))); 192 197 if (strlen(keyword)>=1){ 198 BuddyLookupRequest *req; 193 199 guint tid2; 194 200 ctx=(SipSetupContext*)g_object_get_data(G_OBJECT(w),"SipSetupContext"); 195 sip_setup_context_lookup_buddy(ctx,keyword); 201 req=(BuddyLookupRequest*)g_object_get_data(G_OBJECT(w),"buddylookup_request"); 202 if (req!=NULL){ 203 sip_setup_context_buddy_lookup_free(ctx,req); 204 } 205 req=sip_setup_context_create_buddy_lookup_request(ctx); 206 buddy_lookup_request_set_key(req,keyword); 207 sip_setup_context_buddy_lookup_submit(ctx,req); 208 g_object_set_data(G_OBJECT(w),"buddylookup_request",req); 196 209 if (g_object_get_data(G_OBJECT(w),"buddylookup_processing")==NULL){ 197 210 tid2=g_timeout_add(20,(GSourceFunc)linphone_gtk_process_buddy_lookup,w); -
linphone/gtk-glade/friendlist.c
r645 r739 29 29 FRIEND_ID, 30 30 FRIEND_SIP_ADDRESS, 31 FRIEND_ICON, 31 32 FRIEND_LIST_NCOL 32 33 }; … … 186 187 187 188 store = gtk_list_store_new(FRIEND_LIST_NCOL, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, 188 G_TYPE_STRING); 189 /* need to add friends to the store here ...*/ 190 189 G_TYPE_STRING, GDK_TYPE_PIXBUF); 190 191 191 gtk_tree_view_set_model(GTK_TREE_VIEW(friendlist),GTK_TREE_MODEL(store)); 192 192 g_object_unref(G_OBJECT(store)); 193 193 194 renderer = gtk_cell_renderer_pixbuf_new(); 195 column = gtk_tree_view_column_new_with_attributes (NULL, 196 renderer, 197 "pixbuf", FRIEND_PRESENCE_IMG, 198 NULL); 199 gtk_tree_view_column_set_min_width (column, 29); 200 gtk_tree_view_append_column (GTK_TREE_VIEW (friendlist), column); 201 202 gtk_tree_view_column_set_visible(column,linphone_gtk_get_ui_config_int("friendlist_icon",1)); 203 204 renderer = gtk_cell_renderer_text_new (); 194 renderer = gtk_cell_renderer_pixbuf_new (); 205 195 column = gtk_tree_view_column_new_with_attributes (_("Name"), 206 196 renderer, 207 " text", FRIEND_NAME,197 "pixbuf", FRIEND_ICON, 208 198 NULL); 209 199 g_object_set (G_OBJECT(column), "resizable", TRUE, NULL); 200 renderer = gtk_cell_renderer_text_new (); 201 gtk_tree_view_column_pack_start(column,renderer,FALSE); 202 gtk_tree_view_column_add_attribute (column,renderer, 203 "text", 204 FRIEND_NAME); 205 210 206 gtk_tree_view_append_column (GTK_TREE_VIEW (friendlist), column); 211 207 … … 215 211 NULL); 216 212 g_object_set (G_OBJECT(column), "resizable", TRUE, NULL); 213 gtk_tree_view_column_set_visible(column,linphone_gtk_get_ui_config_int("friendlist_status",1)); 214 215 renderer = gtk_cell_renderer_pixbuf_new(); 216 gtk_tree_view_column_pack_start(column,renderer,FALSE); 217 gtk_tree_view_column_add_attribute (column,renderer, 218 "pixbuf", 219 FRIEND_PRESENCE_IMG); 217 220 gtk_tree_view_append_column (GTK_TREE_VIEW (friendlist), column); 218 gtk_tree_view_column_set_visible(column,linphone_gtk_get_ui_config_int("friendlist_status",1)); 219 221 220 222 select = gtk_tree_view_get_selection (GTK_TREE_VIEW (friendlist)); 221 223 gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); … … 321 323 } 322 324 if (!online_only || (linphone_friend_get_status(lf)!=LINPHONE_STATUS_OFFLINE)){ 325 BuddyInfo *bi; 323 326 if (name==NULL || name[0]=='\0') display=addr; 324 327 gtk_list_store_append(store,&iter); … … 332 335 gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1); 333 336 g_free(escaped); 337 bi=linphone_friend_get_info(lf); 338 if (bi!=NULL && bi->image_data!=NULL){ 339 GdkPixbuf *pbuf= 340 _gdk_pixbuf_new_from_memory_at_scale(bi->image_data,bi->image_length,-1,40,TRUE); 341 if (pbuf) { 342 gtk_list_store_set(store,&iter,FRIEND_ICON,pbuf,-1); 343 g_object_unref(G_OBJECT(pbuf)); 344 } 345 } 334 346 } 335 347 ms_free(uri);
Note: See TracChangeset
for help on using the changeset viewer.
