static void __clear_user_list(TrepiaSession *session) { GaimBlistNode *gnode, *cnode, *bnode; for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { cnode = gnode->child; while(cnode) { if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { bnode = cnode->child; cnode = cnode->next; while(bnode) { GaimBuddy *buddy = (GaimBuddy *)bnode; if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && buddy->account == session->gc->account) { bnode = bnode->next; gaim_blist_remove_buddy(buddy); } else { bnode = bnode->next; } } } else { cnode = cnode->next; } } } }
static gboolean check_timeout(gpointer data) { gint count = check_mail(); GaimBuddyList *list = gaim_get_blist(); if (count == -1) return FALSE; if (!list || !GAIM_IS_GTK_BLIST(list) || !(GAIM_GTK_BLIST(list)->vbox)) return TRUE; if (!mail) { /* guess we better build it then :P */ GtkWidget *vbox = GAIM_GTK_BLIST(list)->vbox; mail = gtk_label_new("No mail messages."); gtk_box_pack_start(GTK_BOX(vbox), mail, FALSE, FALSE, 0); gtk_box_reorder_child(GTK_BOX(vbox), mail, 1); g_signal_connect(G_OBJECT(mail), "destroy", G_CALLBACK(destroy_cb), NULL); gtk_widget_show(mail); } if (count & NEW_MAIL) gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); if (count & UNREAD_MAIL) gtk_label_set_text(GTK_LABEL(mail), "You have new mail!"); else if (count & ANY_MAIL) gtk_label_set_text(GTK_LABEL(mail), "You have mail."); else gtk_label_set_text(GTK_LABEL(mail), "No mail messages."); return TRUE; }
static void signon_cb(GaimConnection *gc) { GaimBuddyList *list = gaim_get_blist(); if (list && GAIM_IS_GTK_BLIST(list) && !timer) { check_timeout(NULL); /* we want the box to be drawn immediately */ timer = g_timeout_add(2000, check_timeout, NULL); } }
static void signoff_cb(GaimConnection *gc) { GaimBuddyList *list = gaim_get_blist(); if ((!list || !GAIM_IS_GTK_BLIST(list) || !GAIM_GTK_BLIST(list)->vbox) && timer) { g_source_remove(timer); timer = 0; } }
static void update_buddy_idle(GaimBuddy *buddy, GaimPresence *presence, time_t current_time, gboolean old_idle, gboolean idle) { GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); if (!old_idle && idle) { if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(buddy->account, FALSE); if (log != NULL) { char *tmp = g_strdup_printf(_("%s became idle"), gaim_buddy_get_alias(buddy)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_buddy_get_alias(buddy), current_time, tmp); g_free(tmp); } } } else if (old_idle && !idle) { if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(buddy->account, FALSE); if (log != NULL) { char *tmp = g_strdup_printf(_("%s became unidle"), gaim_buddy_get_alias(buddy)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_buddy_get_alias(buddy), current_time, tmp); g_free(tmp); } } } if (old_idle != idle) gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-changed", buddy, old_idle, idle); gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); /* Should this be done here? It'd perhaps make more sense to * connect to buddy-[un]idle signals and update from there */ if (ops != NULL && ops->update != NULL) ops->update(gaim_get_blist(), (GaimBlistNode *)buddy); }
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 void notify_buddy_status_update(GaimBuddy *buddy, GaimPresence *presence, GaimStatus *old_status, GaimStatus *new_status) { GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); if (gaim_prefs_get_bool("/core/logging/log_system")) { time_t current_time = time(NULL); const char *buddy_alias = gaim_buddy_get_alias(buddy); char *tmp; GaimLog *log; if (old_status != NULL) { tmp = g_strdup_printf(_("%s changed status from %s to %s"), buddy_alias, gaim_status_get_name(old_status), gaim_status_get_name(new_status)); } else { /* old_status == NULL when an independent status is toggled. */ if (gaim_status_is_active(new_status)) { tmp = g_strdup_printf(_("%s is now %s"), buddy_alias, gaim_status_get_name(new_status)); } else { tmp = g_strdup_printf(_("%s is no longer %s"), buddy_alias, gaim_status_get_name(new_status)); } } log = gaim_account_get_log(buddy->account, FALSE); if (log != NULL) { gaim_log_write(log, GAIM_MESSAGE_SYSTEM, buddy_alias, current_time, tmp); } g_free(tmp); } if (ops != NULL && ops->update != NULL) ops->update(gaim_get_blist(), (GaimBlistNode*)buddy); }
static gboolean plugin_load(GaimPlugin *plugin) { GaimBuddyList *list = gaim_get_blist(); void *conn_handle = gaim_connections_get_handle(); if (!check_timeout(NULL)) { gaim_debug_warning("mailchk", "Could not read $MAIL or /var/spool/mail/$USER"); return FALSE; } if (list && GAIM_IS_GTK_BLIST(list) && GAIM_GTK_BLIST(list)->vbox) timer = g_timeout_add(2000, check_timeout, NULL); gaim_signal_connect(conn_handle, "signed-on", plugin, GAIM_CALLBACK(signon_cb), NULL); gaim_signal_connect(conn_handle, "signed-off", plugin, GAIM_CALLBACK(signoff_cb), NULL); return TRUE; }
void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state) { GaimConnectionUiOps *ops; g_return_if_fail(gc != NULL); if (gc->state == state) return; gc->state = state; ops = gaim_get_connection_ui_ops(); if (gc->state == GAIM_CONNECTING) { connections_connecting = g_list_append(connections_connecting, gc); } else { connections_connecting = g_list_remove(connections_connecting, gc); } if (gc->state == GAIM_CONNECTED) { GaimBlistNode *gnode,*cnode,*bnode; GList *wins; GList *add_buds=NULL; /* Set the time the account came online */ time(&gc->login_time); if (ops != NULL && ops->connected != NULL) ops->connected(gc); gaim_blist_show(); gaim_blist_add_account(gc->account); /* * 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) { GaimWindow *win = (GaimWindow *)wins->data; gaim_conversation_update(gaim_window_get_conversation_at(win, 0), GAIM_CONV_ACCOUNT_ONLINE); } gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); system_log(log_signon, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); #if 0 /* away option given? */ if (opt_away) { away_on_login(opt_away_arg); /* don't do it again */ opt_away = 0; } else if (awaymessage) { serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); } if (opt_away_arg != NULL) { g_free(opt_away_arg); opt_away_arg = NULL; } #endif /* let the prpl know what buddies we pulled out of the local list */ for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; for(cnode = gnode->child; cnode; cnode = cnode->next) { if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) continue; for(bnode = cnode->child; bnode; bnode = bnode->next) { GaimBuddy *b; if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (GaimBuddy *)bnode; if(b->account == gc->account) { add_buds = g_list_append(add_buds, b->name); } } } } if(add_buds) { serv_add_buddies(gc, add_buds); g_list_free(add_buds); } serv_set_permit_deny(gc); } else if (gc->state == GAIM_DISCONNECTED) { if (ops != NULL && ops->disconnected != NULL) ops->disconnected(gc); } }