/
mms_task_notifyresp.c
72 lines (68 loc) · 1.88 KB
/
mms_task_notifyresp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (C) 2013-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "mms_task.h"
#include "mms_task_http.h"
#include "mms_file_util.h"
#include "mms_codec.h"
static
const char*
mms_task_notifyresp_encode(
const MMSConfig* config,
const char* id,
const char* transaction_id,
MMSNotifyStatus status)
{
const char* result = NULL;
const char* file = MMS_NOTIFYRESP_IND_FILE;
char* dir = mms_message_dir(config, id);
int fd = mms_create_file(dir, file, NULL, NULL);
if (fd >= 0) {
MMSPdu* pdu = g_new0(MMSPdu, 1);
pdu->type = MMS_MESSAGE_TYPE_NOTIFYRESP_IND;
pdu->version = MMS_VERSION;
pdu->transaction_id = g_strdup(transaction_id);
pdu->nri.notify_status = status;
if (mms_message_encode(pdu, fd)) result = file;
mms_message_free(pdu);
close(fd);
}
g_free(dir);
return result;
}
/**
* Create MMS retrieve confirmation task
*/
MMSTask*
mms_task_notifyresp_new(
MMSTask* parent,
MMSTransferList* transfers,
const char* tx_id,
MMSNotifyStatus ns)
{
const char* file = mms_task_notifyresp_encode(task_config(parent),
parent->id, tx_id, ns);
if (file) {
return mms_task_http_alloc_with_parent(0, parent, transfers,
MMS_TRANSFER_TYPE_NOTIFY_RESP, NULL, NULL, file);
}
return NULL;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/