[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src util.c,1.33,1.34 util.h,1.18,1.19
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src util.c,1.33,1.34 util.h,1.18,1.19 |
Date: |
Wed, 29 Jan 2003 09:55:44 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv6774/src
Modified Files:
util.c util.h
Log Message:
offline group management (sync problems to fix)
Index: util.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/util.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- util.c 29 Jan 2003 13:32:19 -0000 1.33
+++ util.c 29 Jan 2003 14:55:41 -0000 1.34
@@ -868,7 +868,10 @@
eb_debug(DBG_CORE, "dropping group %s in %s\n",
g->name, get_service_name(ela->service_id));
RUN_SERVICE(ela)->del_group(g->name);
+ } else if (RUN_SERVICE(ela)->del_group) {
+ group_mgmt_queue_add(ela, g->name, MGMT_GRP_DEL, NULL);
}
+
}
g_free(g);
}
@@ -890,7 +893,7 @@
name,
get_service_name(ela->service_id));
RUN_SERVICE(ela)->add_group(name);
} else {
- /* TODO: Add to queue */
+ group_mgmt_queue_add(ela, NULL, MGMT_GRP_ADD,
name);
}
}
update_contact_list();
@@ -917,7 +920,7 @@
oldname, new_name,
get_service_name(ela->service_id));
RUN_SERVICE(ela)->rename_group(oldname,
new_name);
} else {
- /* TODO: Add to queue */
+ group_mgmt_queue_add(ela, oldname,
MGMT_GRP_REN, new_name);
}
}
}
@@ -1039,7 +1042,7 @@
if(find_suitable_local_account(NULL, ea->service_id))
RUN_SERVICE(ea)->add_user(ea);
else {
- /* TODO: Add to queue */
+ contact_mgmt_queue_add(ea, MGMT_ADD,
ea->account_contact->group->name);
}
write_contact_list();
}
@@ -1404,11 +1407,38 @@
fclose(fp);
}
+
+void group_mgmt_queue_add(eb_local_account *ela, char *old_group, int action,
char *new_group)
+{
+ FILE *fp;
+ char buff [NAME_MAX];
+ g_snprintf(buff, NAME_MAX, "%s%cgroup_actions_queue",
+ config_dir,
+ G_DIR_SEPARATOR);
+ fp = fopen(buff,"a");
+ if (!fp) {
+ perror(buff);
+ return;
+ }
+
+ fprintf(fp, "%s\t%d\t%s\t%s\n",
+ get_service_name(ela->service_id),
+ action,
+ (old_group!=NULL ? old_group:"NULL"),
+ (new_group!=NULL ? new_group:"NULL"));
+
+ fclose(fp);
+}
+
int contact_mgmt_flush(eb_local_account *ela)
{
FILE *queue, *temp;
char buff[NAME_MAX], queue_name[NAME_MAX], temp_name[NAME_MAX];
char *str = NULL;
+
+ /* flush groups, too */
+ group_mgmt_flush(ela);
+
g_snprintf(queue_name, NAME_MAX, "%s%ccontact_actions_queue",
config_dir,
G_DIR_SEPARATOR);
@@ -1489,6 +1519,62 @@
rename (temp_name, queue_name);
return 0;
}
+
+
+int group_mgmt_flush(eb_local_account *ela)
+{
+ FILE *queue, *temp;
+ char buff[NAME_MAX], queue_name[NAME_MAX], temp_name[NAME_MAX];
+ char *str = NULL;
+ g_snprintf(queue_name, NAME_MAX, "%s%cgroup_actions_queue",
+ config_dir,
+ G_DIR_SEPARATOR);
+
+ queue = fopen(queue_name, "r");
+ if (!queue)
+ return 0;
+ g_snprintf(temp_name, NAME_MAX, "%s%cgroup_actions_queue.new",
+ config_dir,
+ G_DIR_SEPARATOR);
+
+ temp = fopen(temp_name, "w");
+
+ if (!temp) {
+ perror(buff);
+ return 0;
+ }
+
+ while( fgets(buff, sizeof(buff), queue) != NULL )
+ {
+ char buff_backup[NAME_MAX];
+ strcpy(buff_backup, buff);
+ str = strtok( buff, "\t" );
+ if(!strcmp(str,get_service_name(ela->service_id))) {
+ int action = atoi(strtok(NULL,"\t"));
+ char *oldgroup = strtok(NULL,"\t");
+ char *newgroup = strtok(NULL,"\n");
+
+ if (action == MGMT_GRP_ADD &&
RUN_SERVICE(ela)->add_group) {
+ RUN_SERVICE(ela)->add_group(newgroup);
+ }
+ if (action == MGMT_GRP_REN &&
RUN_SERVICE(ela)->rename_group) {
+
RUN_SERVICE(ela)->rename_group(oldgroup,newgroup);
+ }
+ if (action == MGMT_GRP_DEL &&
RUN_SERVICE(ela)->del_group) {
+ RUN_SERVICE(ela)->del_group(oldgroup);
+ }
+ } else {
+ /* not for me */
+ fprintf(temp, "%s", buff_backup);
+ }
+ }
+
+ fclose (temp);
+ fclose (queue);
+ rename (temp_name, queue_name);
+ return 0;
+}
+
void rename_nick_log(char *oldgroup, char *oldnick, char *newgroup, char
*newnick)
{
Index: util.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/util.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- util.h 29 Jan 2003 13:32:19 -0000 1.18
+++ util.h 29 Jan 2003 14:55:41 -0000 1.19
@@ -74,7 +74,10 @@
MGMT_ADD,
MGMT_DEL,
MGMT_MOV,
- MGMT_REN
+ MGMT_REN,
+ MGMT_GRP_ADD,
+ MGMT_GRP_DEL,
+ MGMT_GRP_REN
};
#ifdef __cplusplus
@@ -130,6 +133,8 @@
LList * get_groups();
void contact_mgmt_queue_add(eb_account *ea, int action, char *group);
int contact_mgmt_flush(eb_local_account *ela);
+void group_mgmt_queue_add(eb_local_account *ela, char *old_group, int action,
char *new_group);
+int group_mgmt_flush(eb_local_account *ela);
void rename_nick_log(char *oldgroup, char *oldnick, char *newgroup, char
*newnick);
GList * llist_to_glist(LList * l, int free_old);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src util.c,1.33,1.34 util.h,1.18,1.19,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.243,1.244 configure.in,1.239,1.240
- Next by Date:
[Ayttm-commits] CVS: ayttm/modules/msn2 msn.C,1.51,1.52
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.243,1.244 configure.in,1.239,1.240
- Next by thread:
[Ayttm-commits] CVS: ayttm/modules/msn2 msn.C,1.51,1.52
- Index(es):