summaryrefslogtreecommitdiff
path: root/src_mobile/Daemon/BoxDaemonImpl.h
blob: 9ee5e10d3214d49e824c4d7b18fc4701eef4777a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
 *
 *    Licensed under the Flora License, Version 1.1 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://floralicense.org/license/
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
/**
 * @file    BoxDaemonImpl.h
 * @author  Yunchan Cho (yunchan.cho@samsung.com)
 */
#ifndef BOX_DAEMON_IMPL_H
#define BOX_DAEMON_IMPL_H

#include <string>
#include <memory>
#include <app.h>
#include <provider.h>
#include <Eina.h>
#include <Ecore.h>
#include <Plugin/box_plugin_interface.h>
#include <Core/BoxData.h>
#include <vconf.h>

// forward declaration
class IBoxManager;
class IBoxPluginConnector;

class BoxDaemonImpl {
    public:
        bool start(std::string& name);
        bool stop();
        bool handleAppService(service_h service);

    public:
        explicit BoxDaemonImpl();
        ~BoxDaemonImpl();
    
    private:
        // type definition
        typedef struct event_arg ProviderEventArg;
        typedef ProviderEventArg* ProviderEventArgPtr;
        typedef struct event_handler ProviderCallbacks;
        typedef ProviderCallbacks* ProviderCallbacksPtr;

        // livebox's provider callbacks
        static int connectedCallback(ProviderEventArgPtr arg, void* data);
        static int disconnectedCallback(ProviderEventArgPtr arg, void* data);
        static int boxCreateCallback( 
                        ProviderEventArgPtr arg, 
                        int* width, int* height, 
                        double* priority, void* data);
        static int boxReCreateCallback(ProviderEventArgPtr arg, void* data);
        static int boxDestroyCallback(ProviderEventArgPtr arg, void* data);
        static int pdCreateCallback(ProviderEventArgPtr arg, void* data);
        static int pdDestroyCallback(ProviderEventArgPtr arg, void* data);
        static int clickedCallback(ProviderEventArgPtr arg, void* data);
        static int boxResizeCallback(ProviderEventArgPtr arg, void* data);
        static int boxPauseCallback(ProviderEventArgPtr arg, void* data);
        static int boxResumeCallback(ProviderEventArgPtr arg, void* data);
        static int pauseCallback(ProviderEventArgPtr arg, void* data);
        static int resumeCallback(ProviderEventArgPtr arg, void* data);
        static int boxPeriodChangeCallback(ProviderEventArgPtr arg, void* data);
        static int boxUpdateCallback(ProviderEventArgPtr arg, void* data);
        // callback for app-core event
        static int requestChangeLanguageCallback(void* data);
        static int requestChangeRegionCallback(void* data);
        static int requestLowMemoryCallback(void* data);
        // callback for vconf event
        static void requestChangeFontCallback(keynode_t* key, void* data);
        static void requestChangeTimeCallback(keynode_t* key, void* data);
        // common private functions
        void setProviderCallbacks(ProviderCallbacks& callbacks);
        std::string getBoxType(const char* boxId);
        BoxInfoPtr initializeBoxInfo(ProviderEventArgPtr arg);

        // functions for handling appcontrol per operation
        std::string getBoxIdFromService(service_h service);
        bool isServiceCallerBoxOwner(service_h service);
        BoxInfoPtr handleOperationUpdate(service_h service);

        // callback for ping to master daemon
        static Eina_Bool pingToMasterCallback(void* data);

        // callback for requested jobs of boxes
        static void requestBoxJobCallback(void* data);

        // members
        std::string m_daemonName;
        Ecore_Timer* m_pingTimer;
        std::shared_ptr<IBoxPluginConnector> m_pluginConnector;
};

struct JobInfo {
    request_cmd_type cmdType;
    BoxInfoPtr boxInfo;
    BoxDaemonImpl* daemonImpl;

    JobInfo(request_cmd_type cmdType,
            BoxInfoPtr boxInfo,
            BoxDaemonImpl* daemonImpl) :
        cmdType(cmdType),
        boxInfo(boxInfo),
        daemonImpl(daemonImpl)
    {
    };
};


#endif //BOX_DAEMON_IMPL_H