Changeset 537d9b9 for protocols/nogaim.c
- Timestamp:
- 2016-11-20T08:40:36Z (8 years ago)
- Children:
- 3f44e43
- Parents:
- ba52ac5 (diff), 9f03c47 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rba52ac5 r537d9b9 40 40 41 41 #ifdef WITH_PLUGINS 42 GList *plugins = NULL; 43 44 static gint pluginscmp(gconstpointer a, gconstpointer b, gpointer data) 45 { 46 const struct plugin_info *ia = a; 47 const struct plugin_info *ib = b; 48 49 return g_strcasecmp(ia->name, ib->name); 50 } 51 42 52 gboolean load_plugin(char *path) 43 53 { 54 GList *l; 55 struct plugin_info *i; 56 struct plugin_info *info; 57 struct plugin_info * (*info_function) (void) = NULL; 44 58 void (*init_function) (void); 45 59 46 60 GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); 61 gboolean loaded = FALSE; 47 62 48 63 if (!mod) { 49 log_message(LOGLVL_ERROR, " Can't find `%s', not loading (%s)\n", path, g_module_error());64 log_message(LOGLVL_ERROR, "Error loading plugin `%s': %s\n", path, g_module_error()); 50 65 return FALSE; 66 } 67 68 if (g_module_symbol(mod, "init_plugin_info", (gpointer *) &info_function)) { 69 info = info_function(); 70 71 if (info->abiver != BITLBEE_ABI_VERSION_CODE) { 72 log_message(LOGLVL_ERROR, 73 "`%s' uses ABI %u but %u is required\n", 74 path, info->abiver, 75 BITLBEE_ABI_VERSION_CODE); 76 g_module_close(mod); 77 return FALSE; 78 } 79 80 if (!info->name || !info->version) { 81 log_message(LOGLVL_ERROR, 82 "Name or version missing from the " 83 "plugin info in `%s'\n", path); 84 g_module_close(mod); 85 return FALSE; 86 } 87 88 for (l = plugins; l; l = l->next) { 89 i = l->data; 90 91 if (g_strcasecmp(i->name, info->name) == 0) { 92 loaded = TRUE; 93 break; 94 } 95 } 96 97 if (loaded) { 98 log_message(LOGLVL_WARNING, 99 "%s plugin already loaded\n", 100 info->name); 101 g_module_close(mod); 102 return FALSE; 103 } 104 } else { 105 log_message(LOGLVL_WARNING, "Can't find function `init_plugin_info' in `%s'\n", path); 51 106 } 52 107 53 108 if (!g_module_symbol(mod, "init_plugin", (gpointer *) &init_function)) { 54 109 log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path); 110 g_module_close(mod); 55 111 return FALSE; 56 112 } 57 113 114 if (info_function) { 115 plugins = g_list_insert_sorted_with_data(plugins, info, 116 pluginscmp, NULL); 117 } 118 58 119 init_function(); 59 60 120 return TRUE; 61 121 } … … 73 133 74 134 while ((entry = g_dir_read_name(dir))) { 135 if (!g_str_has_suffix(entry, "." G_MODULE_SUFFIX)) { 136 continue; 137 } 138 75 139 path = g_build_filename(global.conf->plugindir, entry, NULL); 76 140 if (!path) { … … 86 150 g_dir_close(dir); 87 151 } 152 } 153 154 GList *get_plugins() 155 { 156 return plugins; 88 157 } 89 158 #endif … … 168 237 load_plugins(); 169 238 #endif 239 } 240 241 GList *get_protocols() 242 { 243 return protocols; 244 } 245 246 GList *get_protocols_disabled() 247 { 248 return disabled_protocols; 170 249 } 171 250 … … 495 574 } 496 575 497 /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM 498 modules to suggest a nickname for a handle. */ 499 void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick) 576 /* Implements either imcb_buddy_nick_hint() or imcb_buddy_nick_change() depending on the value of 'change' */ 577 static void buddy_nick_hint_or_change(struct im_connection *ic, const char *handle, const char *nick, gboolean change) 500 578 { 501 579 bee_t *bee = ic->bee; … … 509 587 bu->nick = g_strdup(nick); 510 588 511 if (bee->ui->user_nick_hint) { 589 if (change && bee->ui->user_nick_change) { 590 bee->ui->user_nick_change(bee, bu, nick); 591 } else if (!change && bee->ui->user_nick_hint) { 512 592 bee->ui->user_nick_hint(bee, bu, nick); 513 593 } 594 } 595 596 /* Soft variant, for newly created users. Does nothing if it's already online */ 597 void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick) 598 { 599 buddy_nick_hint_or_change(ic, handle, nick, FALSE); 600 } 601 602 /* Hard variant, always changes the nick */ 603 void imcb_buddy_nick_change(struct im_connection *ic, const char *handle, const char *nick) 604 { 605 buddy_nick_hint_or_change(ic, handle, nick, TRUE); 514 606 } 515 607 … … 667 759 if (away && *away) { 668 760 GList *m = ic->acc->prpl->away_states(ic); 761 if (m == NULL) { 762 return 0; 763 } 669 764 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 670 765 away = imc_away_state_find(m, away, &msg) ? :
Note: See TracChangeset
for help on using the changeset viewer.