15 * \brief A namespace for all classes used to construct \b phoned daemon.
20 * @defgroup phoned phoned daemon
21 * \brief Phoned daemon to provide a single point to access phone functionality.
23 * A module to provide a signle point to access phone functionality. It provides a phoned daemon, which registers itself on D-Bus as \b org.tizen.phone service and exports phone specific methods on D-Bus, as well as emits a phone specific signals on the bus. See Phone for more details.
29 /*! \class PhoneD::Phone
30 * \brief Class which is utilizing ConnMan, Bluez, OFono and Obex D-Bus services to be used for operations with a phone.
32 * Class which is utilizing ConnMan, Bluez, OFono and Obex D-Bus services and in controlled way exports them via D-Bus to be used by WRT plugin @link wrt-plugins-ivi-phone wrt-plugins-ivi-phone @endlink to provide access to phone functionality from Web application. \n
33 * In the construction phase, it requests to get own name on the D-Bus. Once the bus acquired callback is called, it starts setup procedure. It registers a service \b org.tizen.phone on D-Bus, registers Bluez agent for BT authentication and finaly starts OFono (selects and activates a modem) and Obex (creates a session) instances. ConnMan instance is used for initial powering up BT technology. Bluez is used to subscribe for BT specific notifications, such as notifications about \b Powered state of BT, notifications about paired and selected device being removed/unpaired, and many more.
35 * When it registers a service on D-Bus, it exports the following methods on \b org.tizen.Phone interface:
37 * <li> \b SelectRemoteDevice ( \a \b address ) Selects a remote device/phone, to which the phone operations should be performed at. Will emit \b RemoteDeviceSelected signal, once the device gets selected. </li>
39 * <li> \a \b address [in] \b 's' MAC address of a remote device to be selected. </li>
42 * <li> \b GetSelectedRemoteDevice ( \a \b address ) Gets a currently selected remote device used for phone operations. It returns \b "" if no device is currently selected. </li>
44 * <li> \a \b address [out] \b 's' MAC address of selected remote device. </li>
47 * <li> \b UnselectRemoteDevice () Unselects selected remote device. Will emit \b RemoteDeviceSelected signal with an address argument \b "". </li>
49 * <li> \b Dial ( \a \b number ) Dials a given phone number. </li>
51 * <li> \a \b number [in] \b 's' A phone number to dial. </li>
54 * <li> \b Answer () Answers an incoming phone call. </li>
56 * <li> \b Mute ( \a \b muted ) Mutes/unmutes the active phone call. </li>
58 * <li> \a \b muted [in] \b 'b' Specifies whether to mute, or unmute the call. </li>
61 * <li> \b Hangup () A method to decline incoming call, or hangup the active one. </li>
63 * <li> \b ActiveCall ( \a \b call ) Gets the active phone call in JSON format, or \b {} when there is no active call. </li>
65 * <li> \a \b call [out] \b 'a{sv}' An active call in JSON format. </li>
68 * <li> \b Synchronize () Synchronizes PB data from the phone (Contacts, CallHistory).
70 * <li> \b GetContacts ( \a \b count, \a \b contacts ) Gets \a \b count first contacts in \b tizen.Contact JSON format, or \b [] when the data are not synchronized, or there are no contacts on the remote device. </li>
72 * <li> \a \b count [in] \b 'u' A number to specify how many first contacts should be returned. \a \b 0 means to return all contacts. </li>
73 * <li> \a \b contacts [out] \b 's' Returned \a \b count countacts in \b tizen.Contact JSON format. </li>
76 * <li> \b GetCallHistory ( \a \b count, \a \b calls ) Gets \a \b count latest call entries from the history in \b tizen.CallHistoryEntry JSON format, or \b [] when the data are not synchronized, or there are no calls in the history on the remote device. </li>
78 * <li> \a \b count [in] \b 'u' A number to specify how many latest call entries should be returned. </li>
79 * <li> \a \b calls [out] \b 's' Returned latest \a \b count call entries in \b tizen.CallHistoryEntry JSON format. </li>
84 * And emits the following signals:
86 * <li> \b RemoteDeviceSelected ( \a \b device ) A signal which is emitted when the selected remote device has changed, eg. the selected remote device has been selected, or when the remote device has been unselected, eg. due to connection lost with the remote device, or as a result of calling \b UnselectRemoteDevice method.
88 * <li> \a \b device [in] \b 's' A device in JSON format describing the change. </li>
91 * <li> \b ContactsChanged () A signal which is emitted when there is a change in synchronized contacts.
93 * <li> \b CallHistoryChanged () A signal which is emitted when there is a change in synchronized call history, eg. due to made/received phone call.
95 * <li> \b CallHistoryEntryAdded ( \a \b call ) A signal which is emitted when a call has been added to the call history, eg. due to made/received phone call.
97 * <li> \a \b call \b 's' A call in \b tizen.CallHistoryEntry fromat that has been added to the call history.
100 * <li> \b CallChanged ( \a \b call ) A signal which is emitted when there is a change in the active call. It indicates incoming, as well as the individual states that the call may go through, like "alerting", "active", "disconnected".
102 * <li> \a \b call \b '(a{sv})' A call object which specifies \a \b state of the call, \a \b line \a \b identifier (the phone number) and the \a \b contact if there is a match with the \a \b line_id.
106 class Phone : public ConnMan, public Bluez, public OFono, public Obex {
109 * A default constructor which initializes individual services and sets BT adapter "Powered" ON. It requests a name \b org.tizen.phone to register itself on D-Bus. Once the bus acquired callback is called, it registers Bluez agent for BT authentification and starts OFono and Obex services.
115 * Unregisters the service from D-Bus and destructs the object.
120 void setup(); // called once the bus is acquired
121 void startServices(); // starts OFono/Obex services
122 void stopServices(); // stops OFono/Obex services
123 static void busAcquiredCb(GDBusConnection *gdbus, const gchar *name, gpointer data);
124 static void nameAcquiredCb(GDBusConnection *gdbus, const gchar *name, gpointer data);
125 static void nameLostCb(GDBusConnection *gdbus, const gchar *name, gpointer data);
126 static void handleMethodCall( GDBusConnection *connection,
128 const gchar *object_path,
129 const gchar *interface_name,
130 const gchar *method_name,
131 GVariant *parameters,
132 GDBusMethodInvocation *invocation,
136 virtual void adapterPowered(bool value); // to handle "Powered" property changed on ADAPTER, due to eg. RF-kill
137 virtual void defaultAdapterAdded();
138 virtual void defaultAdapterRemoved();
139 virtual void deviceCreated(const char *device);
140 virtual void deviceRemoved(const char *device);
142 virtual void callChanged(const char* state, const char* phoneNumber);
143 virtual void modemAdded(std::string &modem); // MAC address of modem ... from ModemAdded DBUS
144 virtual void modemPowered(bool powered);
145 virtual void setModemPoweredFailed(const char *err);
147 virtual void contactsChanged();
148 virtual void callHistoryChanged();
149 virtual void pbSynchronizationDone();
150 virtual void createSessionFailed(const char *err);
151 virtual void createSessionDone(const char *s);
152 virtual void removeSessionDone();
153 // NOTE: entry is valid only for the time of call this method
154 virtual void callHistoryEntryAdded(std::string &entry);
155 // active transfer is stalled - ??? session is down ???
156 virtual void transferStalled();
157 static gboolean delayedSyncCallHistory(gpointer user_data);
159 // function to store MAC address of selected remote device in persistent storage/file
160 // returns bool indicating result of the operation: false = failed, true = OK
161 bool storeSelectedRemoteDeviceMAC(const std::string &btAddress);
162 // function to read MAC address of selected remote device from persistent storage/file
163 // remote address is returned via 'btAddress' argument to the function
164 // returns bool indicating result of the operation: false = failed, true = OK
165 bool readSelectedRemoteDeviceMAC(std::string &btAddress);
167 // sets selected remote device MAC address
168 void setSelectedRemoteDevice(std::string &btAddress);
171 bool mAdapterPowered; // variable to hold the state of Default adpater - not to try to 'CreateSession' 'cause it will result in Powering up the device, which is unwanted behavior
172 std::string mWantedRemoteDevice; // a remote device that is requested to be 'Selected'
173 std::string mSelectedRemoteDevice; // selected remote device - if initialization of OFono/Obex is successfull
174 bool mPBSynchronized; // indicating whether PB data are synchronized, or not
175 std::vector<CtxCbData*> mSynchronizationDoneListeners; // listeners to be notified once the synchronization finishes
176 guint mNameRequestId;
177 guint mRegistrationId;
178 GDBusNodeInfo *mIntrospectionData;
179 GDBusInterfaceVTable mIfaceVTable;
184 #endif /* PHONE_H_ */