Skip to content

Commit

Permalink
mms_task_notification_make_id -> mms_task_make_id
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Feb 20, 2014
1 parent e533e43 commit e90844b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
17 changes: 17 additions & 0 deletions mms-lib/src/mms_task.c
Expand Up @@ -298,6 +298,23 @@ mms_task_queue_and_unref(
return ok;
}

/**
* Generates dummy task id if necessary.
*/
const char*
mms_task_make_id(
MMSTask* task)
{
if (!task->id) {
char* tmpl = g_strconcat(task->config->root_dir,
"/" MMS_MESSAGE_DIR "/XXXXXX" , NULL);
char* dir = g_mkdtemp_full(tmpl, MMS_DIR_PERM);
if (dir) task->id = g_path_get_basename(dir);
g_free(tmpl);
}
return task->id;
}

/*
* Local Variables:
* mode: C
Expand Down
4 changes: 4 additions & 0 deletions mms-lib/src/mms_task.h
Expand Up @@ -144,6 +144,10 @@ mms_task_queue_and_unref(
MMSTaskDelegate* delegate,
MMSTask* task);

const char*
mms_task_make_id(
MMSTask* task);

/* Create particular types of tasks */
MMSTask*
mms_task_notification_new(
Expand Down
21 changes: 2 additions & 19 deletions mms-lib/src/mms_task_notification.c
Expand Up @@ -37,23 +37,6 @@ G_DEFINE_TYPE(MMSTaskNotification, mms_task_notification, MMS_TYPE_TASK);
#define MMS_TASK_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
MMS_TYPE_TASK_NOTIFICATION, MMSTaskNotification))

/**
* Generates dummy task id if necessary.
*/
static
void
mms_task_notification_make_id(
MMSTask* task)
{
if (!task->id) {
char* tmpl = g_strconcat(task->config->root_dir,
"/" MMS_MESSAGE_DIR "/XXXXXX" , NULL);
char* dir = g_mkdtemp_full(tmpl, MMS_DIR_PERM);
if (dir) task->id = g_path_get_basename(dir);
g_free(tmpl);
}
}

/**
* Writes the datagram to a file in the message directory.
*/
Expand All @@ -65,7 +48,7 @@ mms_task_notification_write_file(
{
char* dir;
gboolean ok;
mms_task_notification_make_id(&ind->task);
mms_task_make_id(&ind->task);
dir = mms_task_dir(&ind->task);
ok = mms_write_bytes(dir, file, ind->push, NULL);
g_free(dir);
Expand Down Expand Up @@ -126,7 +109,7 @@ mms_task_notification_ind(
g_free(id);
}
} else if (!mms_task_retry(task)) {
mms_task_notification_make_id(task);
mms_task_make_id(task);
mms_task_queue_and_unref(task->delegate,
mms_task_notifyresp_new(task->config, task->handler, task->id,
task->imsi, ind->pdu->transaction_id,
Expand Down

0 comments on commit e90844b

Please sign in to comment.