update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginUserAgent.h
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #ifndef MMSPLUGINUSERAGENT_H
32 #define MMSPLUGINUSERAGENT_H
33
34 #include <pthread.h>
35 #include <vector>
36
37 #include "MsgDebug.h"
38 #include "MsgMutex.h"
39 #include "MsgQueue.h"
40 #include "MmsPluginTypes.h"
41 #include "MmsPluginConnManWrapper.h"
42 #include "MmsPluginHttp.h"
43 #include "MsgThread.h"
44
45 class MmsPluginUaManager: public MsgThread
46 {
47         public:
48                 static MmsPluginUaManager *instance();
49                 virtual void start();
50
51                 void addMmsReqEntity(mmsTranQEntity req);
52                 void getMmsPduData(mmsTranQEntity *qEntity);
53                 bool processReceivedData(int msgId, char *pRcvdBody, int rcvdBodyLen, char *retrievedFilePath);
54
55                 void lock(){ mx.lock(); }
56                 void unlock(){ mx.unlock(); }
57                 void wait(){ cv.wait(mx.pMutex()); }
58                 void signal(){ cv.signal(); }
59
60         private:
61                 MmsPluginUaManager();
62                 ~MmsPluginUaManager();
63
64                 static MmsPluginUaManager *pInstance;
65                 virtual void run();
66
67                 Mutex mx;
68                 CndVar cv;
69
70                 MMS_NET_ERROR_T submitHandler(mmsTranQEntity *qEntity);
71                 MMS_NET_ERROR_T waitingConf(mmsTranQEntity *qEntity);
72
73                 // condition values
74                 bool running;           // flag for thread running
75
76                 MsgThdSafeQ <mmsTranQEntity> mmsTranQ; // transaction q for mms plugin
77 };
78
79 bool MsgOpenCreateAndOverwriteFile(char *szFullPath, char *szBuff, int totalLength);
80
81 #endif // MMSPLUGINUSERAGENT_H