Sync with tizen 2.4
[platform/core/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginUserAgent.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #ifndef MMS_PLUGIN_USERAGENT_H
18 #define MMS_PLUGIN_USERAGENT_H
19
20 #include "MsgThread.h"
21 #include "MsgMutex.h"
22 #include "MsgQueue.h"
23 #include "MmsPluginTypes.h"
24
25 class MmsPluginUaManager: public MsgThread
26 {
27         public:
28                 static MmsPluginUaManager *instance();
29                 virtual void start();
30
31                 void addMmsReqEntity(mmsTranQEntity req);
32                 void getMmsPduData(mmsTranQEntity *qEntity);
33                 bool processReceivedData(int msgId, char *pRcvdBody, int rcvdBodyLen, char *retrievedFilePath);
34
35                 void lock(){ mx.lock(); }
36                 void unlock(){ mx.unlock(); }
37                 void wait(){ cv.wait(mx.pMutex()); }
38                 void signal(){ cv.signal(); }
39
40         private:
41                 MmsPluginUaManager();
42                 ~MmsPluginUaManager();
43
44                 static MmsPluginUaManager *pInstance;
45                 virtual void run();
46
47                 Mutex mx;
48                 CndVar cv;
49
50                 MMS_NET_ERROR_T submitHandler(mmsTranQEntity *qEntity);
51                 MMS_NET_ERROR_T waitingConf(mmsTranQEntity *qEntity);
52
53                 // condition values
54                 bool running;           // flag for thread running
55
56                 MsgSimpleQ<mmsTranQEntity> mmsTranQ; // transaction q for mms plugin
57 };
58
59 #endif //MMS_PLUGIN_USERAGENT_H