Yattm - unified GTK instant-messaging client | |
[Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003] |
#include "intl.h"
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "gtk_globals.h"
#include "status.h"
#include "util.h"
#include "dialog.h"
#include "value_pair.h"
#include "pixmaps/ok.xpm"
#include "pixmaps/cancel.xpm"
#include "pixmaps/tb_trash.xpm"
#include "pixmaps/tb_edit.xpm"
#include "pixmaps/tb_preferences.xpm"
Include dependency graph for editcontacts.c:
Go to the source code of this file.
Typedefs | |
typedef char * | account_row [3] |
Enumerations | |
enum | { USER_NAME, PASSWORD, SERVICE_TYPE } |
Functions | |
void | destroy (GtkWidget *widget, gpointer data) |
void | read_contacts () |
void | selection_unmade (GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data) |
void | selection_made (GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data) |
void | remove_callback (GtkWidget *widget, gpointer data) |
char * | check_login_validity (char *text[]) |
void | add_callback (GtkWidget *widget, gpointer data) |
void | modify_callback (GtkWidget *widget, gpointer data) |
void | cancel_callback (GtkWidget *widget, gpointer data) |
void | ok_callback (GtkWidget *widget, gpointer data) |
void | eb_new_user () |
Variables | |
GtkWidget * | account_list |
GtkWidget * | account_window = NULL |
GtkWidget * | username |
GtkWidget * | password |
GtkWidget * | service_type |
GtkWidget * | mod_button |
GtkWidget * | del_button |
gint | selected_row = -1 |
gboolean | is_open = FALSE |
gint | num_accounts = 0 |
|
Definition at line 56 of file editcontacts.c. Referenced by read_contacts(). |
|
Definition at line 49 of file editcontacts.c.
00050 { 00051 USER_NAME, 00052 PASSWORD, 00053 SERVICE_TYPE 00054 }; |
|
Definition at line 167 of file editcontacts.c. References _, account_list, check_login_validity(), do_error_dialog(), num_accounts, password, PASSWORD, service_type, SERVICE_TYPE, USER_NAME, and username. Referenced by eb_new_user().
00168 { 00169 char * text[3]; 00170 char * error_message = NULL; 00171 text[USER_NAME] = gtk_entry_get_text(GTK_ENTRY(username)); 00172 text[PASSWORD] = gtk_entry_get_text(GTK_ENTRY(password)); 00173 text[SERVICE_TYPE] = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_type)->entry)); 00174 00175 error_message = check_login_validity(text); 00176 if(error_message) 00177 { 00178 do_error_dialog(error_message, 00179 _("Wrong parameters")); 00180 return; 00181 } 00182 00183 gtk_clist_append(GTK_CLIST(account_list), text); 00184 num_accounts++; 00185 printf("num_accounts %d\n",num_accounts); 00186 gtk_entry_set_text(GTK_ENTRY(username), ""); 00187 gtk_entry_set_text(GTK_ENTRY(password), ""); 00188 } |
|
Definition at line 214 of file editcontacts.c. References account_window. Referenced by eb_new_user().
00215 { 00216 gtk_widget_destroy(account_window); 00217 if(!statuswindow) 00218 gtk_main_quit(); 00219 } |
|
Definition at line 147 of file editcontacts.c. References get_service_id(), get_service_list(), PASSWORD, SERVICE_TYPE, and USER_NAME. Referenced by add_callback().
00148 { 00149 GList * services = get_service_list(); 00150 GList * l = services; 00151 /* 00152 * okay, this should really be text[SERVICE_TYPE], text[USER_NAME] ... 00153 * change it if you think this is confusing 00154 */ 00155 if (USER_NAME[text] == NULL || strlen(USER_NAME[text]) == 0) 00156 return NULL; 00157 00158 while (l) { 00159 if(!strcmp(l->data, SERVICE_TYPE[text])) 00160 return eb_services[get_service_id(l->data)].sc->check_login(USER_NAME[text], PASSWORD[text]); 00161 l = l->next; 00162 } 00163 00164 return NULL; 00165 } |
|
Definition at line 69 of file editcontacts.c. References is_open, num_accounts, and selected_row. Referenced by eb_new_user().
00070 { 00071 is_open = FALSE; 00072 num_accounts = 0; 00073 selected_row = -1; 00074 } |
|
Definition at line 327 of file editcontacts.c. References _, account_list, account_window, add_callback(), cancel_callback(), del_button, destroy(), eb_icon(), get_service_list(), is_open, mod_button, modify_callback(), ok_callback(), password, PASSWORD, read_contacts(), remove_callback(), selection_made(), selection_unmade(), service_type, and username. Referenced by eb_edit_accounts(), and start_login().
00328 { 00329 char * text[] ={_("Screen Name"), 00330 _("Password"), 00331 _("Service Type")}; 00332 GtkWidget * box; 00333 GtkWidget * window_box; 00334 GtkWidget * hbox; 00335 GtkWidget * button_box; 00336 GtkWidget * label; 00337 GtkWidget * iconwid; 00338 GtkWidget * toolbar; 00339 GtkWidget * toolitem; 00340 GtkWidget * separator; 00341 GList * list; 00342 GdkPixmap *icon; 00343 GdkBitmap *mask; 00344 00345 if(is_open) 00346 return; 00347 00348 is_open = 1; 00349 00350 account_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 00351 gtk_window_set_position(GTK_WINDOW(account_window), GTK_WIN_POS_MOUSE); 00352 gtk_widget_realize(account_window); 00353 account_list = gtk_clist_new_with_titles(3,text); 00354 gtk_clist_set_column_visibility(GTK_CLIST(account_list), PASSWORD, FALSE); 00355 gtk_container_set_border_width(GTK_CONTAINER(account_window), 5); 00356 gtk_signal_connect(GTK_OBJECT(account_list), "select_row", 00357 GTK_SIGNAL_FUNC(selection_made), 00358 NULL); 00359 gtk_signal_connect(GTK_OBJECT(account_list), "unselect_row", 00360 GTK_SIGNAL_FUNC(selection_unmade), 00361 NULL); 00362 00363 box = gtk_vbox_new(FALSE, 0); 00364 window_box = gtk_vbox_new(FALSE,5); 00365 hbox = gtk_hbox_new(FALSE, 5); 00366 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); 00367 00368 /*Screen Name Section*/ 00369 00370 label = gtk_label_new(_("Screen Name:")); 00371 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 00372 gtk_widget_show(label); 00373 username = gtk_entry_new(); 00374 gtk_box_pack_start(GTK_BOX(box), username, FALSE, FALSE, 2); 00375 gtk_widget_show(username); 00376 00377 /*Password Section*/ 00378 00379 label = gtk_label_new(_("Password:")); 00380 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5); 00381 gtk_widget_show(label); 00382 password = gtk_entry_new(); 00383 gtk_entry_set_visibility(GTK_ENTRY(password), FALSE); 00384 gtk_box_pack_start(GTK_BOX(box), password, FALSE, FALSE, 2); 00385 gtk_widget_show(password); 00386 00387 /*Service Type Section*/ 00388 00389 label = gtk_label_new(_("Service Type:")); 00390 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5); 00391 gtk_widget_show(label); 00392 service_type = gtk_combo_new(); 00393 list = get_service_list(); 00394 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(service_type)->entry), FALSE); 00395 gtk_combo_set_popdown_strings(GTK_COMBO(service_type), list); 00396 g_list_free(list); 00397 gtk_widget_show(service_type); 00398 gtk_box_pack_start(GTK_BOX(box), service_type, FALSE, FALSE, 2); 00399 00400 gtk_box_pack_start(GTK_BOX(hbox), box, FALSE, FALSE, 2); 00401 gtk_widget_show(box); 00402 00403 box = gtk_vbox_new(FALSE, 0); 00404 00405 read_contacts(); 00406 00407 gtk_box_pack_start(GTK_BOX(box), account_list, TRUE, TRUE, 0); 00408 gtk_widget_show(account_list); 00409 00410 gtk_box_pack_start(GTK_BOX(hbox), box, TRUE, TRUE, 2); 00411 gtk_widget_show(box); 00412 00413 gtk_box_pack_start(GTK_BOX(window_box), hbox, TRUE, TRUE, 0); 00414 gtk_widget_show(hbox); 00415 00416 separator = gtk_hseparator_new(); 00417 gtk_box_pack_start(GTK_BOX(window_box), separator, TRUE, TRUE, 0); 00418 gtk_widget_show(separator); 00419 00420 /*Initialize Toolbar*/ 00421 00422 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); 00423 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE); 00424 gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0); 00425 gtk_toolbar_set_space_size(GTK_TOOLBAR(toolbar), 5); 00426 00427 /*Add Button*/ 00428 00429 icon = gdk_pixmap_create_from_xpm_d(account_window->window, &mask, NULL, tb_preferences_xpm); 00430 iconwid = gtk_pixmap_new(icon, mask); 00431 gtk_widget_show(iconwid); 00432 toolitem = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 00433 _("Add"), 00434 _("Add Account"), 00435 _("Add"), 00436 iconwid, 00437 GTK_SIGNAL_FUNC(add_callback), 00438 NULL); 00439 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); 00440 00441 /*Delete Button*/ 00442 00443 icon = gdk_pixmap_create_from_xpm_d(account_window->window, &mask, NULL, tb_trash_xpm); 00444 iconwid = gtk_pixmap_new(icon, mask); 00445 gtk_widget_show(iconwid); 00446 del_button = gtk_toolbar_append_item (GTK_TOOLBAR(toolbar), 00447 _("Delete"), 00448 _("Delete Account"), 00449 _("Delete"), 00450 iconwid, 00451 GTK_SIGNAL_FUNC(remove_callback), 00452 NULL); 00453 gtk_widget_set_sensitive(del_button, FALSE); 00454 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); 00455 00456 /* Modify Button */ 00457 00458 icon = gdk_pixmap_create_from_xpm_d(account_window->window, &mask, NULL, tb_edit_xpm); 00459 iconwid = gtk_pixmap_new(icon, mask); 00460 gtk_widget_show(iconwid); 00461 mod_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 00462 _("Modify"), 00463 _("Modify Account"), 00464 _("Modify"), 00465 iconwid, 00466 GTK_SIGNAL_FUNC(modify_callback), 00467 NULL); 00468 gtk_widget_set_sensitive(mod_button, FALSE); 00469 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); 00470 00471 separator = gtk_vseparator_new(); 00472 gtk_widget_set_usize(GTK_WIDGET(separator), 0, 20); 00473 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), separator, NULL, NULL); 00474 gtk_widget_show(separator); 00475 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); 00476 00477 /*Okay Button*/ 00478 00479 icon = gdk_pixmap_create_from_xpm_d(account_window->window, &mask, NULL, ok_xpm); 00480 iconwid = gtk_pixmap_new(icon, mask); 00481 gtk_widget_show(iconwid); 00482 toolitem = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 00483 _("Ok"), 00484 _("Ok"), 00485 _("Ok"), 00486 iconwid, 00487 GTK_SIGNAL_FUNC(ok_callback), 00488 NULL); 00489 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); 00490 00491 /*Cancel Button*/ 00492 00493 icon = gdk_pixmap_create_from_xpm_d(account_window->window, &mask, NULL, cancel_xpm); 00494 iconwid = gtk_pixmap_new(icon, mask); 00495 gtk_widget_show(iconwid); 00496 toolitem = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 00497 _("Cancel"), 00498 _("Cancel"), 00499 _("Cancel"), 00500 iconwid, 00501 GTK_SIGNAL_FUNC(cancel_callback), 00502 NULL); 00503 00504 /*Buttons End*/ 00505 00506 button_box = gtk_hbox_new(FALSE, 0); 00507 00508 gtk_box_pack_end(GTK_BOX(button_box), toolbar, FALSE, FALSE, 0); 00509 gtk_widget_show(toolbar); 00510 00511 gtk_box_pack_start(GTK_BOX(window_box), button_box, FALSE, FALSE, 0); 00512 gtk_widget_show(button_box); 00513 00514 gtk_widget_show(window_box); 00515 00516 gtk_container_add(GTK_CONTAINER(account_window), window_box); 00517 00518 gtk_window_set_title(GTK_WINDOW(account_window), _("Yattm Account Editor")); 00519 eb_icon(account_window->window); 00520 00521 gtk_signal_connect(GTK_OBJECT(account_window), "destroy", 00522 GTK_SIGNAL_FUNC(destroy), NULL ); 00523 gtk_widget_show(account_window); 00524 } |
|
Definition at line 190 of file editcontacts.c. References account_list, password, PASSWORD, selected_row, service_type, SERVICE_TYPE, USER_NAME, and username. Referenced by eb_new_user().
00191 { 00192 char * text[3]; 00193 00194 /* update selected row in list */ 00195 00196 text[USER_NAME] = gtk_entry_get_text(GTK_ENTRY(username)); 00197 gtk_clist_set_text(GTK_CLIST(account_list), 00198 selected_row, USER_NAME, text[USER_NAME]); 00199 00200 text[PASSWORD] = gtk_entry_get_text(GTK_ENTRY(password)); 00201 gtk_clist_set_text(GTK_CLIST(account_list), 00202 selected_row, PASSWORD, text[PASSWORD]); 00203 00204 text[SERVICE_TYPE] = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_type)->entry)); 00205 gtk_clist_set_text(GTK_CLIST(account_list), 00206 selected_row, SERVICE_TYPE, text[SERVICE_TYPE]); 00207 00208 /* reset the entry fields */ 00209 00210 gtk_entry_set_text(GTK_ENTRY(username), ""); 00211 gtk_entry_set_text(GTK_ENTRY(password), ""); 00212 } |
|
Definition at line 221 of file editcontacts.c. References _, account_list, account_window, add_callback(), local_account::connected, DBG_CORE, do_error_dialog(), eb_debug, eb_status_window(), find_local_account_by_handle(), get_service_id(), load_accounts(), load_contacts(), num_accounts, PASSWORD, rebuild_set_status_menu(), RUN_SERVICE, save_account_info(), local_account::service_id, SERVICE_TYPE, USER_NAME, username, value_pair_add(), value_pair_print_values(), and value_pair_remove(). Referenced by eb_new_user().
00222 { 00223 FILE * fp; 00224 char buff[1024]; 00225 char * service, *user, *pass; 00226 int i; 00227 int id; 00228 gboolean had_accounts=(accounts != NULL); 00229 GList *pairs=NULL; 00230 GList *existing_accounts = NULL, *new_accounts = NULL, *acc_walk = NULL; 00231 eb_local_account *ela=NULL; 00232 00233 if (gtk_entry_get_text(GTK_ENTRY(username)) != NULL 00234 && strlen(gtk_entry_get_text(GTK_ENTRY(username))) > 0) { 00235 add_callback(widget,data); 00236 } 00237 00238 g_snprintf(buff, 1024, "%saccounts",config_dir); 00239 00240 fp=fdopen(creat(buff, 0700), "w"); 00241 00242 if (num_accounts == 0) { 00243 do_error_dialog(_("You didn't define any account."), _("Error")); 00244 return; 00245 } 00246 00247 for(i = 0; i < num_accounts; i++) 00248 { 00249 gtk_clist_get_text(GTK_CLIST(account_list), i, SERVICE_TYPE, &service); 00250 gtk_clist_get_text(GTK_CLIST(account_list), i, USER_NAME, &user); 00251 gtk_clist_get_text(GTK_CLIST(account_list), i, PASSWORD, &pass); 00252 id=get_service_id(service); 00253 if(accounts && (ela = find_local_account_by_handle(user, id))) { 00254 /* If the account exits, just update the password 00255 */ 00256 GList * config = NULL; 00257 config = eb_services[id].sc->write_local_config(ela); 00258 config = value_pair_remove(config, "PASSWORD"); 00259 config = value_pair_add(config, "PASSWORD", pass); 00260 fprintf(fp, "<ACCOUNT %s>\n", service); 00261 value_pair_print_values(config, fp, 1); 00262 fprintf(fp, "</ACCOUNT>\n"); 00263 existing_accounts = g_list_append(existing_accounts, ela); 00264 } 00265 else { 00266 GList * config = NULL; 00267 eb_debug(DBG_CORE, "Adding new account %s service %s\n", user, service); 00268 pairs = value_pair_add(NULL, "SCREEN_NAME", user); 00269 pairs = value_pair_add(pairs, "PASSWORD", pass); 00270 save_account_info(service, pairs); 00271 ela = eb_services[id].sc->read_local_account_config(pairs); 00272 //prevent segfault 00273 if(ela != NULL) { 00274 // Is this an account for which a module is not loaded? 00275 if(ela->service_id==-1) 00276 ela->service_id=id; 00277 new_accounts = g_list_append(new_accounts, ela); 00278 config = eb_services[id].sc->write_local_config(ela); 00279 fprintf(fp, "<ACCOUNT %s>\n", service); 00280 value_pair_print_values(config, fp, 1); 00281 fprintf(fp, "</ACCOUNT>\n"); 00282 } else { 00283 do_error_dialog(_("Can't add account : unknown service"), _("Error")); 00284 } 00285 } 00286 } 00287 00288 00289 fclose(fp); 00290 00291 acc_walk = accounts; 00292 if (acc_walk) { 00293 while(acc_walk != NULL && acc_walk->data != NULL) { 00294 if (g_list_find(existing_accounts, acc_walk->data) == NULL) { 00295 eb_local_account *removed = (eb_local_account *)(acc_walk->data); 00296 /* removed account */ 00297 if(removed->connected 00298 && RUN_SERVICE(removed)->logout != NULL) 00299 RUN_SERVICE(removed)->logout(removed); 00300 accounts = g_list_remove(accounts,acc_walk->data); 00301 } 00302 acc_walk = acc_walk->next; 00303 } 00304 } 00305 00306 acc_walk = new_accounts; 00307 if (acc_walk) { 00308 while(acc_walk != NULL) { 00309 accounts = g_list_append(accounts,acc_walk->data); 00310 acc_walk = acc_walk->next; 00311 } 00312 } 00313 00314 gtk_widget_destroy(account_window); 00315 00316 /* if this was an initial launch, start up EB */ 00317 if(!had_accounts) 00318 { 00319 load_accounts(); 00320 load_contacts(); 00321 eb_status_window(); 00322 } 00323 else 00324 rebuild_set_status_menu(); 00325 } |
|
Definition at line 76 of file editcontacts.c. References account_list, account_row, num_accounts, PASSWORD, RUN_SERVICE, local_account::service_id, SERVICE_TYPE, USER_NAME, value_pair_free(), and value_pair_get_value(). Referenced by eb_new_user().
00077 { 00078 account_row text; 00079 GList * node; 00080 00081 for(node = accounts; node; node = node->next) 00082 { 00083 eb_local_account * ela = node->data; 00084 GList * pairs = RUN_SERVICE(ela)->write_local_config(ela); 00085 00086 text[SERVICE_TYPE] = eb_services[ela->service_id].name; 00087 00088 text[USER_NAME] = value_pair_get_value(pairs, "SCREEN_NAME"); 00089 00090 text[PASSWORD] = value_pair_get_value(pairs, "PASSWORD"); 00091 00092 /* gtk_clist_append copies our strings, so we don't need to */ 00093 gtk_clist_append(GTK_CLIST(account_list), text); 00094 value_pair_free(pairs); 00095 num_accounts++; 00096 } 00097 } |
|
Definition at line 137 of file editcontacts.c. References account_list, num_accounts, and selected_row. Referenced by eb_new_user().
00138 { 00139 if(selected_row != -1) 00140 { 00141 gtk_clist_remove(GTK_CLIST(account_list), selected_row); 00142 num_accounts--; 00143 selected_row = -1; 00144 } 00145 } |
|
Definition at line 109 of file editcontacts.c. References del_button, mod_button, password, PASSWORD, selected_row, service_type, SERVICE_TYPE, USER_NAME, and username. Referenced by eb_new_user().
00114 { 00115 00116 gchar *entry_name; 00117 gchar *entry_pass; 00118 gchar *entry_service; 00119 00120 selected_row = row; 00121 00122 /* Put data in selected row into the entry boxes for revision */ 00123 00124 gtk_clist_get_text(GTK_CLIST(clist), row, USER_NAME, &entry_name); 00125 gtk_clist_get_text(GTK_CLIST(clist), row, PASSWORD, &entry_pass); 00126 gtk_clist_get_text(GTK_CLIST(clist), row, SERVICE_TYPE, &entry_service); 00127 gtk_entry_set_text(GTK_ENTRY(username), entry_name); 00128 gtk_entry_set_text(GTK_ENTRY(password), entry_pass); 00129 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(service_type)->entry), entry_service); 00130 00131 gtk_widget_set_sensitive(mod_button, TRUE); 00132 gtk_widget_set_sensitive(del_button, TRUE); 00133 00134 return; 00135 } |
|
Definition at line 99 of file editcontacts.c. References password, and username. Referenced by eb_new_user().
|
|
Definition at line 58 of file editcontacts.c. Referenced by add_callback(), eb_new_user(), modify_callback(), ok_callback(), read_contacts(), and remove_callback(). |
|
Definition at line 59 of file editcontacts.c. Referenced by cancel_callback(), eb_new_user(), and ok_callback(). |
|
Definition at line 64 of file editcontacts.c. Referenced by eb_new_user(), and selection_made(). |
|
Definition at line 66 of file editcontacts.c. Referenced by destroy(), and eb_new_user(). |
|
Definition at line 63 of file editcontacts.c. Referenced by eb_new_user(), and selection_made(). |
|
Definition at line 67 of file editcontacts.c. Referenced by add_callback(), destroy(), ok_callback(), read_contacts(), and remove_callback(). |
|
Definition at line 61 of file editcontacts.c. Referenced by add_callback(), eb_new_user(), modify_callback(), selection_made(), and selection_unmade(). |
|
Definition at line 65 of file editcontacts.c. Referenced by destroy(), modify_callback(), remove_callback(), and selection_made(). |
|
Definition at line 62 of file editcontacts.c. Referenced by add_callback(), eb_new_user(), modify_callback(), and selection_made(). |
|
Definition at line 60 of file editcontacts.c. Referenced by add_callback(), eb_new_user(), modify_callback(), ok_callback(), selection_made(), and selection_unmade(). |