sync with tizen_2.0
[platform/framework/native/appfw.git] / src / app / inc / FApp_NotificationManagerEventParamTraits.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FApp_NotificationManagerEventParamTraits.h
20  * @brief               This is the header file for NotificationManagerEvent param traits.
21  */
22
23 #ifndef _FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_
24 #define _FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_
25
26 #include "FBaseString.h"
27 #include "FBaseColIList.h"
28 #include "FBaseColArrayList.h"
29 #include "FIo_IpcCommonDataTypes.h"
30
31 #include "base/tuple.h"
32 #include "ipc/ipc_param_traits.h"
33
34 #include "FAppNotificationMessage.h"
35
36
37 namespace IPC
38 {
39 template <>
40 struct ParamTraits<Tizen::App::NotificationMessage>
41 {
42         typedef Tizen::App::NotificationMessage param_type;
43
44         static void Write(Message* m, const param_type& p)
45         {
46                 WriteParam(m, p.GetAlertText());
47                 WriteParam(m, p.GetAppMessage());
48                 WriteParam(m, p.GetTitleText());
49                 WriteParam(m, p.GetIconFilePath());
50                 WriteParam(m, p.GetSoundFilePath());
51
52                 m->WriteInt(p.GetBadgeNumber());
53                 m->WriteInt(p.GetBadgeOffset());
54                 m->WriteInt((int)p.GetOngoingActivityType());
55                 m->WriteInt(p.GetOngoingActivityProgressValue());
56         }
57
58         static bool Read(const Message* m, void** iter, param_type* r)
59         {
60                 Tizen::Base::String alertText;
61                 Tizen::Base::String appMessage;
62                 Tizen::Base::String titleText;
63                 Tizen::Base::String iconFilePath;
64                 Tizen::Base::String soundFilePath;
65
66                 int badgeNo = -1;
67                 int badgeOffset = 0;
68                 int progressValue = -1;
69                 int activityType = Tizen::App::ONGOING_ACTIVITY_TYPE_TEXT;
70
71                 if (!ReadParam(m, iter, &alertText))
72                 {
73                         return false;
74                 }
75                 if (!ReadParam(m, iter, &appMessage))
76                 {
77                         return false;
78                 }
79                 if (!ReadParam(m, iter, &titleText))
80                 {
81                         return false;
82                 }
83                 if (!ReadParam(m, iter, &iconFilePath))
84                 {
85                         return false;
86                 }
87                 if (!ReadParam(m, iter, &soundFilePath))
88                 {
89                         return false;
90                 }
91                 m->ReadInt(iter, &badgeNo);
92                 m->ReadInt(iter, &badgeOffset);
93                 m->ReadInt(iter, &progressValue);
94                 m->ReadInt(iter, &activityType);
95
96                 Tizen::App::NotificationMessage notimessage;
97                 notimessage.SetAlertText(alertText);
98                 notimessage.SetAppMessage(appMessage);
99                 notimessage.SetTitleText(titleText);
100                 notimessage.SetIconFilePath(iconFilePath);
101                 notimessage.SetSoundFilePath(soundFilePath);
102
103                 notimessage.SetBadgeNumber(badgeNo);
104                 notimessage.SetBadgeOffset(badgeOffset);
105                 notimessage.SetOngoingActivityProgressValue(progressValue);
106                 notimessage.SetOngoingActivityType((Tizen::App::OngoingActivityType)activityType);
107
108                 *r = notimessage;
109
110                 return true;
111         }
112         static void Log(const param_type& p, std::string* l)
113         {
114         }
115
116 };
117 }
118
119 #endif //_FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_