18 /*! \class PhoneD::OFono
19 * \brief Class which is utilizing OFono D-Bus service. It is a base class and is not meant to be instantiated directly.
21 * A class providing access to <a href="http://www.ofono.org">OFono</a> functionality. It allows make a phone call, answer/decline incoming call, hang-up active phone call.
28 * \brief A Class describing phone call object.
30 * A class describing phone call object. It is used to get information about active call.
35 * A default constructor which constructs an empty object with NULL initialized members.
37 Call() : path(NULL), state(NULL), line_id(NULL) {};
39 * Copy constructor to make a copy from the Call object specified by the pointer to it.
40 * @param[in] call A pointer to Call object to make a copy of.
42 Call(OFono::Call *call) {
43 if(call->path) path = strdup(call->path);
44 if(call->state) state = strdup(call->state);
45 if(call->line_id) line_id = strdup(call->line_id);
48 * A destructor which frees the allocated memory of member variables and destroys the object.
51 if(path) { g_free(path); path=NULL; }
52 if(state) { g_free(state); state=NULL; }
53 if(line_id) { g_free(line_id); line_id=NULL; }
56 char *path; /*!< A path to the call object */
57 char *state; /*!< A state of phone call (incoming,dialing,active,disconnected) */
58 char *line_id; /*!< A line identifier. It contains a phone number of the caller, or the calling person respectively. */
63 * A default constructor. Constructs the object and subscribes for certain D-Bus signals of \b org.ofono service:
65 * <li> "ModemAdded" on \b org.ofono.Manager interface - To get notified when modem is added. </li>
66 * <li> "ModemRemoved" on \b org.ofono.Manager interface - To get notified when modem is removed.</li>
68 * It starts a timer to check whether default modem is \b Powered, or not. It handles the case, when the device gets out of the range, or when the user
69 * turns OFF and then turns ON the BT on the phone device, in which case there isn't a notification that the remote device got back.
70 * The timer in specific interval checks whether the modem is \b Powered and if not, it tries to power it up.
75 * A destructor. Unselects default modem and destructs the object. @see selectModem() and unselectModem()
80 * A method to select modem. It gets the list of available modems and checks them against the given MAC address. If the modem is for the device specified by the given MAC address, it is selected as default one.
81 * @param[in] btAddress A MAC address of a remote BT device for which the modem should be selected.
82 * @see unselectModem()
84 void selectModem(std::string &btAddress);
87 * A method to unselect the default modem.
93 * A method to invoke phone call.
94 * @param[in] phoneNumber A phone number to invoke phone call.
95 * @param[out] error If the return value from the method is \b false, it contains a description of the error. The caller is responsible for freeing the memory if the error is set.
96 * @return \b True if D-Bus "Dial" method was successfuly called on \b org.ofono.VoiceCallManager interface, otherwise it returns \b false.
98 bool invokeCall(const char* phoneNumber, char **error);
101 * A method to answer incoming phone call.
102 * @param[out] error If the return value from the method is \b false, it contains a description of the error. The caller is responsible for freeing the memory if the error is set.
103 * @return \b True if D-Bus "Answer" method was successfuly called on \b org.ofono.VoiceCall interface, otherwise it returns \b false.
105 bool answerCall(char **error);
108 * A method to decline incoming, or hangup active phone call.
109 * @param[out] error If the return value from the method is \b false, it contains a description of the error. The caller is responsible for freeing the memory if the error is set.
110 * @return \b True if D-Bus "Hangup" method was successfuly called on \b org.ofono.VoiceCall interface, otherwise it returns \b false.
112 bool hangupCall(char **error);
115 * A method to mute/unmute active phone call.
116 * @param[in] mute Specifies whether to mute/unmute phone call.
117 * @param[out] error If the return value from the method is \b false, it contains a description of the error. The caller is responsible for freeing the memory if the error is set.
118 * @return \b True if D-Bus "SetProperty" method to set "Muted" property was successfuly called on \b org.ofono.CallVolume interface, otherwise it returns \b false.
120 bool muteCall(bool mute, char **error);
123 * Gets the information about active phone call. It creates new object (allocates a memory) and the caller has to delete it.
124 * @return OFono::Call object describing active phone call.
126 OFono::Call *activeCall();
129 static void asyncSelectModemCallback(GObject *source, GAsyncResult *result, gpointer user_data); // async callback for "GetModems" invoked from selectModem() method
130 virtual void callChanged(const char* state, const char* phoneNumber) = 0;
132 void addModem(const char *path, GVariantIter *props);
133 virtual void modemAdded(std::string &modem) = 0; // MAC address of modem ... from ModemAdded DBUS
134 void removeModem(const char *modemPath);
135 virtual void modemPowered(bool powered) = 0;
136 virtual void setModemPoweredFailed(const char *err) = 0;
137 static void handleSignal(GDBusConnection *connection, const gchar *sender,
138 const gchar *object_path, const gchar *interface_name,
139 const gchar *signal_name, GVariant *parameters,
142 //DBUS: array{object,dict}
143 void getModems(); //Get an array of call object paths and properties of available modems
144 void getCalls(); //Get an array of call object paths and properties that represents the currently present calls.
145 void addCall(const char *path, GVariantIter *props);
146 void removeCall(OFono::Call **call);
148 // used to set property on ifaces that do have same object path, eg. Modem, CallVolume, ...
149 bool setProperty(const char* iface, const char* path, const char *property, int type, void *value); // returns success of the operation
150 void setPropertyAsync(const char* iface, const char* path, const char *property, int type, void *value, GAsyncReadyCallback callback);
152 void setModemPowered(const char *path, bool powered); // path of Modem object
153 bool isModemPowered(const char *modem);
154 static void asyncSetModemPoweredCallback(GObject *source, GAsyncResult *result, gpointer user_data); // async callback for "SetProperty" invoked from setModemPowered() method
155 static gboolean checkForModemPowered(gpointer user_data); // continuous timeout method to check for 'Selected' modem being Powered and power it on, if it's not
157 static void GDbusAsyncReadyCallback(GObject *source, GAsyncResult *result, gpointer user_data);
160 DBusConnection *mDBusConnection;
162 OFono::Call *mActiveCall;
165 #endif /* OFONO_H_ */