void do_im_back(GtkWidget *w, GtkWidget *x) { if (imaway) { GtkWidget *tmp = imaway; purge_away_queue(&message_queue); imaway = NULL; gtk_widget_destroy(tmp); if (w != tmp) return; } awaymessage = NULL; awayqueue = NULL; awayqueuesw = NULL; if (awayqueuestore != NULL) g_object_unref(G_OBJECT(awayqueuestore)); awayqueuestore = NULL; serv_set_away_all(NULL); }
/* go through file and run any commands */ void run_commands() { struct stat finfo; char filename[256]; char buffer[1024]; char *command, *arg1, *arg2; FILE *file; sprintf(filename, "%s/.gaim/control", getenv("HOME")); file = fopen(filename, "r+"); while (fgets(buffer, sizeof buffer, file)) { if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0; gaim_debug(GAIM_DEBUG_MISC, "filectl", "read: %s\n", buffer); command = getarg(buffer, 0, 0); if (!strncasecmp(command, "signon", 6)) { GaimAccount *account = NULL; GList *accts = gaim_accounts_get_all(); arg1 = getarg(buffer, 1, 1); if (arg1) { while (accts) { GaimAccount *a = accts->data; if (!strcmp(a->username, arg1)) { account = a; break; } accts = accts->next; } free(arg1); } if (account) /* username found */ gaim_account_connect(account); } else if (!strncasecmp(command, "signoff", 7)) { GaimConnection *gc = NULL; GList *c = gaim_connections_get_all(); arg1 = getarg(buffer, 1, 1); while (arg1 && c) { gc = c->data; if (!strcmp(gc->account->username, arg1)) { break; } gc = NULL; c = c->next; } if (gc) gaim_connection_disconnect(gc); else if (!arg1) gaim_connections_disconnect_all(); free(arg1); } else if (!strncasecmp(command, "send", 4)) { GaimConversation *c; arg1 = getarg(buffer, 1, 0); arg2 = getarg(buffer, 2, 1); c = gaim_find_conversation(arg1); if (c) { /* disable for now gaim_conversation_write(c, arg2, WFLAG_SEND, NULL, time(NULL), -1); serv_send_im(c->gc, arg1, arg2, 0); */ } free(arg1); free(arg2); } else if (!strncasecmp(command, "away", 4)) { arg1 = getarg(buffer, 1, 1); serv_set_away_all(arg1); free(arg1); } else if (!strncasecmp(command, "hide", 4)) { /* hide_buddy_list(); */ } else if (!strncasecmp(command, "unhide", 6)) { /* unhide_buddy_list(); */ } else if (!strncasecmp(command, "back", 4)) { /* do_im_back(); */ } else if (!strncasecmp(command, "quit", 4)) { /* gaim_core_quit(); */ } free(command); } fclose(file); if (stat (filename, &finfo) != 0) return; mtime = finfo.st_mtime; }
void do_away_message(GtkWidget *w, struct away_message *a) { GtkWidget *back; GtkWidget *edit; GtkWidget *awaytext; GtkWidget *sw; GtkWidget *vbox; GtkWidget *hbox; GtkTreeViewColumn *column; GtkCellRenderer *renderer; char *buf; if (!a) return; if(imaway) gtk_widget_destroy(imaway); GAIM_DIALOG(imaway); gtk_window_set_role(GTK_WINDOW(imaway), "imaway"); if (strlen(a->name)) gtk_window_set_title(GTK_WINDOW(imaway), a->name); else gtk_window_set_title(GTK_WINDOW(imaway), _("Away!")); g_signal_connect(G_OBJECT(imaway), "destroy", G_CALLBACK(do_im_back), imaway); vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(imaway), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); gtk_widget_show(vbox); hbox = gtk_hbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(hbox), 0); gtk_widget_show(hbox); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); gtk_widget_set_size_request(sw, 245, 120); gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); gtk_widget_show(sw); awaytext = gtk_imhtml_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(sw), awaytext); gaim_setup_imhtml(awaytext); gtk_widget_show(awaytext); buf = stylize(a->message, BUF_LONG); gtk_imhtml_append_text(GTK_IMHTML(awaytext), buf, GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL); g_free(buf); gtk_imhtml_append_text(GTK_IMHTML(awaytext), "<BR>", GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL); awayqueuesw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(awayqueuesw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(awayqueuesw), GTK_SHADOW_IN); gtk_box_pack_start(GTK_BOX(vbox), awayqueuesw, TRUE, TRUE, 0); awayqueuestore = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); awayqueue = gtk_tree_view_new_with_model(GTK_TREE_MODEL(awayqueuestore)); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(awayqueue), FALSE); column = gtk_tree_view_column_new_with_attributes (NULL, renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", 1, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", 2, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); gtk_container_add(GTK_CONTAINER(awayqueuesw), awayqueue); g_signal_connect(G_OBJECT(awayqueue), "button_press_event", G_CALLBACK(dequeue_cb), NULL); if (gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { gtk_widget_show(awayqueuesw); gtk_widget_show(awayqueue); } awaymessage = a; edit = gaim_pixbuf_button_from_stock(_("Edit This Message"), GTK_STOCK_CONVERT, GAIM_BUTTON_HORIZONTAL); gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(edit), "clicked", G_CALLBACK(create_away_mess), awaymessage); gtk_widget_show(edit); back = gaim_pixbuf_button_from_stock(_("I'm Back!"), GTK_STOCK_JUMP_TO, GAIM_BUTTON_HORIZONTAL); gtk_box_pack_start(GTK_BOX(hbox), back, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(back), "clicked", G_CALLBACK(do_im_back), imaway); gtk_window_set_focus(GTK_WINDOW(imaway), back); gtk_widget_show(back); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(imaway); serv_set_away_all(awaymessage->message); }