modify method names to give consitancy
[platform/framework/native/appwidget-service.git] / src / FShell_AppWidgetContext.cpp
1 //
2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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  * @file        FShell_AppWidgetContext.cpp
19  * @brief       This is the implementation for the _AppWidgetContext class.
20  */
21
22 #include <provider.h>
23 #include <unique_ptr.h>
24
25 #include <FBaseSysLog.h>
26 #include <FBaseInteger.h>
27 #include <FBaseDouble.h>
28 #include <FBaseColHashMap.h>
29 #include <FBaseColAllElementsDeleter.h>
30 #include <FSysSystemTime.h>
31 #include <FAppAppManager.h>
32
33 #include <FBase_StringConverter.h>
34 #include "FShell_AppWidgetManagerImpl.h"
35 #include "FShell_AppWidgetManagerService.h"
36 #include "FShell_AppWidgetPopupContext.h"
37 #include "FShell_AppWidgetContext.h"
38 #include "FShell_AppWidgetContextHelper.h"
39 #include "FShell_AppWidgetRemoteBuffer.h"
40
41 namespace Tizen { namespace Shell  { namespace App
42 {
43
44 using namespace std;
45 using namespace Tizen::App;
46 using namespace Tizen::Base;
47 using namespace Tizen::Base::Collection;
48 using namespace Tizen::System;
49
50 const wchar_t ARG_KEY_INSTANCE_ID[] = L"_InstanceId";
51 const wchar_t ARG_KEY_PROVIDER_NAME[] = L"_ProviderName";
52 const wchar_t ARG_KEY_USER_INFO[] = L"_UserInfo";
53 const wchar_t ARG_KEY_X[] = L"_X";
54 const wchar_t ARG_KEY_Y[] = L"_Y";
55 const wchar_t ARG_KEY_WIDTH[] = L"_Width";
56 const wchar_t ARG_KEY_HEIGHT[] = L"_Height";
57 const wchar_t ARG_KEY_POPUP_WIDTH[] = L"_PopupWidth";
58 const wchar_t ARG_KEY_POPUP_HEIGHT[] = L"_PopupHeight";
59 const wchar_t ARG_KEY_ARGUMENT[] = L"_Argument";
60 const wchar_t ARG_KEY_EVENT_TYPE[] = L"_EventType";
61 const wchar_t ARG_KEY_TIME_STAMP[] = L"_TimeStamp";
62
63 const wchar_t APPWIDGET_ON_ADD[] = L"http://tizen.org/appcontrol/appwidget/add";
64 const wchar_t APPWIDGET_ON_REMOVE[] = L"http://tizen.org/appcontrol/appwidget/remove";
65 const wchar_t APPWIDGET_ON_UPDATE[] = L"http://tizen.org/appcontrol/appwidget/update";
66 const wchar_t APPWIDGET_ON_RESIZE[] = L"http://tizen.org/appcontrol/appwidget/resize";
67 const wchar_t APPWIDGET_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidget/touch";
68
69 const int UPDATE_PERIOD_MSEC_MIN = 1800000;     // 30min
70
71 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72 // _AppContext class
73 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
74 _AppContext::_AppContext(void)
75         :__isWaitingResult(false)
76         ,__ipcClientId(0)
77         ,__connectionState(CONNECTION_STATE_NONE)
78 {
79
80 }
81
82 _AppContext::~_AppContext(void)
83 {
84
85 }
86
87 _ConnectionState
88 _AppContext::GetConnectionState(void) const
89 {
90         return __connectionState;
91 }
92
93 void
94 _AppContext::SetConnectionState(_ConnectionState state)
95 {
96         __connectionState = state;
97 }
98
99 int
100 _AppContext::GetClientId(void) const
101 {
102         return __ipcClientId;
103 }
104
105 void
106 _AppContext::SetClientId(int clientId)
107 {
108         __ipcClientId = clientId;
109 }
110
111 void
112 _AppContext::SetWaitingStatus(bool status)
113 {
114         __isWaitingResult = status;
115 }
116
117 bool
118 _AppContext::GetWaitingStatus(void) const
119 {
120         return __isWaitingResult;
121 }
122
123 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
124 // _AppWidgetContext class
125 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
126 _AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int period, int priority)
127         :__isTouchAvailable(false)
128         ,__hasPendingRequest(false)
129         ,__isForeground(true)
130         ,__width(width)
131         ,__height(height)
132         ,__priority(priority)
133         ,__ipcClientId(-1)
134         ,__updateMillis(period)
135         ,__lastUpdatedTime(0)
136         ,__userInfo(userInfo)
137         ,__providerId(providerId)
138         ,__instanceId(instanceId)
139         ,__pAppContext(pAppContext)
140         ,__pAppWidgetPopup(null)
141         ,__pAppWidgetRemoteBuffer(null)
142         ,__pPendingTouchEventList(null)
143         ,__pPendingEventList(null)
144 {
145         _AppWidgetManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
146         SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
147
148         // for updating period
149         if (__updateMillis > 0)
150         {
151                 __updateMillis = (__updateMillis > UPDATE_PERIOD_MSEC_MIN) ? __updateMillis : UPDATE_PERIOD_MSEC_MIN;
152                 SysLog(NID_SHELL, "period(%d)", __updateMillis);
153
154                 SystemTime::GetTicks(this->__lastUpdatedTime);
155
156                 result r = __updateTimer.Construct(*this);
157                 SysTryReturnVoidResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "");
158
159                 r = __updateTimer.StartAsRepeatable(__updateMillis);
160                 SysTryReturnVoidResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "");
161         }
162
163         __pPendingTouchEventList = new (nothrow) ArrayListT<PendingTouchEvent*>();
164         SysTryReturnVoidResult(NID_SHELL, __pPendingTouchEventList, E_OUT_OF_MEMORY, "");
165         __pPendingTouchEventList->Construct();
166
167         __pPendingEventList = new (nothrow) ArrayListT<PendingEvent*>();
168         SysTryReturnVoidResult(NID_SHELL, __pPendingEventList, E_OUT_OF_MEMORY, "");
169         __pPendingEventList->Construct();
170
171         __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(providerId, instanceId, TYPE_LB, this);
172         SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, "");
173 }
174
175 _AppWidgetContext::~_AppWidgetContext(void)
176 {
177         SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight(), GetPriority());
178
179         __updateTimer.Cancel();
180
181         if (__pAppWidgetPopup)
182         {
183                 SysLog(NID_SHELL, "Destroying dangling AppWidgetPopup instance..");
184                 delete __pAppWidgetPopup;
185         }
186
187         if (__pPendingTouchEventList)
188         {
189                 for (int i = 0; i < __pPendingTouchEventList->GetCount(); i++)
190                 {
191                         PendingTouchEvent* pTouchEvent = null;
192                         __pPendingTouchEventList->GetAt(i, pTouchEvent);
193                         delete pTouchEvent;
194                 }
195                 __pPendingTouchEventList->RemoveAll();
196                 delete __pPendingTouchEventList;
197         }
198
199         if (__pPendingEventList)
200         {
201                 for (int i = 0; i < __pPendingEventList->GetCount(); i++)
202                 {
203                         PendingEvent* pEvent = null;
204                         __pPendingEventList->GetAt(i, pEvent);
205                         delete pEvent;
206                 }
207                 __pPendingEventList->RemoveAll();
208                 delete __pPendingEventList;
209         }
210
211         if (__pAppWidgetRemoteBuffer)
212         {
213                 delete __pAppWidgetRemoteBuffer;
214         }
215 }
216
217 _AppContext*
218 _AppWidgetContext::GetAppContext(void) const
219 {
220         return __pAppContext;
221 }
222
223 _AppWidgetPopupContext*
224 _AppWidgetContext::GetAppWidgetPopup(void) const
225 {
226         return __pAppWidgetPopup;
227 }
228
229 void
230 _AppWidgetContext::OnAdded(void)
231 {
232         SendAddRequest(GetWidth(), GetHeight());
233 }
234
235 result
236 _AppWidgetContext::OnRemoved(void)
237 {
238         return SendRemoveRequest();
239 }
240
241 void
242 _AppWidgetContext::OnUpdate(const String& argument)
243 {
244         SysLog(NID_SHELL, "argument(%ls)", argument.GetPointer());
245
246         ClearLastResult();
247
248         AppWidgetManagerService* pMgrService = AppWidgetManagerService::GetInstance();
249         SysTryReturnVoidResult(NID_SHELL, pMgrService, E_SYSTEM, "[E_SYSTEM] Failed to get an instance of AppWidgetManagerService.");
250
251         // Queueing the pointer of background context.
252         if (!this->IsForeground())
253         {
254                 // Saving the data
255                 if (!argument.IsEmpty())
256                 {
257                         __pendingArgument = argument;
258                 }
259
260                 __hasPendingRequest = true;
261                 SysLog(NID_SHELL, "Update is requested but the %ls is background.", (this->GetAppId()).GetPointer());
262         }
263         else
264         {
265                 result r = this->SendUpdateRequest(GetWidth(), GetHeight(), argument);
266                 SysTryLog(NID_SHELL, !IsFailed(r), "Failed to execute SendUpdateRequest.");
267
268                 SystemTime::GetTicks(this->__lastUpdatedTime);
269                 SysLog(NID_SHELL, "The last updated time is %lld.", this->__lastUpdatedTime);
270
271                 __hasPendingRequest = false;
272                 __pendingArgument.Clear();
273         }
274 }
275
276 void
277 _AppWidgetContext::OnResize(int width, int height)
278 {
279         SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight(), GetPriority());
280
281         SetWidth(width);
282         SetHeight(height);
283
284         SendResizeRequest(width, height);
285 }
286
287 result
288 _AppWidgetContext::RequestUpdate(const String& argument)
289 {
290         AppWidgetManagerService* pMgrService = AppWidgetManagerService::GetInstance();
291         SysTryReturnResult(NID_SHELL, pMgrService, E_SYSTEM, "[E_SYSTEM] Failed to get an instance of AppWidgetManagerService.");
292
293         result r = pMgrService->RequestUpdate(this, argument);
294         SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to request update.");
295
296         return r;
297 }
298
299 void
300 _AppWidgetContext::OnForeground(void)
301 {
302         if (IsForeground())
303         {
304                 SysLog(NID_SHELL, "%ls is already foreground.", (this->GetAppId()).GetPointer());
305                 return;
306         }
307
308         this->SetForeground(true);
309
310         if (__hasPendingRequest == true)
311         {
312                 RequestUpdate(__pendingArgument);
313         }
314         else
315         {
316                 if (this->GetPeriod() > 0)
317                 {
318                         long long currentTicks = 0;
319                         SystemTime::GetTicks(currentTicks);
320
321                         SysLog(NID_SHELL, "current[%lld] - updatedTime[%lld] = [%lld], period[%d]",
322                                         currentTicks, this->GetLastUpdatedTime(), currentTicks - this->GetLastUpdatedTime(), this->GetPeriod());
323
324                         bool isPeriodExpired = (currentTicks - this->GetLastUpdatedTime()) >= (this->GetPeriod());
325                         if (isPeriodExpired)
326                         {
327                                 SysLog(NID_SHELL, "The period is expired.");
328                                 RequestUpdate(L"");
329                         }
330                 }
331         }
332 }
333
334 void
335 _AppWidgetContext::OnBackground(void)
336 {
337         SysLog(NID_SHELL, "OnBackground");
338
339         if (!IsForeground())
340         {
341                 SysLog(NID_SHELL, "%ls is already background.", (this->GetAppId()).GetPointer());
342                 return;
343         }
344         SetForeground(false);
345 }
346
347 void
348 _AppWidgetContext::OnPopupCreated(double x, double y, int width, int height)
349 {
350         __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(this);
351         SysTryReturnVoidResult(NID_SHELL, __pAppWidgetPopup, E_OUT_OF_MEMORY, "");
352
353         __pAppWidgetPopup->OnPopupCreated(x, y, width, height);
354 }
355
356 void
357 _AppWidgetContext::OnPopupDestoyed(void)
358 {
359         SysLog(NID_SHELL, "");
360
361         if (__pAppWidgetPopup)
362         {
363 //              __pAppWidgetPopup->OnPopupDestoyed();
364                 delete __pAppWidgetPopup;
365                 __pAppWidgetPopup = null;
366         }
367 }
368
369 result
370 _AppWidgetContext::SendAddRequest(int width, int height)
371 {
372         std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
373
374         return SendRequestToApp(GetAppId(), APPWIDGET_ON_ADD, pArgs.release());
375 }
376
377 result
378 _AppWidgetContext::SendUpdateRequest(int width, int height, const String& argument)
379 {
380         std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
381
382         pArgs->Add(new (nothrow) String(ARG_KEY_ARGUMENT), new (nothrow) String(argument));
383
384         return SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release());
385 }
386
387 result
388 _AppWidgetContext::SendResizeRequest(int width, int height)
389 {
390         std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
391
392         return SendRequestToApp(GetAppId(), APPWIDGET_ON_RESIZE, pArgs.release());
393 }
394
395 result
396 _AppWidgetContext::SendRemoveRequest(void)
397 {
398         std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
399
400         return SendRequestToApp(GetAppId(), APPWIDGET_ON_REMOVE, pArgs.release());
401 }
402
403 result
404 _AppWidgetContext::SendPendingEvent(void)
405 {
406         TryReturnResult(__pPendingEventList->GetCount() > 0 , "There is no pending event.");
407
408         PendingEvent* pEvent = null;
409         __pPendingEventList->GetAt(0, pEvent);
410
411         if (pEvent == null)
412         {
413                 SysLog(NID_SHELL, "SendPendingEvent by IPC [0 existed.]");
414                 GetAppContext()->SetWaitingStatus(false);
415                 return E_SYSTEM;
416         }
417         SysLog(NID_SHELL, "SendPendingEvent by IPC [%d existed.]", __pPendingEventList->GetCount());
418
419         __pPendingEventList->RemoveAt(0);
420         result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg);
421         GetAppContext()->SetWaitingStatus(false);
422         delete pEvent;
423         SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed.");
424
425         return E_SUCCESS;
426 }
427
428 void
429 _AppWidgetContext::SendPendingTouchEvent(void)
430 {
431         for (int i =0; i< __pPendingTouchEventList->GetCount(); i++)
432         {
433                 PendingTouchEvent* pTouchEvent = null;
434                 __pPendingTouchEventList->GetAt(i, pTouchEvent);
435                 AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), pTouchEvent->eventType, pTouchEvent->timeStamp, pTouchEvent->x, pTouchEvent->y);
436                 delete pTouchEvent;
437         }
438         __pPendingTouchEventList->RemoveAll();
439 }
440
441 void
442 _AppWidgetContext::OnTouchEventReceived(buffer_event event, double timestamp, double x, double y)
443 {
444         if (__pAppContext->GetConnectionState() == CONNECTION_STATE_CONNECTED && __isTouchAvailable)
445         {
446                 SysLog(NID_SHELL, "%d, %f, %f", event, x, y);
447                 AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), event, timestamp, x, y);
448         }
449         else
450         {
451                 __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(event, timestamp, x, y));
452
453                 if( AppManager::GetInstance()->IsRunning(this->GetAppId() ) == false)
454                 {
455                         SysLog(NID_SHELL, "request to start AppControl");
456                         std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
457
458                         // TODO: consider to remove these unused args.
459                         pArgs->Add(new (nothrow) String(ARG_KEY_EVENT_TYPE), new (nothrow) String(Integer::ToString(event)));
460                         pArgs->Add(new (nothrow) String(ARG_KEY_TIME_STAMP), new (nothrow) String(Double::ToString(timestamp)));
461                         pArgs->Add(new (nothrow) String(ARG_KEY_X), new (nothrow) String(Double::ToString(x)));
462                         pArgs->Add(new (nothrow) String(ARG_KEY_Y), new (nothrow) String(Double::ToString(y)));
463
464                         SendRequestToApp(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get());
465                 }
466         }
467 }
468
469 result
470 _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
471 {
472         result r = E_SUCCESS;
473
474         if ( __pAppContext->GetConnectionState() == CONNECTION_STATE_NONE || __pAppContext->GetConnectionState() == CONNECTION_STATE_DISCONNECTED)
475         {
476                 SysLog(NID_SHELL, "The application is not running.");
477                 result r = _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);
478                 SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r));
479
480                 __pAppContext->SetWaitingStatus(true);
481                 __pAppContext->SetConnectionState(CONNECTION_STATE_CONNECTING);
482         }
483         else
484         {
485                 if ( __pAppContext->GetConnectionState() == CONNECTION_STATE_CONNECTING || __pAppContext->GetWaitingStatus() == true)
486                 {
487                         SysLog(NID_SHELL, "The application is running but IPC is not connected yet.");
488                         __pPendingEventList->Add(new (nothrow) PendingEvent(operation, pArgs));
489                 }
490                 else
491                 {
492                         SysLog(NID_SHELL, "The application is running and IPC is connected.");
493                         r  = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), operation, pArgs);
494
495                         pArgs->RemoveAll(true);
496                         delete pArgs;
497                         __pAppContext->SetWaitingStatus(true);
498                 }
499         }
500
501         return E_SUCCESS;
502 }
503
504 result
505 _AppWidgetContext::SendPopupRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) const
506 {
507         return _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);;
508 }
509
510 result
511 _AppWidgetContext::SyncRemoteBuffer(int width, int height)
512 {
513         std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(GetProviderId()));
514         std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
515         std::unique_ptr<char[]> content_info(_StringConverter::CopyToCharArrayN(GetUserInfo()));
516
517         int ret = provider_send_updated(providerId.get(), id.get(), width, height, GetPriority(), content_info.get(), null);
518         SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
519
520         SendPendingTouchEvent();
521         SysLog(NID_SHELL, "Done");
522         return E_SUCCESS;
523 }
524
525 result
526 _AppWidgetContext::SendAccessStatus(int accessStatus) const
527 {
528         std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(GetProviderId()));
529         std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
530
531         int ret = provider_send_access_status(providerId.get(), id.get(), accessStatus);
532         SysLog(NID_SHELL, "[LB_ACCESS] provider_send_access_status is called. : ret = %d, status = %d", ret, accessStatus);
533         SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_access_status");
534
535         return E_SUCCESS;
536 }
537
538 Tizen::Base::Collection::HashMap*
539 _AppWidgetContext::CreateRequestArgsN(void) const
540 {
541         HashMap* pArgs = new (nothrow) HashMap(SingleObjectDeleter);
542         pArgs->Construct();
543
544         pArgs->Add(new (nothrow) String(ARG_KEY_INSTANCE_ID), new (nothrow) String(GetInstanceId()));
545         pArgs->Add(new (nothrow) String(ARG_KEY_PROVIDER_NAME), new (nothrow) String(GetProviderName()));
546         pArgs->Add(new (nothrow) String(ARG_KEY_USER_INFO), new (nothrow) String(GetUserInfo()));
547         pArgs->Add(new (nothrow) String(ARG_KEY_WIDTH), new (nothrow) String(Integer::ToString(GetWidth())));
548         pArgs->Add(new (nothrow) String(ARG_KEY_HEIGHT), new (nothrow) String(Integer::ToString(GetHeight())));
549
550         return pArgs;
551 }
552
553 int
554 _AppWidgetContext::GetPeriod(void) const
555 {
556         return __updateMillis;
557 }
558
559 long long
560 _AppWidgetContext::GetLastUpdatedTime(void) const
561 {
562         return __lastUpdatedTime;
563 }
564
565 int
566 _AppWidgetContext::GetClientId(void) const
567 {
568         return GetAppContext()->GetClientId();
569 }
570
571 int
572 _AppWidgetContext::GetWidth(void) const
573 {
574         return __width;
575 }
576
577 void
578 _AppWidgetContext::SetWidth(int width)
579 {
580         __width = width;
581 }
582
583 int
584 _AppWidgetContext::GetHeight(void) const
585 {
586         return __height;
587 }
588
589 void
590 _AppWidgetContext::SetHeight(int height)
591 {
592         __height = height;
593 }
594
595 String
596 _AppWidgetContext::GetProviderId(void) const
597 {
598         return __providerId;
599 }
600
601 /*void
602 _AppWidgetContext::SetProviderId(const String& providerId)
603 {
604         __providerId = providerId;
605 }*/
606
607 String
608 _AppWidgetContext::GetAppId(void) const
609 {
610         return __appId;
611 }
612
613 int
614 _AppWidgetContext::GetPriority(void) const
615 {
616         return __priority;
617 }
618
619 /*void
620 _AppWidgetContext::SetPriority(int priority)
621 {
622         __priority = priority;
623 }*/
624
625 String
626 _AppWidgetContext::GetProviderName(void) const
627 {
628         return __providerName;
629 }
630
631 void
632 _AppWidgetContext::SetForeground(bool foreground)
633 {
634         __isForeground = foreground;
635 }
636
637 bool
638 _AppWidgetContext::IsForeground(void) const
639 {
640         return __isForeground;
641 }
642
643 String
644 _AppWidgetContext::GetUserInfo(void) const
645 {
646         return __userInfo;
647 }
648
649 /*void
650 _AppWidgetContext::SetUserInfo(const String& userInfo)
651 {
652         __userInfo = userInfo;
653 }*/
654
655 String
656 _AppWidgetContext::GetInstanceId(void) const
657 {
658         return __instanceId;
659 }
660
661 void
662 _AppWidgetContext::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
663 {
664         if (&timer == &__updateTimer)
665         {
666                 SysLog(NID_SHELL, "update timer is expired for appWidget app(%ls).", GetProviderId().GetPointer());
667                 OnUpdate(L"");
668         }
669 }
670
671 void
672 _AppWidgetContext::OnDisconnected(void)
673 {
674         SysSecureLog(NID_SHELL, "%ls, %ls", GetInstanceId().GetPointer(), GetProviderId().GetPointer());
675
676         __isTouchAvailable = false;
677         if (GetAppWidgetPopup())
678         {
679                 OnPopupDestoyed();
680         }
681 }
682
683 int
684 _AppWidgetContext::AcquireRemoteBuffer(int w, int h) const
685 {
686         int id = __pAppWidgetRemoteBuffer->Acquire(w, h);
687         if (id != -1)
688         {
689                 __isTouchAvailable = true;
690         }
691         return id;
692 }
693
694 }}}  // Tizen::Shell::App