Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Mediacontent / MediaWrapper.cpp
1 /*
2 * Copyright (c) 2011 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
18 #include <string.h>
19 #include <algorithm>
20 #include <pcrecpp.h>
21 #include <dpl/log/log.h>
22 #include <Commons/Exception.h>
23 #include "MediaWrapper.h"
24 #include "Mediacontent.h"
25
26 using namespace WrtPlugins::Api;
27
28
29
30 namespace WrtPlugins {
31 namespace Platform {
32 MediaWrapper::MediaWrapper() :
33     m_platformEvent(NULL),
34     m_abstractEvent(NULL)
35 {
36     LogDebug("entered");
37     m_abstractEvent = CalendarEventPtr(new CalendarEvent());
38     if (!m_abstractEvent) {
39         ThrowMsg(Commons::UnknownException, "abstract object is not created");
40     }
41 }
42
43 MediaWrapper::MediaWrapper(media_info_h media) :
44     m_platformEvent(NULL),
45     m_abstractEvent(event)
46 {
47     LogDebug("entered");
48 }
49
50 MediaWrapper::MediaWrapper()
51 {
52     LogDebug("entered");
53     freePlatformEvent();
54 }
55
56 void EventWrapper::displayAbstractEvent()
57 {
58     m_abstractEvent->display();
59 }
60
61 void EventWrapper::displayPlatformEvent()
62 {
63     LogDebug("event id: " << calendar_svc_struct_get_int(m_platformEvent,
64                                                          CAL_VALUE_INT_INDEX));
65     LogDebug("event start time: " << calendar_svc_struct_get_time(
66                  m_platformEvent, CAL_VALUE_GMT_START_DATE_TIME,
67                  CAL_TZ_FLAG_GMT));
68     LogDebug("event end time: " << calendar_svc_struct_get_time(m_platformEvent,
69                                                                 CAL_VALUE_GMT_END_DATE_TIME,
70                                                                 CAL_TZ_FLAG_GMT));
71     LogDebug("event location: " << calendar_svc_struct_get_str(m_platformEvent,
72                                                                CAL_VALUE_TXT_LOCATION));
73     LogDebug("event summary: " << calendar_svc_struct_get_str(m_platformEvent,
74                                                               CAL_VALUE_TXT_SUMMARY));
75     LogDebug("event description: " << calendar_svc_struct_get_str(
76                  m_platformEvent, CAL_VALUE_TXT_DESCRIPTION));
77
78     LogDebug("event isAllDay: " << calendar_svc_struct_get_int(
79                  m_platformEvent, CAL_VALUE_INT_ALL_DAY_EVENT));
80     LogDebug("event organizer: " << calendar_svc_struct_get_str(m_platformEvent,
81                                                                CAL_VALUE_TXT_ORGANIZER_NAME));
82     LogDebug("event lastModifiedDate: " << calendar_svc_struct_get_time(
83                  m_platformEvent, CAL_VALUE_GMT_LAST_MODIFIED_TIME,
84                  CAL_TZ_FLAG_GMT));
85     LogDebug("event visibility: " << calendar_svc_struct_get_int(
86                  m_platformEvent, CAL_VALUE_INT_SENSITIVITY));    
87     LogDebug("event availability: " << calendar_svc_struct_get_int(
88                  m_platformEvent, CAL_VALUE_INT_BUSY_STATUS));
89
90     GList *categoryList = NULL;
91     if (CAL_SUCCESS != calendar_svc_struct_get_list(m_platformEvent,
92                                      CAL_VALUE_LST_MEETING_CATEGORY,
93                                      &categoryList)) {
94         LogError("cannot read category list");
95         return;
96     }
97     cal_value* category = NULL;
98     for (; categoryList; categoryList = g_list_next(categoryList)) {
99         category = static_cast<cal_value*>(categoryList->data);
100         char* categoryName = calendar_svc_value_get_str(category, "category_name");
101         if (NULL == categoryName) {
102             LogError("cannot read category name");
103             return;
104         }
105         LogDebug("event categories: " << categoryName);
106     }
107
108     LogDebug("event uid: " << calendar_svc_struct_get_str(m_platformEvent,
109                                                                CAL_VALUE_TXT_UID));
110     LogDebug("event recurrenceId: " << calendar_svc_struct_get_time(
111                  m_platformEvent, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_GMT));
112
113     GList *attendees = NULL;
114     if (CAL_SUCCESS != calendar_svc_struct_get_list(m_platformEvent,
115                                      CAL_VALUE_LST_ATTENDEE_LIST,
116                                      &attendees)) {
117         LogError("cannot read attendee list");
118         return;
119     }
120     cal_value* attendee = NULL;
121     for (; attendees; attendees = g_list_next(attendees)) {
122         attendee = static_cast<cal_value*>(attendees->data);
123         char* attendeeName = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
124         if (NULL == attendeeName) {
125             LogError("cannot read attendee name");
126             return;
127         }
128         LogDebug("event attendees: " << attendeeName);
129     }
130
131     LogDebug("event repeat frequency: " << calendar_svc_struct_get_int(
132                  m_platformEvent, CAL_VALUE_INT_REPEAT_TERM));
133 }
134
135 }
136 }