ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/src edit_local_accounts.c,1.10,1.11


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src edit_local_accounts.c,1.10,1.11
Date: Wed, 26 Mar 2003 04:51:03 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv6918/src

Modified Files:
        edit_local_accounts.c 
Log Message:
forbid multiple accounts for a service (for now)



Index: edit_local_accounts.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/edit_local_accounts.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- edit_local_accounts.c       26 Mar 2003 09:34:43 -0000      1.10
+++ edit_local_accounts.c       26 Mar 2003 09:51:01 -0000      1.11
@@ -166,6 +166,8 @@
 {
        char * text[3];
        char * error_message = NULL;
+       int i;
+       
        text[USER_NAME] = gtk_entry_get_text(GTK_ENTRY(username));
        text[PASSWORD] = gtk_entry_get_text(GTK_ENTRY(password));
        text[SERVICE_TYPE] = 
gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_type)->entry));
@@ -180,6 +182,19 @@
                return;
        }
 
+       for (i = 0; i < num_accounts; i++) {
+               char *service;
+               gtk_clist_get_text(GTK_CLIST(account_list), i, SERVICE_TYPE, 
&service); 
+               if (!strcmp(service, text[SERVICE_TYPE])) {
+                       char * buf = g_strdup_printf(_("You already have an 
account for %s service. \n\n"
+                                                       "Multiple accounts per 
service aren't supported yet."), 
+                               text[SERVICE_TYPE]);
+                       do_error_dialog(buf, _("Invalid account"));
+                       g_free(buf);
+                       return;
+               }
+       }
+       
        gtk_clist_append(GTK_CLIST(account_list), text);
        num_accounts++;
        printf("num_accounts %d\n",num_accounts);
@@ -190,18 +205,44 @@
 static void modify_callback(GtkWidget * widget, gpointer data)
 {
        char * text[3];
+       char * error_message = NULL;
+       int i;
+       
+       text[USER_NAME] = gtk_entry_get_text(GTK_ENTRY(username));
+       text[PASSWORD] = gtk_entry_get_text(GTK_ENTRY(password));
+       text[SERVICE_TYPE] = 
gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_type)->entry));
+
+       error_message = check_login_validity(text);
+       if (error_message) {
+               char * buf = g_strdup_printf(_("This account is not a valid %s 
account: \n\n %s"), 
+                               text[SERVICE_TYPE], error_message);
+               g_free(error_message);
+               do_error_dialog(buf, _("Invalid account"));
+               g_free(buf);
+               return;
+       }
+
+       for (i = 0; i < num_accounts; i++) {
+               char *service;
+               gtk_clist_get_text(GTK_CLIST(account_list), i, SERVICE_TYPE, 
&service); 
+               if (i != selected_row && !strcmp(service, text[SERVICE_TYPE])) {
+                       char * buf = g_strdup_printf(_("You already have an 
account for %s service. \n\n"
+                                                       "Multiple accounts per 
service aren't supported yet."), 
+                               text[SERVICE_TYPE]);
+                       do_error_dialog(buf, _("Invalid account"));
+                       g_free(buf);
+                       return;
+               }
+       }
        
        /* update selected row in list */
        
-       text[USER_NAME] = gtk_entry_get_text(GTK_ENTRY(username));
        gtk_clist_set_text(GTK_CLIST(account_list), 
                        selected_row, USER_NAME, text[USER_NAME]);
        
-       text[PASSWORD] = gtk_entry_get_text(GTK_ENTRY(password));
        gtk_clist_set_text(GTK_CLIST(account_list), 
                                                selected_row, PASSWORD, 
text[PASSWORD]);
 
-       text[SERVICE_TYPE] = 
gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_type)->entry));
        gtk_clist_set_text(GTK_CLIST(account_list), 
                                                selected_row, SERVICE_TYPE, 
text[SERVICE_TYPE]);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]