46
46
gchar *cFile = g_strdup_printf ("%s/%s", cDirPath, "tasks.conf");
47
47
GKeyFile *pKeyFile = cairo_dock_open_key_file (cFile);
50
50
if (pKeyFile == NULL) // encore aucune taches.
54
57
gchar **pGroupList = g_key_file_get_groups (pKeyFile, &length);
55
58
if (pGroupList == NULL)
57
60
g_key_file_free (pKeyFile);
61
65
CDClockTask *pTask;
63
67
GList *pTaskList = NULL;
68
guint iMonth = myData.currentTime.tm_mon;
69
guint iYear = myData.currentTime.tm_year + 1900;
71
gboolean bUpdateFile = FALSE;
65
73
for (i = 0; i < length; i ++)
67
75
cTaskID = pGroupList[i];
77
// discard tasks older than 1 year (clean the file too).
78
y = g_key_file_get_integer (pKeyFile, cTaskID, "year", NULL);
79
m = g_key_file_get_integer (pKeyFile, cTaskID, "month", NULL);
80
freq = g_key_file_get_integer (pKeyFile, cTaskID, "freq", NULL);
81
if (freq == CD_TASK_DONT_REPEAT && (iYear < y -1 || iYear == y - 1 && iMonth < m))
83
g_key_file_remove_group (pKeyFile, cTaskID, NULL);
68
90
pTask = g_new0 (CDClockTask, 1);
69
//g_print ("+ task %s\n", cTaskID);
71
91
pTask->cID = cTaskID;
72
92
pTask->iDay = g_key_file_get_integer (pKeyFile, cTaskID, "day", NULL);
73
pTask->iMonth = g_key_file_get_integer (pKeyFile, cTaskID, "month", NULL);
74
pTask->iYear = g_key_file_get_integer (pKeyFile, cTaskID, "year", NULL);
75
95
pTask->cTitle = g_key_file_get_string (pKeyFile, cTaskID, "title", NULL);
76
96
pTask->cText = g_key_file_get_string (pKeyFile, cTaskID, "text", NULL);
77
97
pTask->cTags = g_key_file_get_string (pKeyFile, cTaskID, "tags", NULL);
78
98
pTask->iHour = g_key_file_get_integer (pKeyFile, cTaskID, "hour", NULL);
79
99
pTask->iMinute = g_key_file_get_integer (pKeyFile, cTaskID, "minute", NULL);
80
pTask->iFrequency = g_key_file_get_integer (pKeyFile, cTaskID, "freq", NULL);
100
pTask->iFrequency = freq;
101
pTask->bAcknowledged = g_key_file_get_boolean (pKeyFile, cTaskID, "ack", NULL);
82
103
pTaskList = g_list_prepend (pTaskList, pTask);
83
104
s_iCounter = MAX (s_iCounter, atoi (cTaskID));
86
107
g_free (pGroupList); // les elements sont les IDs et sont integres dans les taches.
110
cairo_dock_write_keys_to_file (pKeyFile, cFile);
87
112
g_key_file_free (pKeyFile);
107
133
g_key_file_set_integer (pKeyFile, pTask->cID, "hour", pTask->iHour);
108
134
g_key_file_set_integer (pKeyFile, pTask->cID, "minute", pTask->iMinute);
109
135
g_key_file_set_integer (pKeyFile, pTask->cID, "freq", pTask->iFrequency);
136
g_key_file_set_boolean (pKeyFile, pTask->cID, "ack", pTask->bAcknowledged);
111
138
cairo_dock_write_keys_to_file (pKeyFile, cFile);
143
170
g_key_file_set_integer (pKeyFile, pTask->cID, "hour", pTask->iHour);
144
171
g_key_file_set_integer (pKeyFile, pTask->cID, "minute", pTask->iMinute);
145
172
g_key_file_set_integer (pKeyFile, pTask->cID, "freq", pTask->iFrequency);
173
g_key_file_set_boolean (pKeyFile, pTask->cID, "ack", pTask->bAcknowledged);
147
175
cairo_dock_write_keys_to_file (pKeyFile, cFile);