Mercurial > pidgin.yaz
comparison src/protocols/sametime/sametime.c @ 12630:97ec28aaae47
[gaim-migrate @ 14966]
added user search action to sametime
committer: Tailor Script <tailor@pidgin.im>
author | Christopher O'Brien <siege@pidgin.im> |
---|---|
date | Thu, 22 Dec 2005 19:54:52 +0000 |
parents | fee6a32644a4 |
children | e8da8f12e694 |
comparison
equal
deleted
inserted
replaced
12629:fee6a32644a4 | 12630:97ec28aaae47 |
---|---|
4264 " add them to your buddy list."); | 4264 " add them to your buddy list."); |
4265 msgB = g_strdup_printf(msgB, result->name); | 4265 msgB = g_strdup_printf(msgB, result->name); |
4266 | 4266 |
4267 gaim_notify_searchresults(gc, _("Select User"), | 4267 gaim_notify_searchresults(gc, _("Select User"), |
4268 msgA, msgB, sres, notify_close, NULL); | 4268 msgA, msgB, sres, notify_close, NULL); |
4269 | |
4270 g_free(msgB); | |
4269 } | 4271 } |
4270 | 4272 |
4271 | 4273 |
4272 static void add_buddy_resolved(struct mwServiceResolve *srvc, | 4274 static void add_buddy_resolved(struct mwServiceResolve *srvc, |
4273 guint32 id, guint32 code, GList *results, | 4275 guint32 id, guint32 code, GList *results, |
5356 _("Cancel"), NULL, | 5358 _("Cancel"), NULL, |
5357 gc); | 5359 gc); |
5358 } | 5360 } |
5359 | 5361 |
5360 | 5362 |
5363 static void search_notify(struct mwResolveResult *result, | |
5364 GaimConnection *gc) { | |
5365 GList *l; | |
5366 char *msgA, *msgB; | |
5367 | |
5368 GaimNotifySearchResults *sres; | |
5369 GaimNotifySearchColumn *scol; | |
5370 | |
5371 sres = gaim_notify_searchresults_new(); | |
5372 | |
5373 scol = gaim_notify_searchresults_column_new(_("User Name")); | |
5374 gaim_notify_searchresults_column_add(sres, scol); | |
5375 | |
5376 scol = gaim_notify_searchresults_column_new(_("Sametime ID")); | |
5377 gaim_notify_searchresults_column_add(sres, scol); | |
5378 | |
5379 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_IM, | |
5380 notify_im); | |
5381 | |
5382 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_ADD, | |
5383 notify_add); | |
5384 | |
5385 for(l = result->matches; l; l = l->next) { | |
5386 struct mwResolveMatch *match = l->data; | |
5387 GList *row = NULL; | |
5388 | |
5389 if(!match->id || !match->name) | |
5390 continue; | |
5391 | |
5392 row = g_list_append(row, g_strdup(match->name)); | |
5393 row = g_list_append(row, g_strdup(match->id)); | |
5394 gaim_notify_searchresults_row_add(sres, row); | |
5395 } | |
5396 | |
5397 msgA = _("Search results for '%s'"); | |
5398 msgB = _("The identifier '%s' may possibly refer to any of the following" | |
5399 " users. You may add these users to your buddy list or send them" | |
5400 " messages with the action buttons below."); | |
5401 | |
5402 msgA = g_strdup_printf(msgA, result->name); | |
5403 msgB = g_strdup_printf(msgB, result->name); | |
5404 | |
5405 gaim_notify_searchresults(gc, _("Search Results"), | |
5406 msgA, msgB, sres, notify_close, NULL); | |
5407 | |
5408 g_free(msgA); | |
5409 g_free(msgB); | |
5410 } | |
5411 | |
5412 | |
5413 static void search_resolved(struct mwServiceResolve *srvc, | |
5414 guint32 id, guint32 code, GList *results, | |
5415 gpointer b) { | |
5416 | |
5417 GaimConnection *gc = b; | |
5418 struct mwResolveResult *res = NULL; | |
5419 | |
5420 if(results) res = results->data; | |
5421 | |
5422 if(!code && res && res->matches) { | |
5423 search_notify(res, gc); | |
5424 | |
5425 } else { | |
5426 char *msgA, *msgB; | |
5427 msgA = _("No matches"); | |
5428 msgB = _("The identifier '%s' did not match and users in your" | |
5429 " Sametime community."); | |
5430 msgB = g_strdup_printf(msgB, NSTR(res->name)); | |
5431 | |
5432 gaim_notify_error(gc, _("No Matches"), msgA, msgB); | |
5433 | |
5434 g_free(msgB); | |
5435 } | |
5436 } | |
5437 | |
5438 | |
5439 static void search_action_cb(GaimConnection *gc, const char *name) { | |
5440 struct mwGaimPluginData *pd; | |
5441 struct mwServiceResolve *srvc; | |
5442 GList *query; | |
5443 enum mwResolveFlag flags; | |
5444 guint32 req; | |
5445 | |
5446 pd = gc->proto_data; | |
5447 srvc = pd->srvc_resolve; | |
5448 | |
5449 query = g_list_prepend(NULL, (char *) name); | |
5450 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; | |
5451 | |
5452 req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, | |
5453 gc, NULL); | |
5454 g_list_free(query); | |
5455 | |
5456 if(req == SEARCH_ERROR) { | |
5457 /** @todo display error */ | |
5458 } | |
5459 } | |
5460 | |
5461 | |
5462 static void search_action(GaimPluginAction *act) { | |
5463 GaimConnection *gc; | |
5464 const char *msgA, *msgB; | |
5465 | |
5466 gc = act->context; | |
5467 | |
5468 msgA = _("Search for a user"); | |
5469 msgB = _("Enter a name or partial ID in the field below to search" | |
5470 " for matching users in your Sametime community."); | |
5471 | |
5472 gaim_request_input(gc, _("User Search"), msgA, msgB, NULL, | |
5473 FALSE, FALSE, NULL, | |
5474 _("Search"), G_CALLBACK(search_action_cb), | |
5475 _("Cancel"), NULL, | |
5476 gc); | |
5477 } | |
5478 | |
5479 | |
5361 static GList *mw_plugin_actions(GaimPlugin *plugin, gpointer context) { | 5480 static GList *mw_plugin_actions(GaimPlugin *plugin, gpointer context) { |
5362 GaimPluginAction *act; | 5481 GaimPluginAction *act; |
5363 GList *l = NULL; | 5482 GList *l = NULL; |
5364 | 5483 |
5365 act = gaim_plugin_action_new(_("Import Sametime List..."), | 5484 act = gaim_plugin_action_new(_("Import Sametime List..."), |
5370 st_export_action); | 5489 st_export_action); |
5371 l = g_list_append(l, act); | 5490 l = g_list_append(l, act); |
5372 | 5491 |
5373 act = gaim_plugin_action_new(_("Add Notes Address Book Group..."), | 5492 act = gaim_plugin_action_new(_("Add Notes Address Book Group..."), |
5374 remote_group_action); | 5493 remote_group_action); |
5494 l = g_list_append(l, act); | |
5495 | |
5496 act = gaim_plugin_action_new(_("User Search..."), | |
5497 search_action); | |
5375 l = g_list_append(l, act); | 5498 l = g_list_append(l, act); |
5376 | 5499 |
5377 return l; | 5500 return l; |
5378 } | 5501 } |
5379 | 5502 |