static char * gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account) { GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info; const char *prpl_name; char *acct_name; const char *target; char *dir; prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); if (!prpl) return NULL; prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); prpl_name = prpl_info->list_icon(account, NULL); acct_name = g_strdup(gaim_escape_filename(gaim_normalize(account, gaim_account_get_username(account)))); if (type == GAIM_LOG_CHAT) { char *temp = g_strdup_printf("%s.chat", gaim_normalize(account, name)); target = gaim_escape_filename(temp); g_free(temp); } else if(type == GAIM_LOG_SYSTEM) { target = ".system"; } else { target = gaim_escape_filename(gaim_normalize(account, name)); } dir = g_build_filename(gaim_user_dir(), "logs", prpl_name, acct_name, target, NULL); g_free(acct_name); return dir; }
void add_chat_icon_stuff(GaimConversation * c) { GtkTreeModel *ls; GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(c); GaimGtkChatPane *gtkchat = gtkconv->u.chat; GaimPluginProtocolInfo *prpl_info = NULL; GaimAccount *account = gaim_conversation_get_account(c); GaymChatIcon *icon_data = g_new0(GaymChatIcon, 1); if (account && account->gc) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); ls = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); GtkBox *hbox = GTK_BOX(gtkconv->lower_hbox); g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(changed_cb), c); icon_data->icon_container_parent = GTK_WIDGET(hbox); icon_data->icon_container = NULL; icon_data->icon = NULL; icon_data->anim = NULL; icon_data->iter = NULL; icon_data->show_icon = TRUE; icon_data->icon_container = gtk_vbox_new(FALSE, 0); gtk_widget_set_size_request(GTK_WIDGET(icon_data->icon_container), prpl_info->icon_spec.max_width, prpl_info->icon_spec.max_height); icon_data->frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(icon_data->frame), (GTK_SHADOW_IN)); gtk_box_pack_start(GTK_BOX(icon_data->icon_container), icon_data->frame, FALSE, FALSE, 0); gtk_widget_show(icon_data->icon_container); gtk_widget_show(icon_data->frame); gtk_box_pack_end(GTK_BOX(icon_data->icon_container_parent), icon_data->icon_container, FALSE, FALSE, 0); icon_data->event = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(icon_data->frame), icon_data->event); // Maybe add menu functionality later. // g_signal_connect(G_OBJECT(icon_data->event), "button-press-event", // G_CALLBACK(icon_menu), conv); gtk_widget_show(icon_data->event); g_hash_table_insert(icons, c, icon_data); }
GaimRoomlist *gaim_roomlist_get_list(GaimConnection *gc) { GaimPluginProtocolInfo *prpl_info = NULL; g_return_val_if_fail(gc != NULL, NULL); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->roomlist_get_list) return prpl_info->roomlist_get_list(gc); return NULL; }
static GaimChat *gaym_find_blist_chat(GaimAccount * account, const char *name) { char *chat_name; GaimChat *chat; GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info = NULL; struct proto_chat_entry *pce; GaimBlistNode *node, *group; GList *parts; GaimBuddyList *gaimbuddylist = gaim_get_blist(); g_return_val_if_fail(gaimbuddylist != NULL, NULL); g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); if (!gaim_account_is_connected(account)) return NULL; prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); for (group = gaimbuddylist->root; group != NULL; group = group->next) { for (node = group->child; node != NULL; node = node->next) { if (GAIM_BLIST_NODE_IS_CHAT(node)) { chat = (GaimChat *) node; if (account != chat->account) continue; parts = prpl_info-> chat_info(gaim_account_get_connection(chat->account)); pce = parts->data; chat_name = g_hash_table_lookup(chat->components, pce->identifier); if (chat->account == account && chat_name != NULL && name != NULL && g_pattern_match_simple(chat_name, name)) { return chat; } } } } return NULL; }
static gboolean send_keepalive(gpointer data) { GaimConnection *gc = data; GaimPluginProtocolInfo *prpl_info = NULL; if (gc != NULL && gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->keepalive) prpl_info->keepalive(gc); return TRUE; }
void gaim_connection_register(GaimConnection *gc) { GaimAccount *account; GaimConnectionUiOps *ops; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(gc != NULL); gaim_debug(GAIM_DEBUG_INFO, "connection", "Registering. gc = %p\n", gc); ops = gaim_get_connection_ui_ops(); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); else { gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(gaim_connection_get_account(gc))); gaim_debug(GAIM_DEBUG_ERROR, "connection", "Could not get prpl info for %p\n", gc); gaim_notify_error(NULL, _("Registration Error"), message, NULL); g_free(message); return; } account = gaim_connection_get_account(gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) return; gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling register_user\n"); prpl_info->register_user(account); }
void gaim_roomlist_cancel_get_list(GaimRoomlist *list) { GaimPluginProtocolInfo *prpl_info = NULL; GaimConnection *gc; g_return_if_fail(list != NULL); gc = gaim_account_get_connection(list->account); g_return_if_fail(gc != NULL); if (gc != NULL && gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->roomlist_cancel) prpl_info->roomlist_cancel(list); }
void gaim_roomlist_expand_category(GaimRoomlist *list, GaimRoomlistRoom *category) { GaimPluginProtocolInfo *prpl_info = NULL; GaimConnection *gc; g_return_if_fail(list != NULL); g_return_if_fail(category != NULL); g_return_if_fail(category->type & GAIM_ROOMLIST_ROOMTYPE_CATEGORY); gc = gaim_account_get_connection(list->account); g_return_if_fail(gc != NULL); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->roomlist_expand_category) prpl_info->roomlist_expand_category(list, category); }
void send_auto_reply(GaimAccount * account, const char *recipient, const char *message) { int i = 0; GaimConnection *gc = NULL; GaimPluginProtocolInfo *prpl_info = NULL; gc = gaim_account_get_connection(account); if (gc != NULL && gc->prpl != NULL) { prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); } if (prpl_info && prpl_info->send_im) { i = prpl_info->send_im(gc, recipient, message, GAIM_CONV_IM_AUTO_RESP); } return; }
static void update_keepalive(GaimConnection *gc, gboolean on) { GaimPluginProtocolInfo *prpl_info = NULL; if (gc != NULL && gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (!prpl_info || !prpl_info->keepalive) return; if (on && !gc->keepalive) { gaim_debug_info("connection", "Activating keepalive.\n"); gc->keepalive = gaim_timeout_add(30000, send_keepalive, gc); } else if (!on && gc->keepalive > 0) { gaim_debug_info("connection", "Deactivating keepalive.\n"); gaim_timeout_remove(gc->keepalive); gc->keepalive = 0; } }
void gaim_connection_destroy(GaimConnection *gc) { GaimAccount *account; GSList *buddies, *tmp; #if 0 GList *wins; #endif GaimPluginProtocolInfo *prpl_info = NULL; gboolean remove = FALSE; g_return_if_fail(gc != NULL); account = gaim_connection_get_account(gc); gaim_debug_info("connection", "Disconnecting connection %p\n", gc); if (gaim_connection_get_state(gc) != GAIM_CONNECTING) remove = TRUE; gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); while (gc->buddy_chats) { GaimConversation *b = gc->buddy_chats->data; gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); gaim_conv_chat_left(GAIM_CONV_CHAT(b)); } update_keepalive(gc, FALSE); gaim_proxy_connect_cancel_with_handle(gc); prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->close) (prpl_info->close)(gc); /* Clear out the proto data that was freed in the prpl close method*/ buddies = gaim_find_buddies(account, NULL); for (tmp = buddies; tmp; tmp = tmp->next) { GaimBuddy *buddy = tmp->data; buddy->proto_data = NULL; } g_slist_free(buddies); connections = g_list_remove(connections, gc); gaim_connection_set_state(gc, GAIM_DISCONNECTED); if (remove) gaim_blist_remove_account(account); gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); #if 0 /* see comment later in file on if 0'd same code */ /* * XXX This is a hack! Remove this and replace it with a better event * notification system. */ for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { GaimConvWindow *win = (GaimConvWindow *)wins->data; gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), GAIM_CONV_ACCOUNT_OFFLINE); } #endif gaim_request_close_with_handle(gc); gaim_notify_close_with_handle(gc); gaim_debug_info("connection", "Destroying connection %p\n", gc); gaim_account_set_connection(account, NULL); g_free(gc->password); g_free(gc->display_name); if (gc->disconnect_timeout) gaim_timeout_remove(gc->disconnect_timeout); GAIM_DBUS_UNREGISTER_POINTER(gc); g_free(gc); }
void gaim_connection_connect(GaimConnection *gc) { GaimAccount *account; GaimConnectionUiOps *ops; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(gc != NULL); gaim_debug(GAIM_DEBUG_INFO, "connection", "Connecting. gc = %p\n", gc); ops = gaim_get_connection_ui_ops(); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); else { gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(gaim_connection_get_account(gc))); gaim_debug(GAIM_DEBUG_ERROR, "connection", "Could not get prpl info for %p\n", gc); gaim_notify_error(NULL, _("Connection Error"), message, NULL); g_free(message); return; } account = gaim_connection_get_account(gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) return; if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) && gaim_account_get_password(account) == NULL) { gchar *primary; gchar *escaped; const gchar *username = gaim_account_get_username(account); gaim_debug(GAIM_DEBUG_INFO, "connection", "Requesting password\n"); gaim_connection_destroy(gc); escaped = g_markup_escape_text(username, strlen(username)); primary = g_strdup_printf(_("Enter password for %s"), escaped); gaim_request_input(gc, NULL, primary, NULL, NULL, FALSE, TRUE, _("OK"), G_CALLBACK(request_pass_ok_cb), _("Cancel"), NULL, account); g_free(primary); g_free(escaped); return; } gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n"); serv_login(account); }
void gaim_presence_set_idle(GaimPresence *presence, gboolean idle, time_t idle_time) { gboolean old_idle; g_return_if_fail(presence != NULL); if (presence->idle == idle && presence->idle_time == idle_time) return; old_idle = presence->idle; presence->idle = idle; presence->idle_time = (idle ? idle_time : 0); if (gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_BUDDY) { const GList *l; time_t current_time = time(NULL); for (l = gaim_presence_get_buddies(presence); l != NULL; l = l->next) { update_buddy_idle((GaimBuddy *)l->data, presence, current_time, old_idle, idle); } } else if(gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_ACCOUNT) { GaimAccount *account; GaimConnection *gc; GaimPluginProtocolInfo *prpl_info = NULL; account = gaim_presence_get_account(presence); if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(account, FALSE); if (log != NULL) { char *msg; if (idle) msg = g_strdup_printf(_("+++ %s became idle"), gaim_account_get_username(account)); else msg = g_strdup_printf(_("+++ %s became unidle"), gaim_account_get_username(account)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_account_get_username(account), idle_time, msg); g_free(msg); } } gc = gaim_account_get_connection(account); if (gc != NULL && GAIM_CONNECTION_IS_CONNECTED(gc) && gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->set_idle) prpl_info->set_idle(gc, (idle ? (time(NULL) - idle_time) : 0)); } }
void do_away_menu() { GtkWidget *menuitem; GtkWidget *remmenu; GtkWidget *submenu, *submenu2; GtkWidget *remitem; GtkWidget *image; GdkPixbuf *pixbuf, *scale; GList *l; GSList *awy = away_messages; struct away_message *a; GList *con; GaimConnection *gc = NULL; GaimPluginProtocolInfo *prpl_info = NULL; int count = 0; if (prefs_away_store != NULL) { gtk_list_store_clear(prefs_away_store); while (awy) { GtkTreeIter iter; a = (struct away_message *)awy->data; gtk_list_store_append(prefs_away_store, &iter); gtk_list_store_set(prefs_away_store, &iter, 0, a->name, 1, a, -1); awy = g_slist_next(awy); } } if (awaymenu) { l = gtk_container_get_children(GTK_CONTAINER(awaymenu)); while (l) { gtk_container_remove(GTK_CONTAINER(awaymenu), GTK_WIDGET(l->data)); l = l->next; } g_list_free(l); remmenu = gtk_menu_new(); menuitem = gtk_menu_item_new_with_label(_("New Away Message")); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(create_away_mess), NULL); awy = away_messages; while (awy) { a = (struct away_message *)awy->data; remitem = gtk_menu_item_new_with_label(a->name); gtk_menu_shell_append(GTK_MENU_SHELL(remmenu), remitem); gtk_widget_show(remitem); g_signal_connect(G_OBJECT(remitem), "activate", G_CALLBACK(rem_away_mess), a); awy = g_slist_next(awy); } menuitem = gtk_menu_item_new_with_label(_("Remove Away Message")); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu); gtk_widget_show(remmenu); gaim_separator(awaymenu); for (con = gaim_connections_get_all(); con != NULL; con = con->next) { gc = con->data; prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->away_states != NULL && prpl_info->set_away != NULL) count++; } if (count == 0) { } else if (count == 1) { GList *msgs, *tmp; for (con = gaim_connections_get_all(); con != NULL; con = con->next) { gc = con->data; prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->away_states && prpl_info->set_away) break; } tmp = msgs = prpl_info->away_states(gc); if ((g_list_length(msgs) == 1) && !strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { awy = away_messages; while (awy) { a = (struct away_message *)awy->data; menuitem = gtk_menu_item_new_with_label(a->name); g_object_set_data(G_OBJECT(menuitem), "away_message", a); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(do_away_message), a); awy = g_slist_next(awy); } } else while (msgs) { awy = away_messages; menuitem = gtk_menu_item_new_with_label(msgs->data); g_object_set_data(G_OBJECT(menuitem), "away_state", msgs->data); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(set_gc_state), gc); } else { submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); gtk_widget_show(submenu); while (awy) { a = (struct away_message *)awy->data; menuitem = gtk_menu_item_new_with_label(a->name); g_object_set_data(G_OBJECT(menuitem), "away_message", a); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK (do_away_message), a); awy = g_slist_next(awy); } } msgs = g_list_next(msgs); } g_list_free(tmp); } else { for (con = gaim_connections_get_all(); con != NULL; con = con->next) { GaimAccount *account; char buf[256]; GList *msgs, *tmp; gc = con->data; prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (!prpl_info->away_states || !prpl_info->set_away) continue; account = gaim_connection_get_account(gc); g_snprintf(buf, sizeof(buf), "%s (%s)", gaim_account_get_username(account), gaim_account_get_protocol_name(account)); menuitem = gtk_image_menu_item_new_with_label(buf); pixbuf = create_prpl_icon(gc->account); if (pixbuf) { scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); image = gtk_image_new_from_pixbuf(scale); g_object_unref(G_OBJECT(pixbuf)); g_object_unref(G_OBJECT(scale)); gtk_widget_show(image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); } gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); gtk_widget_show(submenu); tmp = msgs = prpl_info->away_states(gc); if ((g_list_length(msgs) == 1) && (!strcmp(msgs->data, GAIM_AWAY_CUSTOM))) { menuitem = gtk_menu_item_new_with_label(_("Back")); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(set_gc_away), gc); gaim_separator(submenu); awy = away_messages; while (awy) { a = (struct away_message *)awy->data; menuitem = gtk_menu_item_new_with_label(a->name); g_object_set_data(G_OBJECT(menuitem), "away_message", a); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(set_gc_away), gc); awy = g_slist_next(awy); } } else while (msgs) { awy = away_messages; menuitem = gtk_menu_item_new_with_label(msgs->data); g_object_set_data(G_OBJECT(menuitem), "away_state", msgs->data); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); gtk_widget_show(menuitem); if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(set_gc_state), gc); } else { submenu2 = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM (menuitem), submenu2); gtk_widget_show(submenu2); while (awy) { a = (struct away_message *)awy->data; menuitem = gtk_menu_item_new_with_label(a-> name); g_object_set_data(G_OBJECT(menuitem), "away_message", a); gtk_menu_shell_append(GTK_MENU_SHELL(submenu2), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK (set_gc_away), gc); awy = g_slist_next(awy); } } msgs = g_list_next(msgs); } g_list_free(tmp); } menuitem = gtk_menu_item_new_with_label(_("Set All Away")); gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); gtk_widget_show(menuitem); submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); gtk_widget_show(submenu); awy = away_messages; while (awy) { a = (struct away_message *)awy->data; menuitem = gtk_menu_item_new_with_label(a->name); g_object_set_data(G_OBJECT(menuitem), "away_message", a); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); gtk_widget_show(menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(do_away_message), a); awy = g_slist_next(awy); } } } if (prefs_away_menu) { l = gtk_container_get_children(GTK_CONTAINER(prefs_away_menu)); while (l) { gtk_widget_destroy(GTK_WIDGET(l->data)); l = l->next; } gtk_widget_hide(GTK_WIDGET(prefs_away_menu)); default_away_menu_init(GTK_WIDGET(prefs_away_menu)); gtk_widget_show(prefs_away_menu); } }
void gaim_connection_new(GaimAccount *account, gboolean regist, const char *password) { GaimConnection *gc; GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info; g_return_if_fail(account != NULL); if (!gaim_account_is_disconnected(account)) return; prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); if (prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); else { gchar *message; message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(account)); gaim_notify_error(NULL, regist ? _("Registration Error") : _("Connection Error"), message, NULL); g_free(message); return; } if (regist) { if (prpl_info->register_user == NULL) return; } else { if (((password == NULL) || (*password == '\0')) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) { gaim_debug_error("connection", "Can not connect to account %s without " "a password.\n", gaim_account_get_username(account)); return; } } gc = g_new0(GaimConnection, 1); GAIM_DBUS_REGISTER_POINTER(gc, GaimConnection); gc->prpl = prpl; if ((password != NULL) && (*password != '\0')) gc->password = g_strdup(password); gaim_connection_set_account(gc, account); gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_account_set_connection(account, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); if (regist) { gaim_debug_info("connection", "Registering. gc = %p\n", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; prpl_info->register_user(account); } else { gaim_debug_info("connection", "Connecting. gc = %p\n", gc); gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account); prpl_info->login(account); } }
void gaym_update_thumbnail(GaimConversation * conv, GdkPixbuf * pixbuf) { GaimGtkConversation *gtkconv; GdkPixbuf *scale; GdkPixmap *pm = NULL; GdkBitmap *bm = NULL; int scale_width = 0, scale_height = 0; GaimAccount *account; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(conv != NULL); g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_CHAT); gtkconv = GAIM_GTK_CONVERSATION(conv); GaymChatIcon *icon_data = g_hash_table_lookup(icons, conv); if (!icon_data->show_icon) return; account = gaim_conversation_get_account(conv); if (account && account->gc) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); if (!gaim_prefs_get_bool ("/gaim/gtk/conversations/im/show_buddy_icons")) return; if (gaim_conversation_get_gc(conv) == NULL) return; get_icon_scale_size(pixbuf, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); // double // aspect=(double)gdk_pixbuf_get_width(pixbuf)/(double)gdk_pixbuf_get_height(pixbuf); // // scale = gdk_pixbuf_scale_simple(pixbuf, scale_width, scale_height, GDK_INTERP_BILINEAR); gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); g_object_unref(G_OBJECT(scale)); icon_data->event = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(icon_data->frame), icon_data->event); gtk_widget_set_size_request(GTK_WIDGET(icon_data->frame), 57, 77); // g_signal_connect(G_OBJECT(icon_data->event), "button-press-event", // G_CALLBACK(icon_menu), conv); gtk_widget_show(icon_data->event); icon_data->icon = gtk_image_new_from_pixmap(pm, bm); gtk_container_add(GTK_CONTAINER(icon_data->event), icon_data->icon); gtk_widget_show(icon_data->icon); if (pm) g_object_unref(G_OBJECT(pm)); if (bm) g_object_unref(G_OBJECT(bm)); }
void gaym_gtkconv_update_thumbnail(GaimConversation * conv, struct fetch_thumbnail_data *thumbnail_data) { GaimGtkConversation *gtkconv; char filename[256]; FILE *file; GError *err = NULL; size_t len; GdkPixbuf *buf; GdkPixbuf *scale; GdkPixmap *pm; GdkBitmap *bm; int scale_width, scale_height; GaimAccount *account; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(conv != NULL); g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_CHAT); gtkconv = GAIM_GTK_CONVERSATION(conv); GaymChatIcon *icon_data = g_hash_table_lookup(icons, conv); if (!thumbnail_data) return; if (!icon_data->show_icon) return; const char *data = thumbnail_data->pic_data; len = thumbnail_data->pic_data_len; account = gaim_conversation_get_account(conv); if (account && account->gc) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); if (icon_data->anim != NULL) g_object_unref(G_OBJECT(icon_data->anim)); icon_data->anim = NULL; if (icon_data->icon_timer != 0) g_source_remove(icon_data->icon_timer); icon_data->icon_timer = 0; if (icon_data->iter != NULL) g_object_unref(G_OBJECT(icon_data->iter)); icon_data->iter = NULL; if (!gaim_prefs_get_bool ("/gaim/gtk/conversations/im/show_buddy_icons")) return; if (gaim_conversation_get_gc(conv) == NULL) return; /* this is such an evil hack, i don't know why i'm even considering it. we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ /* gdk-pixbuf-loader was leaky? is it still? */ g_snprintf(filename, sizeof(filename), "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", g_get_tmp_dir(), thumbnail_data->who, getpid()); if (!(file = g_fopen(filename, "wb"))) return; fwrite(data, 1, len, file); fclose(file); icon_data->anim = gdk_pixbuf_animation_new_from_file(filename, &err); /* make sure we remove the file as soon as possible */ g_unlink(filename); if (err) { gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", "Buddy icon error: %s\n", err->message); g_error_free(err); } if (!icon_data->anim) return; if (gdk_pixbuf_animation_is_static_image(icon_data->anim)) { icon_data->iter = NULL; buf = gdk_pixbuf_animation_get_static_image(icon_data->anim); } else { icon_data->iter = gdk_pixbuf_animation_get_iter(icon_data->anim, NULL); /* LEAK */ buf = gdk_pixbuf_animation_iter_get_pixbuf(icon_data->iter); } get_icon_scale_size(icon_data->anim, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); scale = gdk_pixbuf_scale_simple(buf, MAX(gdk_pixbuf_get_width(buf) * scale_width / gdk_pixbuf_animation_get_width (icon_data->anim), 1), MAX(gdk_pixbuf_get_height(buf) * scale_height / gdk_pixbuf_animation_get_height (icon_data->anim), 1), GDK_INTERP_NEAREST); gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); g_object_unref(G_OBJECT(scale)); icon_data->event = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(icon_data->frame), icon_data->event); gtk_widget_set_size_request(GTK_WIDGET(icon_data->frame), scale_width, scale_height); // g_signal_connect(G_OBJECT(icon_data->event), "button-press-event", // G_CALLBACK(icon_menu), conv); gtk_widget_show(icon_data->event); icon_data->icon = gtk_image_new_from_pixmap(pm, bm); gtk_container_add(GTK_CONTAINER(icon_data->event), icon_data->icon); gtk_widget_show(icon_data->icon); g_object_unref(G_OBJECT(pm)); if (bm) g_object_unref(G_OBJECT(bm)); }