diff options
author | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
commit | f3ab456a17af1c89a6e3be4d20c5944853df1cb0 (patch) | |
tree | d00e1a332cd038a6d906a1ea0ac91e1a4458e617 /pjsip-apps/src/symbian_ua_gui/src |
Import pjproject-2.0.1
Diffstat (limited to 'pjsip-apps/src/symbian_ua_gui/src')
9 files changed, 2599 insertions, 0 deletions
diff --git a/pjsip-apps/src/symbian_ua_gui/src/Symbian_ua_guiSettingItemListSets.cpp b/pjsip-apps/src/symbian_ua_gui/src/Symbian_ua_guiSettingItemListSets.cpp new file mode 100644 index 0000000..7e66d76 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/Symbian_ua_guiSettingItemListSets.cpp @@ -0,0 +1,154 @@ +/* $Id: Symbian_ua_guiSettingItemListSets.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/** + * Generated helper class which manages the settings contained + * in 'symbian_ua_guiSettingItemList'. Each CAknSettingItem maintains + * a reference to data in this class so that changes in the setting + * item list can be synchronized with this storage. + */ + +// [[[ begin generated region: do not modify [Generated Includes] +#include <e32base.h> +#include <stringloader.h> +#include <barsread.h> +#include <symbian_ua_gui.rsg> +#include "Symbian_ua_guiSettingItemListSettings.h" +// ]]] end generated region [Generated Includes] + +/** + * C/C++ constructor for settings data, cannot throw + */ +TSymbian_ua_guiSettingItemListSettings::TSymbian_ua_guiSettingItemListSettings() + { + } + +/** + * Two-phase constructor for settings data + */ +TSymbian_ua_guiSettingItemListSettings* TSymbian_ua_guiSettingItemListSettings::NewL() + { + TSymbian_ua_guiSettingItemListSettings* data = new( ELeave ) TSymbian_ua_guiSettingItemListSettings; + CleanupStack::PushL( data ); + data->ConstructL(); + CleanupStack::Pop( data ); + return data; + } + +/** + * Second phase for initializing settings data + */ +void TSymbian_ua_guiSettingItemListSettings::ConstructL() + { + // [[[ begin generated region: do not modify [Generated Initializers] + { + HBufC* text = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_ED_REGISTRAR ); + SetEd_registrar( text->Des() ); + CleanupStack::PopAndDestroy( text ); + } + { + HBufC* text = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_ED_USER ); + SetEd_user( text->Des() ); + CleanupStack::PopAndDestroy( text ); + } + SetB_srtp( 0 ); + SetB_ice( 0 ); + { + HBufC* text = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_ED_STUN_SERVER ); + SetEd_stun_server( text->Des() ); + CleanupStack::PopAndDestroy( text ); + } + // ]]] end generated region [Generated Initializers] + + } + +// [[[ begin generated region: do not modify [Generated Contents] +TDes& TSymbian_ua_guiSettingItemListSettings::Ed_registrar() + { + return iEd_registrar; + } + +void TSymbian_ua_guiSettingItemListSettings::SetEd_registrar(const TDesC& aValue) + { + if ( aValue.Length() < KEd_registrarMaxLength) + iEd_registrar.Copy( aValue ); + else + iEd_registrar.Copy( aValue.Ptr(), KEd_registrarMaxLength); + } + +TDes& TSymbian_ua_guiSettingItemListSettings::Ed_user() + { + return iEd_user; + } + +void TSymbian_ua_guiSettingItemListSettings::SetEd_user(const TDesC& aValue) + { + if ( aValue.Length() < KEd_userMaxLength) + iEd_user.Copy( aValue ); + else + iEd_user.Copy( aValue.Ptr(), KEd_userMaxLength); + } + +TDes& TSymbian_ua_guiSettingItemListSettings::Ed_password() + { + return iEd_password; + } + +void TSymbian_ua_guiSettingItemListSettings::SetEd_password(const TDesC& aValue) + { + if ( aValue.Length() < KEd_passwordMaxLength) + iEd_password.Copy( aValue ); + else + iEd_password.Copy( aValue.Ptr(), KEd_passwordMaxLength); + } + +TBool& TSymbian_ua_guiSettingItemListSettings::B_srtp() + { + return iB_srtp; + } + +void TSymbian_ua_guiSettingItemListSettings::SetB_srtp(const TBool& aValue) + { + iB_srtp = aValue; + } + +TBool& TSymbian_ua_guiSettingItemListSettings::B_ice() + { + return iB_ice; + } + +void TSymbian_ua_guiSettingItemListSettings::SetB_ice(const TBool& aValue) + { + iB_ice = aValue; + } + +TDes& TSymbian_ua_guiSettingItemListSettings::Ed_stun_server() + { + return iEd_stun_server; + } + +void TSymbian_ua_guiSettingItemListSettings::SetEd_stun_server(const TDesC& aValue) + { + if ( aValue.Length() < KEd_stun_serverMaxLength) + iEd_stun_server.Copy( aValue ); + else + iEd_stun_server.Copy( aValue.Ptr(), KEd_stun_serverMaxLength); + } + +// ]]] end generated region [Generated Contents] + diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua.cpp new file mode 100644 index 0000000..79e81f2 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua.cpp @@ -0,0 +1,514 @@ +/* $Id: ua.cpp 1793 2008-02-14 13:39:24Z bennylp $ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjsua-lib/pjsua.h>
+#include <pjsua-lib/pjsua_internal.h>
+#include <es_sock.h>
+#include "symbian_ua.h"
+
+#define THIS_FILE "symbian_ua.cpp"
+#define LOG_LEVEL 3
+
+#define SIP_PORT 5060
+#define USE_ICE 0
+#define USE_SRTP PJSUA_DEFAULT_USE_SRTP
+
+static RSocketServ aSocketServer;
+static RConnection aConn;
+
+static pjsua_acc_id g_acc_id = PJSUA_INVALID_ID;
+static pjsua_call_id g_call_id = PJSUA_INVALID_ID;
+static pjsua_buddy_id g_buddy_id = PJSUA_INVALID_ID;
+
+static symbian_ua_info_cb_t g_cb = {NULL, NULL, NULL, NULL, NULL};
+
+static void log_writer(int level, const char *buf, int len)
+{
+ static wchar_t buf16[PJ_LOG_MAX_SIZE];
+
+ PJ_UNUSED_ARG(level);
+
+ if (!g_cb.on_info)
+ return;
+
+ pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
+ g_cb.on_info(buf16);
+}
+
+static void on_reg_state(pjsua_acc_id acc_id)
+{
+ pjsua_acc_info acc_info;
+ pj_status_t status;
+
+ status = pjsua_acc_get_info(acc_id, &acc_info);
+ if (status != PJ_SUCCESS)
+ return;
+
+ if (acc_info.status == 200) {
+ if (acc_info.expires) {
+ PJ_LOG(3,(THIS_FILE, "Registration success!"));
+ if (g_cb.on_reg_state) g_cb.on_reg_state(true);
+ } else {
+ PJ_LOG(3,(THIS_FILE, "Unregistration success!"));
+ if (g_cb.on_unreg_state) g_cb.on_unreg_state(true);
+ }
+ } else {
+ if (acc_info.expires) {
+ PJ_LOG(3,(THIS_FILE, "Registration failed!"));
+ if (g_cb.on_reg_state) g_cb.on_reg_state(false);
+ } else {
+ PJ_LOG(3,(THIS_FILE, "Unregistration failed!"));
+ if (g_cb.on_unreg_state) g_cb.on_unreg_state(false);
+ }
+ }
+}
+
+/* Callback called by the library upon receiving incoming call */
+static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
+ pjsip_rx_data *rdata)
+{
+ pjsua_call_info ci;
+
+ PJ_UNUSED_ARG(acc_id);
+ PJ_UNUSED_ARG(rdata);
+
+ if (g_call_id != PJSUA_INVALID_ID) {
+ pjsua_call_answer(call_id, PJSIP_SC_BUSY_HERE, NULL, NULL);
+ return;
+ }
+
+ pjsua_call_get_info(call_id, &ci);
+
+ PJ_LOG(3,(THIS_FILE, "Incoming call from %.*s!!",
+ (int)ci.remote_info.slen,
+ ci.remote_info.ptr));
+
+ g_call_id = call_id;
+
+ /* Automatically answer incoming calls with 180/Ringing */
+ pjsua_call_answer(call_id, 180, NULL, NULL);
+
+ if (g_cb.on_incoming_call) {
+ static wchar_t disp[256];
+ static wchar_t uri[PJSIP_MAX_URL_SIZE];
+
+ pj_ansi_to_unicode(ci.remote_info.ptr, ci.remote_info.slen,
+ disp, PJ_ARRAY_SIZE(disp));
+ pj_ansi_to_unicode(ci.remote_contact.ptr, ci.remote_contact.slen,
+ uri, PJ_ARRAY_SIZE(uri));
+
+ g_cb.on_incoming_call(disp, uri);
+ }
+}
+
+/* Callback called by the library when call's state has changed */
+static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
+{
+ pjsua_call_info ci;
+
+ PJ_UNUSED_ARG(e);
+
+ pjsua_call_get_info(call_id, &ci);
+
+ if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
+ if (call_id == g_call_id)
+ g_call_id = PJSUA_INVALID_ID;
+ if (g_cb.on_call_end) {
+ static wchar_t reason[256];
+ pj_ansi_to_unicode(ci.last_status_text.ptr, ci.last_status_text.slen,
+ reason, PJ_ARRAY_SIZE(reason));
+ g_cb.on_call_end(reason);
+ }
+
+ } else if (ci.state != PJSIP_INV_STATE_INCOMING) {
+ if (g_call_id == PJSUA_INVALID_ID)
+ g_call_id = call_id;
+ }
+
+ PJ_LOG(3,(THIS_FILE, "Call %d state=%.*s", call_id,
+ (int)ci.state_text.slen,
+ ci.state_text.ptr));
+}
+
+/* Callback called by the library when call's media state has changed */
+static void on_call_media_state(pjsua_call_id call_id)
+{
+ pjsua_call_info ci;
+
+ pjsua_call_get_info(call_id, &ci);
+
+ if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
+ // When media is active, connect call to sound device.
+ pjsua_conf_connect(ci.conf_slot, 0);
+ pjsua_conf_connect(0, ci.conf_slot);
+ }
+}
+
+
+/* Handler on buddy state changed. */
+static void on_buddy_state(pjsua_buddy_id buddy_id)
+{
+ pjsua_buddy_info info;
+ pjsua_buddy_get_info(buddy_id, &info);
+
+ PJ_LOG(3,(THIS_FILE, "%.*s status is %.*s",
+ (int)info.uri.slen,
+ info.uri.ptr,
+ (int)info.status_text.slen,
+ info.status_text.ptr));
+}
+
+
+/* Incoming IM message (i.e. MESSAGE request)! */
+static void on_pager(pjsua_call_id call_id, const pj_str_t *from,
+ const pj_str_t *to, const pj_str_t *contact,
+ const pj_str_t *mime_type, const pj_str_t *text)
+{
+ /* Note: call index may be -1 */
+ PJ_UNUSED_ARG(call_id);
+ PJ_UNUSED_ARG(to);
+ PJ_UNUSED_ARG(contact);
+ PJ_UNUSED_ARG(mime_type);
+
+ PJ_LOG(3,(THIS_FILE,"MESSAGE from %.*s: %.*s",
+ (int)from->slen, from->ptr,
+ (int)text->slen, text->ptr));
+}
+
+
+/* Received typing indication */
+static void on_typing(pjsua_call_id call_id, const pj_str_t *from,
+ const pj_str_t *to, const pj_str_t *contact,
+ pj_bool_t is_typing)
+{
+ PJ_UNUSED_ARG(call_id);
+ PJ_UNUSED_ARG(to);
+ PJ_UNUSED_ARG(contact);
+
+ PJ_LOG(3,(THIS_FILE, "IM indication: %.*s %s",
+ (int)from->slen, from->ptr,
+ (is_typing?"is typing..":"has stopped typing")));
+}
+
+
+/* Call transfer request status. */
+static void on_call_transfer_status(pjsua_call_id call_id,
+ int status_code,
+ const pj_str_t *status_text,
+ pj_bool_t final,
+ pj_bool_t *p_cont)
+{
+ PJ_LOG(3,(THIS_FILE, "Call %d: transfer status=%d (%.*s) %s",
+ call_id, status_code,
+ (int)status_text->slen, status_text->ptr,
+ (final ? "[final]" : "")));
+
+ if (status_code/100 == 2) {
+ PJ_LOG(3,(THIS_FILE,
+ "Call %d: call transfered successfully, disconnecting call",
+ call_id));
+ pjsua_call_hangup(call_id, PJSIP_SC_GONE, NULL, NULL);
+ *p_cont = PJ_FALSE;
+ }
+}
+
+
+/* NAT detection result */
+static void on_nat_detect(const pj_stun_nat_detect_result *res)
+{
+ if (res->status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "NAT detection failed", res->status);
+ } else {
+ PJ_LOG(3, (THIS_FILE, "NAT detected as %s", res->nat_type_name));
+ }
+}
+
+/* Notification that call is being replaced. */
+static void on_call_replaced(pjsua_call_id old_call_id,
+ pjsua_call_id new_call_id)
+{
+ pjsua_call_info old_ci, new_ci;
+
+ pjsua_call_get_info(old_call_id, &old_ci);
+ pjsua_call_get_info(new_call_id, &new_ci);
+
+ PJ_LOG(3,(THIS_FILE, "Call %d with %.*s is being replaced by "
+ "call %d with %.*s",
+ old_call_id,
+ (int)old_ci.remote_info.slen, old_ci.remote_info.ptr,
+ new_call_id,
+ (int)new_ci.remote_info.slen, new_ci.remote_info.ptr));
+}
+
+int symbian_ua_init()
+{
+ TInt err;
+ pj_symbianos_params sym_params;
+ pj_status_t status;
+
+ // Initialize RSocketServ
+ if ((err=aSocketServer.Connect(32)) != KErrNone)
+ return PJ_STATUS_FROM_OS(err);
+
+ // Open up a connection
+ if ((err=aConn.Open(aSocketServer)) != KErrNone) {
+ aSocketServer.Close();
+ return PJ_STATUS_FROM_OS(err);
+ }
+
+ if ((err=aConn.Start()) != KErrNone) {
+ aConn.Close();
+ aSocketServer.Close();
+ return PJ_STATUS_FROM_OS(err);
+ }
+
+ // Set Symbian OS parameters in pjlib.
+ // This must be done before pj_init() is called.
+ pj_bzero(&sym_params, sizeof(sym_params));
+ sym_params.rsocketserv = &aSocketServer;
+ sym_params.rconnection = &aConn;
+ pj_symbianos_set_params(&sym_params);
+
+ /* Redirect log before pjsua_init() */
+ pj_log_set_log_func(&log_writer);
+
+ /* Set log level */
+ pj_log_set_level(LOG_LEVEL);
+
+ /* Create pjsua first! */
+ status = pjsua_create();
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "pjsua_create() error", status);
+ return status;
+ }
+
+ /* Init pjsua */
+ pjsua_config cfg;
+
+ pjsua_config_default(&cfg);
+ cfg.max_calls = 2;
+ cfg.thread_cnt = 0; // Disable threading on Symbian
+ cfg.use_srtp = USE_SRTP;
+ cfg.srtp_secure_signaling = 0;
+
+ cfg.cb.on_incoming_call = &on_incoming_call;
+ cfg.cb.on_call_media_state = &on_call_media_state;
+ cfg.cb.on_call_state = &on_call_state;
+ cfg.cb.on_buddy_state = &on_buddy_state;
+ cfg.cb.on_pager = &on_pager;
+ cfg.cb.on_typing = &on_typing;
+ cfg.cb.on_call_transfer_status = &on_call_transfer_status;
+ cfg.cb.on_call_replaced = &on_call_replaced;
+ cfg.cb.on_nat_detect = &on_nat_detect;
+ cfg.cb.on_reg_state = &on_reg_state;
+
+ pjsua_media_config med_cfg;
+
+ pjsua_media_config_default(&med_cfg);
+ med_cfg.thread_cnt = 0; // Disable threading on Symbian
+ med_cfg.has_ioqueue = PJ_FALSE;
+ med_cfg.clock_rate = 8000;
+#if defined(PJMEDIA_SYM_SND_USE_APS) && (PJMEDIA_SYM_SND_USE_APS==1)
+ med_cfg.audio_frame_ptime = 20;
+#else
+ med_cfg.audio_frame_ptime = 40;
+#endif
+ med_cfg.ec_tail_len = 0;
+ med_cfg.enable_ice = USE_ICE;
+ med_cfg.snd_auto_close_time = 5; // wait for 5 seconds idle before sound dev get auto-closed
+
+ pjsua_logging_config log_cfg;
+
+ pjsua_logging_config_default(&log_cfg);
+ log_cfg.console_level = LOG_LEVEL;
+ log_cfg.cb = &log_writer;
+ log_cfg.decor = 0;
+
+ status = pjsua_init(&cfg, &log_cfg, &med_cfg);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "pjsua_init() error", status);
+ pjsua_destroy();
+ return status;
+ }
+
+ /* Add UDP transport. */
+ pjsua_transport_config tcfg;
+ pjsua_transport_id tid;
+
+ pjsua_transport_config_default(&tcfg);
+ tcfg.port = SIP_PORT;
+ status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &tcfg, &tid);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Error creating transport", status);
+ pjsua_destroy();
+ return status;
+ }
+
+ /* Add account for the transport */
+ pjsua_acc_add_local(tid, PJ_TRUE, &g_acc_id);
+
+ /* Initialization is done, now start pjsua */
+ status = pjsua_start();
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Error starting pjsua", status);
+ pjsua_destroy();
+ return status;
+ }
+
+ /* Adjust Speex priority and enable only the narrowband */
+ {
+ pj_str_t codec_id = pj_str("speex/8000");
+ pjmedia_codec_mgr_set_codec_priority(
+ pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+ &codec_id, PJMEDIA_CODEC_PRIO_NORMAL+1);
+
+ codec_id = pj_str("speex/16000");
+ pjmedia_codec_mgr_set_codec_priority(
+ pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+ &codec_id, PJMEDIA_CODEC_PRIO_DISABLED);
+
+ codec_id = pj_str("speex/32000");
+ pjmedia_codec_mgr_set_codec_priority(
+ pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+ &codec_id, PJMEDIA_CODEC_PRIO_DISABLED);
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+int symbian_ua_destroy()
+{
+ // Shutdown pjsua
+ pjsua_destroy();
+
+ // Close connection and socket server
+ aConn.Close();
+ aSocketServer.Close();
+
+ CloseSTDLIB();
+
+ return PJ_SUCCESS;
+}
+
+void symbian_ua_set_info_callback(const symbian_ua_info_cb_t *cb)
+{
+ if (cb)
+ g_cb = *cb;
+ else
+ pj_bzero(&g_cb, sizeof(g_cb));
+}
+
+int symbian_ua_set_account(const char *domain, const char *username,
+ const char *password,
+ bool use_srtp, bool use_ice)
+{
+ pj_status_t status;
+
+ PJ_ASSERT_RETURN(username && password && domain, PJ_EINVAL);
+ PJ_UNUSED_ARG(use_srtp);
+ PJ_UNUSED_ARG(use_ice);
+
+ if (domain[0] == 0) {
+ pjsua_acc_info acc_info;
+ pj_status_t status;
+
+ status = pjsua_acc_get_info(g_acc_id, &acc_info);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ if (acc_info.status == 200) {
+ PJ_LOG(3,(THIS_FILE, "Unregistering.."));
+ pjsua_acc_set_registration(g_acc_id, PJ_FALSE);
+ g_acc_id = 0;
+ }
+ return PJ_SUCCESS;
+ }
+
+ if (pjsua_acc_get_count() > 1) {
+ status = pjsua_acc_del(g_acc_id);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Error removing account", status);
+ return status;
+ }
+ g_acc_id = 0;
+ }
+
+ pjsua_acc_config cfg;
+ char tmp_id[PJSIP_MAX_URL_SIZE];
+ char tmp_reg_uri[PJSIP_MAX_URL_SIZE];
+
+ if (!pj_ansi_strnicmp(domain, "sip:", 4)) {
+ domain += 4;
+ }
+
+ pjsua_acc_config_default(&cfg);
+ pj_ansi_sprintf(tmp_id, "sip:%s@%s", username, domain);
+ cfg.id = pj_str(tmp_id);
+ pj_ansi_sprintf(tmp_reg_uri, "sip:%s", domain);
+ cfg.reg_uri = pj_str(tmp_reg_uri);
+ cfg.cred_count = 1;
+ cfg.cred_info[0].realm = pj_str("*");
+ cfg.cred_info[0].scheme = pj_str("digest");
+ cfg.cred_info[0].username = pj_str((char*)username);
+ cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
+ cfg.cred_info[0].data = pj_str((char*)password);
+
+ status = pjsua_acc_add(&cfg, PJ_TRUE, &g_acc_id);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Error setting account", status);
+ pjsua_destroy();
+ return status;
+ }
+
+ return PJ_SUCCESS;
+}
+
+int symbian_ua_makecall(const char* dest_url)
+{
+ if (pjsua_verify_url(dest_url) == PJ_SUCCESS) {
+ pj_str_t dst = pj_str((char*)dest_url);
+ pjsua_call_make_call(g_acc_id, &dst, 0, NULL,
+ NULL, &g_call_id);
+
+ return PJ_SUCCESS;
+ }
+
+ return PJ_EINVAL;
+}
+
+int symbian_ua_endcall()
+{
+ pjsua_call_hangup_all();
+
+ return PJ_SUCCESS;
+}
+
+bool symbian_ua_anycall()
+{
+ return (pjsua_call_get_count()>0);
+}
+
+int symbian_ua_answercall()
+{
+ PJ_ASSERT_RETURN (g_call_id != PJSUA_INVALID_ID, PJ_EINVAL);
+
+ return pjsua_call_answer(g_call_id, 200, NULL, NULL);
+}
+
diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiAppUi.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiAppUi.cpp new file mode 100644 index 0000000..276ffa3 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiAppUi.cpp @@ -0,0 +1,257 @@ +/* $Id: symbian_ua_guiAppUi.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated System Includes] +#include <eikmenub.h> +#include <akncontext.h> +#include <akntitle.h> +#include <symbian_ua_gui.rsg> +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_guiAppUi.h" +#include "symbian_ua_gui.hrh" +#include "symbian_ua_guiContainer.hrh" +#include "symbian_ua_guiSettingItemList.hrh" +#include "symbian_ua_guiContainerView.h" +#include "symbian_ua_guiSettingItemListView.h" +// ]]] end generated region [Generated User Includes] + +// [[[ begin generated region: do not modify [Generated Constants] +// ]]] end generated region [Generated Constants] + +#include "symbian_ua.h" + +/** + * Construct the Csymbian_ua_guiAppUi instance + */ +Csymbian_ua_guiAppUi::Csymbian_ua_guiAppUi() : CTimer(0) + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * The appui's destructor removes the container from the control + * stack and destroys it. + */ +Csymbian_ua_guiAppUi::~Csymbian_ua_guiAppUi() + { + // [[[ begin generated region: do not modify [Generated Contents] + TRAPD( err_Dlg_wait_init, RemoveDlg_wait_initL() ); + // ]]] end generated region [Generated Contents] + } + +// [[[ begin generated function: do not modify +void Csymbian_ua_guiAppUi::InitializeContainersL() + { + iSymbian_ua_guiContainerView = Csymbian_ua_guiContainerView::NewL(); + AddViewL( iSymbian_ua_guiContainerView ); + iSymbian_ua_guiSettingItemListView = Csymbian_ua_guiSettingItemListView::NewL(); + AddViewL( iSymbian_ua_guiSettingItemListView ); + SetDefaultViewL( *iSymbian_ua_guiSettingItemListView ); + } +// ]]] end generated function + +/** + * Handle a command for this appui (override) + * @param aCommand command id to be handled + */ +void Csymbian_ua_guiAppUi::HandleCommandL( TInt aCommand ) + { + // [[[ begin generated region: do not modify [Generated Code] + TBool commandHandled = EFalse; + switch ( aCommand ) + { // code to dispatch to the AppUi's menu and CBA commands is generated here + default: + break; + } + + + if ( !commandHandled ) + { + if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit ) + { + symbian_ua_destroy(); + Exit(); + } + } + // ]]] end generated region [Generated Code] + + } + +/** + * Override of the HandleResourceChangeL virtual function + */ +void Csymbian_ua_guiAppUi::HandleResourceChangeL( TInt aType ) + { + CAknViewAppUi::HandleResourceChangeL( aType ); + // [[[ begin generated region: do not modify [Generated Code] + // ]]] end generated region [Generated Code] + + } + +/** + * Override of the HandleKeyEventL virtual function + * @return EKeyWasConsumed if event was handled, EKeyWasNotConsumed if not + * @param aKeyEvent + * @param aType + */ +TKeyResponse Csymbian_ua_guiAppUi::HandleKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + // The inherited HandleKeyEventL is private and cannot be called + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + return EKeyWasNotConsumed; + } + +/** + * Override of the HandleViewDeactivation virtual function + * + * @param aViewIdToBeDeactivated + * @param aNewlyActivatedViewId + */ +void Csymbian_ua_guiAppUi::HandleViewDeactivation( + const TVwsViewId& aViewIdToBeDeactivated, + const TVwsViewId& aNewlyActivatedViewId ) + { + CAknViewAppUi::HandleViewDeactivation( + aViewIdToBeDeactivated, + aNewlyActivatedViewId ); + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * @brief Completes the second phase of Symbian object construction. + * Put initialization code that could leave here. + */ +void Csymbian_ua_guiAppUi::ConstructL() + { + // [[[ begin generated region: do not modify [Generated Contents] + BaseConstructL( EAknEnableSkin ); + InitializeContainersL(); + // ]]] end generated region [Generated Contents] + + // Create private folder + RProcess process; + TFileName path; + + path.Copy( process.FileName().Left(2) ); + + if(path.Compare(_L("c")) || path.Compare(_L("C"))) + CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveC); + else if(path.Compare(_L("e")) || path.Compare(_L("E"))) + CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveE); + + // Init PJSUA + if (symbian_ua_init() != 0) { + symbian_ua_destroy(); + Exit(); + } + + ExecuteDlg_wait_initLD(); + + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + After(4000000); + } + +/** + * Override of the HandleApplicationSpecificEventL virtual function + */ +void Csymbian_ua_guiAppUi::HandleApplicationSpecificEventL( + TInt aType, + const TWsEvent& anEvent ) + { + CAknViewAppUi::HandleApplicationSpecificEventL( aType, anEvent ); + // [[[ begin generated region: do not modify [Generated Code] + // ]]] end generated region [Generated Code] + + } + +/** + * Handle the applicationSpecificEvent event. + */ +void Csymbian_ua_guiAppUi::HandleSymbian_ua_guiAppUiApplicationSpecificEventL( + TInt /* aType */, + const TWsEvent& /* anEvent */ ) + { + // TODO: implement applicationSpecificEvent event handler + } + +// [[[ begin generated function: do not modify +/** + * Execute the wait dialog for dlg_wait_init. This routine returns + * while the dialog is showing. It will be closed and destroyed when + * RemoveDlg_wait_initL() or the user selects the Cancel soft key. + * @param aOverrideText optional override text. When null the text configured + * in the UI Designer is used. + */ +void Csymbian_ua_guiAppUi::ExecuteDlg_wait_initLD( const TDesC* aOverrideText ) + { + iDlg_wait_init = new ( ELeave ) CAknWaitDialog( + reinterpret_cast< CEikDialog** >( &iDlg_wait_init ), EFalse ); + if ( aOverrideText != NULL ) + { + iDlg_wait_init->SetTextL( *aOverrideText ); + } + iDlg_wait_init->ExecuteLD( R_APPLICATION_DLG_WAIT_INIT ); + iDlg_wait_initCallback = new ( ELeave ) CProgressDialogCallback( + this, iDlg_wait_init, &Csymbian_ua_guiAppUi::HandleDlg_wait_initCanceledL ); + iDlg_wait_init->SetCallback( iDlg_wait_initCallback ); + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +/** + * Close and dispose of the wait dialog for dlg_wait_init + */ +void Csymbian_ua_guiAppUi::RemoveDlg_wait_initL() + { + if ( iDlg_wait_init != NULL ) + { + iDlg_wait_init->SetCallback( NULL ); + iDlg_wait_init->ProcessFinishedL(); // deletes the dialog + iDlg_wait_init = NULL; + } + delete iDlg_wait_initCallback; + iDlg_wait_initCallback = NULL; + + } +// ]]] end generated function + +/** + * Handle the canceled event. + */ +void Csymbian_ua_guiAppUi::HandleDlg_wait_initCanceledL( CAknProgressDialog* /* aDialog */ ) + { + // TODO: implement canceled event handler + + } + +void Csymbian_ua_guiAppUi::RunL() + { + RemoveDlg_wait_initL(); + iSymbian_ua_guiSettingItemListView->HandleCommandL(EAknSoftkeySave); + } diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiApplication.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiApplication.cpp new file mode 100644 index 0000000..2ccbbb2 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiApplication.cpp @@ -0,0 +1,96 @@ +/* $Id: symbian_ua_guiApplication.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated System Includes] +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated Includes] +#include "symbian_ua_guiApplication.h" +#include "symbian_ua_guiDocument.h" +#ifdef EKA2 +#include <eikstart.h> +#endif +// ]]] end generated region [Generated Includes] + + +// Needed by APS +TPtrC APP_UID = _L("EBD12EE4"); + +/** + * @brief Returns the application's UID (override from CApaApplication::AppDllUid()) + * @return UID for this application (KUidsymbian_ua_guiApplication) + */ +TUid Csymbian_ua_guiApplication::AppDllUid() const + { + return KUidsymbian_ua_guiApplication; + } + +/** + * @brief Creates the application's document (override from CApaApplication::CreateDocumentL()) + * @return Pointer to the created document object (Csymbian_ua_guiDocument) + */ +CApaDocument* Csymbian_ua_guiApplication::CreateDocumentL() + { + return Csymbian_ua_guiDocument::NewL( *this ); + } + +#ifdef EKA2 + +/** + * @brief Called by the application framework to construct the application object + * @return The application (Csymbian_ua_guiApplication) + */ +LOCAL_C CApaApplication* NewApplication() + { + return new Csymbian_ua_guiApplication; + } + +/** +* @brief This standard export is the entry point for all Series 60 applications +* @return error code + */ +GLDEF_C TInt E32Main() + { + TInt err; + + err = EikStart::RunApplication( NewApplication ); + + return err; + } + +#else // Series 60 2.x main DLL program code + +/** +* @brief This standard export constructs the application object. +* @return The application (Csymbian_ua_guiApplication) +*/ +EXPORT_C CApaApplication* NewApplication() + { + return new Csymbian_ua_guiApplication; + } + +/** +* @brief This standard export is the entry point for all Series 60 applications +* @return error code +*/ +GLDEF_C TInt E32Dll(TDllReason /*reason*/) + { + return KErrNone; + } + +#endif // EKA2 diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainer.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainer.cpp new file mode 100644 index 0000000..94fc98a --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainer.cpp @@ -0,0 +1,295 @@ +/* $Id: symbian_ua_guiContainer.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated System Includes] +#include <barsread.h> +#include <stringloader.h> +#include <eiklabel.h> +#include <eikenv.h> +#include <gdi.h> +#include <eikedwin.h> +#include <aknviewappui.h> +#include <eikappui.h> +#include <symbian_ua_gui.rsg> +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_guiContainer.h" +#include "symbian_ua_guiContainerView.h" +#include "symbian_ua_gui.hrh" +#include "symbian_ua_guiContainer.hrh" +#include "symbian_ua_guiSettingItemList.hrh" +// ]]] end generated region [Generated User Includes] + +// [[[ begin generated region: do not modify [Generated Constants] +// ]]] end generated region [Generated Constants] + +/** + * First phase of Symbian two-phase construction. Should not + * contain any code that could leave. + */ +CSymbian_ua_guiContainer::CSymbian_ua_guiContainer() + { + // [[[ begin generated region: do not modify [Generated Contents] + iLabel1 = NULL; + iEd_url = NULL; + iEd_info = NULL; + // ]]] end generated region [Generated Contents] + + } +/** + * Destroy child controls. + */ +CSymbian_ua_guiContainer::~CSymbian_ua_guiContainer() + { + // [[[ begin generated region: do not modify [Generated Contents] + delete iLabel1; + iLabel1 = NULL; + delete iEd_url; + iEd_url = NULL; + delete iEd_info; + iEd_info = NULL; + // ]]] end generated region [Generated Contents] + + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is not left on cleanup stack. + * @param aRect bounding rectangle + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return initialized instance of CSymbian_ua_guiContainer + */ +CSymbian_ua_guiContainer* CSymbian_ua_guiContainer::NewL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CSymbian_ua_guiContainer* self = CSymbian_ua_guiContainer::NewLC( + aRect, + aParent, + aCommandObserver ); + CleanupStack::Pop( self ); + return self; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is left on cleanup stack. + * @param aRect The rectangle for this window + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return new instance of CSymbian_ua_guiContainer + */ +CSymbian_ua_guiContainer* CSymbian_ua_guiContainer::NewLC( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CSymbian_ua_guiContainer* self = new ( ELeave ) CSymbian_ua_guiContainer(); + CleanupStack::PushL( self ); + self->ConstructL( aRect, aParent, aCommandObserver ); + return self; + } + +/** + * Construct the control (second phase). + * Creates a window to contain the controls and activates it. + * @param aRect bounding rectangle + * @param aCommandObserver command observer + * @param aParent owning parent, or NULL + */ +void CSymbian_ua_guiContainer::ConstructL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + if ( aParent == NULL ) + { + CreateWindowL(); + } + else + { + SetContainerWindowL( *aParent ); + } + iFocusControl = NULL; + iCommandObserver = aCommandObserver; + InitializeControlsL(); + SetRect( aRect ); + ActivateL(); + // [[[ begin generated region: do not modify [Post-ActivateL initializations] + // ]]] end generated region [Post-ActivateL initializations] + + } + +/** +* Return the number of controls in the container (override) +* @return count +*/ +TInt CSymbian_ua_guiContainer::CountComponentControls() const + { + return ( int ) ELastControl; + } + +/** +* Get the control with the given index (override) +* @param aIndex Control index [0...n) (limited by #CountComponentControls) +* @return Pointer to control +*/ +CCoeControl* CSymbian_ua_guiContainer::ComponentControl( TInt aIndex ) const + { + // [[[ begin generated region: do not modify [Generated Contents] + switch ( aIndex ) + { + case ELabel1: + return iLabel1; + case EEd_url: + return iEd_url; + case EEd_info: + return iEd_info; + } + // ]]] end generated region [Generated Contents] + + // handle any user controls here... + + return NULL; + } + +/** + * Handle resizing of the container. This implementation will lay out + * full-sized controls like list boxes for any screen size, and will layout + * labels, editors, etc. to the size they were given in the UI designer. + * This code will need to be modified to adjust arbitrary controls to + * any screen size. + */ +void CSymbian_ua_guiContainer::SizeChanged() + { + CCoeControl::SizeChanged(); + LayoutControls(); + // [[[ begin generated region: do not modify [Generated Contents] + + // ]]] end generated region [Generated Contents] + + } + +// [[[ begin generated function: do not modify +/** + * Layout components as specified in the UI Designer + */ +void CSymbian_ua_guiContainer::LayoutControls() + { + iLabel1->SetExtent( TPoint( 2, 23 ), TSize( 32, 28 ) ); + iEd_url->SetExtent( TPoint( 49, 25 ), TSize( 197, 28 ) ); + iEd_info->SetExtent( TPoint( 3, 78 ), TSize( 235, 143 ) ); + } +// ]]] end generated function + +/** + * Handle key events. + */ +TKeyResponse CSymbian_ua_guiContainer::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + // [[[ begin generated region: do not modify [Generated Contents] + + // ]]] end generated region [Generated Contents] + + if ( iFocusControl != NULL + && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) + { + return EKeyWasConsumed; + } + return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); + } + +// [[[ begin generated function: do not modify +/** + * Initialize each control upon creation. + */ +void CSymbian_ua_guiContainer::InitializeControlsL() + { + iLabel1 = new ( ELeave ) CEikLabel; + iLabel1->SetContainerWindowL( *this ); + { + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_LABEL1 ); + iLabel1->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + iEd_url = new ( ELeave ) CEikEdwin; + iEd_url->SetContainerWindowL( *this ); + { + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_ED_URL ); + iEd_url->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + { + HBufC* text = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_ED_URL_2 ); + iEd_url->SetTextL( text ); + CleanupStack::PopAndDestroy( text ); + } + iEd_info = new ( ELeave ) CEikEdwin; + iEd_info->SetContainerWindowL( *this ); + { + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_ED_INFO ); + iEd_info->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + { + HBufC* text = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_ED_INFO_2 ); + iEd_info->SetTextL( text ); + CleanupStack::PopAndDestroy( text ); + } + + iEd_url->SetFocus( ETrue ); + iFocusControl = iEd_url; + + } +// ]]] end generated function + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CSymbian_ua_guiContainer::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ESymbian_ua_guiContainerViewId ) )->ClientRect() ); + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * Draw container contents. + */ +void CSymbian_ua_guiContainer::Draw( const TRect& aRect ) const + { + // [[[ begin generated region: do not modify [Generated Contents] + CWindowGc& gc = SystemGc(); + gc.Clear( aRect ); + + // ]]] end generated region [Generated Contents] + + } + diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainerView.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainerView.cpp new file mode 100644 index 0000000..0fae4f6 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainerView.cpp @@ -0,0 +1,488 @@ +/* $Id: symbian_ua_guiContainerView.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated System Includes] +#include <aknviewappui.h> +#include <eikmenub.h> +#include <avkon.hrh> +#include <barsread.h> +#include <stringloader.h> +#include <eiklabel.h> +#include <eikenv.h> +#include <gdi.h> +#include <eikedwin.h> +#include <akncontext.h> +#include <akntitle.h> +#include <eikbtgpc.h> +#include <aknnotewrappers.h> +#include <aknquerydialog.h> +#include <symbian_ua_gui.rsg> +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_gui.hrh" +#include "symbian_ua_guiContainerView.h" +#include "symbian_ua_guiContainer.hrh" +#include "symbian_ua_guiSettingItemList.hrh" +#include "symbian_ua_guiContainer.h" +// ]]] end generated region [Generated User Includes] + +#include <utf.h> +#include "symbian_ua.h" + +// [[[ begin generated region: do not modify [Generated Constants] +// ]]] end generated region [Generated Constants] + +Csymbian_ua_guiContainerView *myinstance = NULL; +_LIT(KStCall, "Call"); +_LIT(KStHangUp, "Hang Up"); + +void on_info(const wchar_t* buf) +{ + TPtrC aBuf((const TUint16*)buf); + + if (myinstance) + myinstance->PutMessage(aBuf); +} + +void on_incoming_call(const wchar_t* caller_disp, const wchar_t* caller_uri) +{ + TBuf<512> buf; + TPtrC aDisp((const TUint16*)caller_disp); + TPtrC aUri((const TUint16*)caller_uri); + _LIT(KFormat, "Incoming call from %S, accept?"); + + buf.Format(KFormat, &aDisp); + if (Csymbian_ua_guiContainerView::RunQry_accept_callL(&buf) == EAknSoftkeyYes) + { + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + if (cba != NULL) { + TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp)); + cba->DrawDeferred(); + } + symbian_ua_answercall(); + } else { + symbian_ua_endcall(); + } +} + +void on_call_end(const wchar_t* reason) +{ + TPtrC aReason((const TUint16*)reason); + + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + if (cba != NULL) { + TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall)); + cba->DrawDeferred(); + } + + Csymbian_ua_guiContainerView::RunNote_infoL(&aReason); +} + +void on_reg_state(bool success) +{ + if (success) + Csymbian_ua_guiContainerView::RunNote_infoL(); + else + Csymbian_ua_guiContainerView::RunNote_warningL(); +} + +void on_unreg_state(bool success) +{ + TPtrC st_success(_L("Unregistration Success!")); + TPtrC st_failed(_L("Unregistration Failed!")); + + if (success) + Csymbian_ua_guiContainerView::RunNote_infoL(&st_success); + else + Csymbian_ua_guiContainerView::RunNote_warningL(&st_failed); +} + +void Csymbian_ua_guiContainerView::PutMessage(const TDesC &msg) + { + if (!iSymbian_ua_guiContainer) + return; + + CEikEdwin *obj_info = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_info); + + obj_info->SetTextL(&msg); + obj_info->DrawDeferred(); + } + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +Csymbian_ua_guiContainerView::Csymbian_ua_guiContainerView() + { + // [[[ begin generated region: do not modify [Generated Contents] + iSymbian_ua_guiContainer = NULL; + // ]]] end generated region [Generated Contents] + + } +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +Csymbian_ua_guiContainerView::~Csymbian_ua_guiContainerView() + { + // [[[ begin generated region: do not modify [Generated Contents] + delete iSymbian_ua_guiContainer; + iSymbian_ua_guiContainer = NULL; + // ]]] end generated region [Generated Contents] + + symbian_ua_set_info_callback(NULL); + myinstance = NULL; + } + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of Csymbian_ua_guiContainerView + */ +Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewL() + { + Csymbian_ua_guiContainerView* self = Csymbian_ua_guiContainerView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of Csymbian_ua_guiContainerView + */ +Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewLC() + { + Csymbian_ua_guiContainerView* self = new ( ELeave ) Csymbian_ua_guiContainerView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void Csymbian_ua_guiContainerView::ConstructL() + { + // [[[ begin generated region: do not modify [Generated Code] + BaseConstructL( R_SYMBIAN_UA_GUI_CONTAINER_SYMBIAN_UA_GUI_CONTAINER_VIEW ); + // ]]] end generated region [Generated Code] + + // add your own initialization code here + symbian_ua_info_cb_t cb; + Mem::FillZ(&cb, sizeof(cb)); + + cb.on_info = &on_info; + cb.on_incoming_call = &on_incoming_call; + cb.on_reg_state = &on_reg_state; + cb.on_unreg_state = &on_unreg_state; + cb.on_call_end = &on_call_end; + + symbian_ua_set_info_callback(&cb); + myinstance = this; + } + +/** + * @return The UID for this view + */ +TUid Csymbian_ua_guiContainerView::Id() const + { + return TUid::Uid( ESymbian_ua_guiContainerViewId ); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void Csymbian_ua_guiContainerView::HandleCommandL( TInt aCommand ) + { + // [[[ begin generated region: do not modify [Generated Code] + TBool commandHandled = EFalse; + switch ( aCommand ) + { // code to dispatch to the AknView's menu and CBA commands is generated here + + case ESymbian_ua_guiContainerViewControlPaneRightId: + commandHandled = CallSoftKeyPressedL( aCommand ); + break; + case ESymbian_ua_guiContainerViewSettingMenuItemCommand: + commandHandled = HandleSettingMenuItemSelectedL( aCommand ); + break; + default: + break; + } + + + if ( !commandHandled ) + { + + if ( aCommand == ESymbian_ua_guiContainerViewControlPaneRightId ) + { + AppUi()->HandleCommandL( EEikCmdExit ); + } + + } + // ]]] end generated region [Generated Code] + + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void Csymbian_ua_guiContainerView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + // [[[ begin generated region: do not modify [Generated Contents] + SetupStatusPaneL(); + + CEikButtonGroupContainer* cba = AppUi()->Cba(); + if ( cba != NULL ) + { + cba->MakeVisible( EFalse ); + } + + if ( iSymbian_ua_guiContainer == NULL ) + { + iSymbian_ua_guiContainer = CSymbian_ua_guiContainer::NewL( ClientRect(), NULL, this ); + iSymbian_ua_guiContainer->SetMopParent( this ); + AppUi()->AddToStackL( *this, iSymbian_ua_guiContainer ); + } + // ]]] end generated region [Generated Contents] + + cba = CEikButtonGroupContainer::Current(); + if (cba != NULL) { + if (symbian_ua_anycall()) + cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp); + else + cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall); + } + + } + +/** + */ +void Csymbian_ua_guiContainerView::DoDeactivate() + { + // [[[ begin generated region: do not modify [Generated Contents] + CleanupStatusPane(); + + CEikButtonGroupContainer* cba = AppUi()->Cba(); + if ( cba != NULL ) + { + cba->MakeVisible( ETrue ); + cba->DrawDeferred(); + } + + if ( iSymbian_ua_guiContainer != NULL ) + { + AppUi()->RemoveFromViewStack( *this, iSymbian_ua_guiContainer ); + delete iSymbian_ua_guiContainer; + iSymbian_ua_guiContainer = NULL; + } + // ]]] end generated region [Generated Contents] + + } + +// [[[ begin generated function: do not modify +void Csymbian_ua_guiContainerView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_TITLE_RESOURCE ); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +void Csymbian_ua_guiContainerView::CleanupStatusPane() + { + } +// ]]] end generated function + +/** + * Handle status pane size change for this view (override) + */ +void Csymbian_ua_guiContainerView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + +/** + * Handle the rightSoftKeyPressed event. + * @return ETrue if the command was handled, EFalse if not + */ +TBool Csymbian_ua_guiContainerView::CallSoftKeyPressedL( TInt aCommand ) + { + CEikEdwin *obj_url = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_url); + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + + if (symbian_ua_anycall()) { + symbian_ua_endcall(); + return ETrue; + } + + PutMessage(_L("Making call...")); + if ( cba != NULL ) { + cba->SetCommandL(aCommand, KStHangUp); + cba->DrawDeferred(); + } + + + TUint8 url[256]; + TPtr8 aUrl(url, 256); + + HBufC *buf = obj_url->GetTextInHBufL(); + CnvUtfConverter::ConvertFromUnicodeToUtf8(aUrl, *buf); + delete buf; + + if (symbian_ua_makecall((char *)aUrl.PtrZ()) != 0) { + PutMessage(_L("Making call failed!")); + if ( cba != NULL ) { + cba->SetCommandL(aCommand, KStCall); + cba->DrawDeferred(); + } + } + + return ETrue; + } + +/** + * Handle the selected event. + * @param aCommand the command id invoked + * @return ETrue if the command was handled, EFalse if not + */ +TBool Csymbian_ua_guiContainerView::HandleSettingMenuItemSelectedL( TInt aCommand ) + { + AppUi()->ActivateLocalViewL(TUid::Uid(ESymbian_ua_guiSettingItemListViewId)); + return ETrue; + } + +// [[[ begin generated function: do not modify +/** + * Show the popup note for note_error + * @param aOverrideText optional override text + */ +void Csymbian_ua_guiContainerView::RunNote_errorL( const TDesC* aOverrideText ) + { + CAknErrorNote* note = new ( ELeave ) CAknErrorNote(); + if ( aOverrideText == NULL ) + { + HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_ERROR ); + note->ExecuteLD( *noteText ); + CleanupStack::PopAndDestroy( noteText ); + } + else + { + note->ExecuteLD( *aOverrideText ); + } + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +/** + * Show the popup note for note_info + * @param aOverrideText optional override text + */ +void Csymbian_ua_guiContainerView::RunNote_infoL( const TDesC* aOverrideText ) + { + CAknInformationNote* note = new ( ELeave ) CAknInformationNote(); + if ( aOverrideText == NULL ) + { + HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_INFO ); + note->ExecuteLD( *noteText ); + CleanupStack::PopAndDestroy( noteText ); + } + else + { + note->ExecuteLD( *aOverrideText ); + } + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +/** + * Show the popup note for note_warning + * @param aOverrideText optional override text + */ +void Csymbian_ua_guiContainerView::RunNote_warningL( const TDesC* aOverrideText ) + { + CAknWarningNote* note = new ( ELeave ) CAknWarningNote(); + if ( aOverrideText == NULL ) + { + HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_WARNING ); + note->ExecuteLD( *noteText ); + CleanupStack::PopAndDestroy( noteText ); + } + else + { + note->ExecuteLD( *aOverrideText ); + } + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +/** + * Show the popup dialog for qry_accept_call + * @param aOverrideText optional override text + * @return EAknSoftkeyYes (left soft key id) or 0 + */ +TInt Csymbian_ua_guiContainerView::RunQry_accept_callL( const TDesC* aOverrideText ) + { + + CAknQueryDialog* queryDialog = CAknQueryDialog::NewL(); + + if ( aOverrideText != NULL ) + { + queryDialog->SetPromptL( *aOverrideText ); + } + return queryDialog->ExecuteLD( R_SYMBIAN_UA_GUI_CONTAINER_QRY_ACCEPT_CALL ); + } +// ]]] end generated function + diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiDocument.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiDocument.cpp new file mode 100644 index 0000000..906577c --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiDocument.cpp @@ -0,0 +1,67 @@ +/* $Id: symbian_ua_guiDocument.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_guiDocument.h" +#include "symbian_ua_guiAppUi.h" +// ]]] end generated region [Generated User Includes] + +/** + * @brief Constructs the document class for the application. + * @param anApplication the application instance + */ +Csymbian_ua_guiDocument::Csymbian_ua_guiDocument( CEikApplication& anApplication ) + : CAknDocument( anApplication ) + { + } + +/** + * @brief Completes the second phase of Symbian object construction. + * Put initialization code that could leave here. + */ +void Csymbian_ua_guiDocument::ConstructL() + { + } + +/** + * Symbian OS two-phase constructor. + * + * Creates an instance of Csymbian_ua_guiDocument, constructs it, and + * returns it. + * + * @param aApp the application instance + * @return the new Csymbian_ua_guiDocument + */ +Csymbian_ua_guiDocument* Csymbian_ua_guiDocument::NewL( CEikApplication& aApp ) + { + Csymbian_ua_guiDocument* self = new ( ELeave ) Csymbian_ua_guiDocument( aApp ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +/** + * @brief Creates the application UI object for this document. + * @return the new instance + */ +CEikAppUi* Csymbian_ua_guiDocument::CreateAppUiL() + { + return new ( ELeave ) Csymbian_ua_guiAppUi; + } + diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemList.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemList.cpp new file mode 100644 index 0000000..48f86d3 --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemList.cpp @@ -0,0 +1,433 @@ +/* $Id: symbian_ua_guiSettingItemList.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +// [[[ begin generated region: do not modify [Generated System Includes] +#include <avkon.hrh> +#include <avkon.rsg> +#include <eikmenup.h> +#include <aknappui.h> +#include <eikcmobs.h> +#include <barsread.h> +#include <stringloader.h> +#include <gdi.h> +#include <eikedwin.h> +#include <eikenv.h> +#include <eikseced.h> +#include <aknpopupfieldtext.h> +#include <eikappui.h> +#include <aknviewappui.h> +#include <akntextsettingpage.h> +#include <symbian_ua_gui.rsg> +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_guiSettingItemList.h" +#include "Symbian_ua_guiSettingItemListSettings.h" +#include "symbian_ua_guiSettingItemList.hrh" +#include "symbian_ua_gui.hrh" +#include "symbian_ua_guiSettingItemListView.h" +// ]]] end generated region [Generated User Includes] + + +#include <s32stor.h> +#include <s32file.h> + + +// [[[ begin generated region: do not modify [Generated Constants] +// ]]] end generated region [Generated Constants] + + +_LIT(KtxDicFileName ,"settings.ini" ); + +const TInt KRegistrar = 2; +const TInt KUsername = 3; +const TInt KPassword = 4; +const TInt KStunServer = 5; +const TInt KSrtp = 6; +const TInt KIce = 7; + +/** + * Construct the CSymbian_ua_guiSettingItemList instance + * @param aCommandObserver command observer + */ +CSymbian_ua_guiSettingItemList::CSymbian_ua_guiSettingItemList( + TSymbian_ua_guiSettingItemListSettings& aSettings, + MEikCommandObserver* aCommandObserver ) + : iSettings( aSettings ), iCommandObserver( aCommandObserver ) + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } +/** + * Destroy any instance variables + */ +CSymbian_ua_guiSettingItemList::~CSymbian_ua_guiSettingItemList() + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * Handle system notification that the container's size has changed. + */ +void CSymbian_ua_guiSettingItemList::SizeChanged() + { + if ( ListBox() ) + { + ListBox()->SetRect( Rect() ); + } + } + +/** + * Create one setting item at a time, identified by id. + * CAknSettingItemList calls this method and takes ownership + * of the returned value. The CAknSettingItem object owns + * a reference to the underlying data, which EditItemL() uses + * to edit and store the value. + */ +CAknSettingItem* CSymbian_ua_guiSettingItemList::CreateSettingItemL( TInt aId ) + { + switch ( aId ) + { + // [[[ begin generated region: do not modify [Initializers] + case ESymbian_ua_guiSettingItemListViewEd_registrar: + { + CAknTextSettingItem* item = new ( ELeave ) + CAknTextSettingItem( + aId, + iSettings.Ed_registrar() ); + item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed); + return item; + } + case ESymbian_ua_guiSettingItemListViewEd_user: + { + CAknTextSettingItem* item = new ( ELeave ) + CAknTextSettingItem( + aId, + iSettings.Ed_user() ); + item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed); + return item; + } + case ESymbian_ua_guiSettingItemListViewEd_password: + { + CAknPasswordSettingItem* item = new ( ELeave ) + CAknPasswordSettingItem( + aId, + CAknPasswordSettingItem::EAlpha, + iSettings.Ed_password() ); + item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed); + return item; + } + case ESymbian_ua_guiSettingItemListViewB_srtp: + { + CAknBinaryPopupSettingItem* item = new ( ELeave ) + CAknBinaryPopupSettingItem( + aId, + iSettings.B_srtp() ); + item->SetHidden( ETrue ); + return item; + } + case ESymbian_ua_guiSettingItemListViewB_ice: + { + CAknBinaryPopupSettingItem* item = new ( ELeave ) + CAknBinaryPopupSettingItem( + aId, + iSettings.B_ice() ); + item->SetHidden( ETrue ); + return item; + } + case ESymbian_ua_guiSettingItemListViewEd_stun_server: + { + CAknTextSettingItem* item = new ( ELeave ) + CAknTextSettingItem( + aId, + iSettings.Ed_stun_server() ); + item->SetHidden( ETrue ); + return item; + } + // ]]] end generated region [Initializers] + + } + + return NULL; + } + +/** + * Edit the setting item identified by the given id and store + * the changes into the store. + * @param aIndex the index of the setting item in SettingItemArray() + * @param aCalledFromMenu true: a menu item invoked editing, thus + * always show the edit page and interactively edit the item; + * false: change the item in place if possible, else show the edit page + */ +void CSymbian_ua_guiSettingItemList::EditItemL ( TInt aIndex, TBool aCalledFromMenu ) + { + CAknSettingItem* item = ( *SettingItemArray() )[aIndex]; + switch ( item->Identifier() ) + { + // [[[ begin generated region: do not modify [Editing Started Invoker] + // ]]] end generated region [Editing Started Invoker] + + } + + CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); + + TBool storeValue = ETrue; + switch ( item->Identifier() ) + { + // [[[ begin generated region: do not modify [Editing Stopped Invoker] + // ]]] end generated region [Editing Stopped Invoker] + + } + + if ( storeValue ) + { + item->StoreL(); + SaveSettingValuesL(); + } + } +/** + * Handle the "Change" option on the Options menu. This is an + * alternative to the Selection key that forces the settings page + * to come up rather than changing the value in place (if possible). + */ +void CSymbian_ua_guiSettingItemList::ChangeSelectedItemL() + { + if ( ListBox()->CurrentItemIndex() >= 0 ) + { + EditItemL( ListBox()->CurrentItemIndex(), ETrue ); + } + } + +/** + * Load the initial contents of the setting items. By default, + * the setting items are populated with the default values from + * the design. You can override those values here. + * <p> + * Note: this call alone does not update the UI. + * LoadSettingsL() must be called afterwards. + */ +void CSymbian_ua_guiSettingItemList::LoadSettingValuesL() + { + // load values into iSettings + + TFileName path; + TFileName pathWithoutDrive; + CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive ); + + // Extract drive letter into appDrive: +#ifdef __WINS__ + path.Copy( _L("c:") ); +#else + RProcess process; + path.Copy( process.FileName().Left(2) ); +#endif + + path.Append( pathWithoutDrive ); + path.Append( KtxDicFileName ); + + TFindFile AufFolder(CCoeEnv::Static()->FsSession()); + if(KErrNone == AufFolder.FindByDir(path, KNullDesC)) + { + CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),AufFolder.File(), TUid::Uid(1)); + TUid FileUid; + + FileUid.iUid = KRegistrar; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + in >> iSettings.Ed_registrar(); + CleanupStack::PopAndDestroy(1);// in + } + + FileUid.iUid = KUsername; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + in >> iSettings.Ed_user(); + CleanupStack::PopAndDestroy(1);// in + } + + FileUid.iUid = KPassword; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + in >> iSettings.Ed_password(); + CleanupStack::PopAndDestroy(1);// in + } + + FileUid.iUid = KStunServer; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + in >> iSettings.Ed_stun_server(); + CleanupStack::PopAndDestroy(1);// in + } + + FileUid.iUid = KSrtp; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + iSettings.SetB_srtp((TBool)in.ReadInt32L()); + CleanupStack::PopAndDestroy(1);// in + } + + FileUid.iUid = KIce; + if(MyDStore->IsPresentL(FileUid)) + { + RDictionaryReadStream in; + in.OpenLC(*MyDStore,FileUid); + iSettings.SetB_ice((TBool)in.ReadInt32L()); + CleanupStack::PopAndDestroy(1);// in + } + + CleanupStack::PopAndDestroy(1);// Store + } + + } + +/** + * Save the contents of the setting items. Note, this is called + * whenever an item is changed and stored to the model, so it + * may be called multiple times or not at all. + */ +void CSymbian_ua_guiSettingItemList::SaveSettingValuesL() + { + // store values from iSettings + + TFileName path; + TFileName pathWithoutDrive; + CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive ); + + // Extract drive letter into appDrive: +#ifdef __WINS__ + path.Copy( _L("c:") ); +#else + RProcess process; + path.Copy( process.FileName().Left(2) ); + + if(path.Compare(_L("c")) || path.Compare(_L("C"))) + CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveC); + else if(path.Compare(_L("e")) || path.Compare(_L("E"))) + CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveE); +#endif + + path.Append( pathWithoutDrive ); + path.Append( KtxDicFileName ); + + TFindFile AufFolder(CCoeEnv::Static()->FsSession()); + if(KErrNone == AufFolder.FindByDir(path, KNullDesC)) + { + User::LeaveIfError(CCoeEnv::Static()->FsSession().Delete(AufFolder.File())); + } + + CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),path, TUid::Uid(1)); + + TUid FileUid = {0x0}; + + FileUid.iUid = KRegistrar; + RDictionaryWriteStream out1; + out1.AssignLC(*MyDStore,FileUid); + out1 << iSettings.Ed_registrar(); + out1.CommitL(); + CleanupStack::PopAndDestroy(1);// out2 + + FileUid.iUid = KUsername; + RDictionaryWriteStream out2; + out2.AssignLC(*MyDStore,FileUid); + out2 << iSettings.Ed_user(); + out2.CommitL(); + CleanupStack::PopAndDestroy(1);// out2 + + FileUid.iUid = KPassword; + RDictionaryWriteStream out3; + out3.AssignLC(*MyDStore,FileUid); + out3 << iSettings.Ed_password(); + out3.CommitL(); + CleanupStack::PopAndDestroy(1);// out2 + + FileUid.iUid = KStunServer; + RDictionaryWriteStream out4; + out4.AssignLC(*MyDStore,FileUid); + out4 << iSettings.Ed_stun_server(); + out4.CommitL(); + CleanupStack::PopAndDestroy(1);// out2 + + FileUid.iUid = KSrtp; + RDictionaryWriteStream out5; + out5.AssignLC(*MyDStore,FileUid); + out5.WriteInt32L(iSettings.B_srtp()); + out5.CommitL(); + CleanupStack::PopAndDestroy(1);// out1 + + FileUid.iUid = KIce; + RDictionaryWriteStream out6; + out6.AssignLC(*MyDStore,FileUid); + out6.WriteInt32L(iSettings.B_ice()); + out6.CommitL(); + CleanupStack::PopAndDestroy(1);// out1 + + MyDStore->CommitL(); + CleanupStack::PopAndDestroy(1);// Store + + } + + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CSymbian_ua_guiSettingItemList::HandleResourceChange( TInt aType ) + { + CAknSettingItemList::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ESymbian_ua_guiSettingItemListViewId ) )->ClientRect() ); + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * Handle key event (override) + * @param aKeyEvent key event + * @param aType event code + * @return EKeyWasConsumed if the event was handled, else EKeyWasNotConsumed + */ +TKeyResponse CSymbian_ua_guiSettingItemList::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + if ( aKeyEvent.iCode == EKeyLeftArrow + || aKeyEvent.iCode == EKeyRightArrow ) + { + // allow the tab control to get the arrow keys + return EKeyWasNotConsumed; + } + + return CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType ); + } + diff --git a/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemListView.cpp b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemListView.cpp new file mode 100644 index 0000000..aa8155d --- /dev/null +++ b/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemListView.cpp @@ -0,0 +1,295 @@ +/* $Id: symbian_ua_guiSettingItemListView.cpp 3550 2011-05-05 05:33:27Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +// [[[ begin generated region: do not modify [Generated System Includes] +#include <aknviewappui.h> +#include <eikmenub.h> +#include <avkon.hrh> +#include <akncontext.h> +#include <akntitle.h> +#include <stringloader.h> +#include <barsread.h> +#include <eikbtgpc.h> +#include <symbian_ua_gui.rsg> +// ]]] end generated region [Generated System Includes] + +// [[[ begin generated region: do not modify [Generated User Includes] +#include "symbian_ua_gui.hrh" +#include "symbian_ua_guiSettingItemListView.h" +#include "symbian_ua_guiContainer.hrh" +#include "symbian_ua_guiSettingItemList.hrh" +#include "symbian_ua_guiSettingItemList.h" +// ]]] end generated region [Generated User Includes] + +#include "symbian_ua.h" + +// [[[ begin generated region: do not modify [Generated Constants] +// ]]] end generated region [Generated Constants] + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +Csymbian_ua_guiSettingItemListView::Csymbian_ua_guiSettingItemListView() + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +Csymbian_ua_guiSettingItemListView::~Csymbian_ua_guiSettingItemListView() + { + // [[[ begin generated region: do not modify [Generated Contents] + // ]]] end generated region [Generated Contents] + + } + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of Csymbian_ua_guiSettingItemListView + */ +Csymbian_ua_guiSettingItemListView* Csymbian_ua_guiSettingItemListView::NewL() + { + Csymbian_ua_guiSettingItemListView* self = Csymbian_ua_guiSettingItemListView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of Csymbian_ua_guiSettingItemListView + */ +Csymbian_ua_guiSettingItemListView* Csymbian_ua_guiSettingItemListView::NewLC() + { + Csymbian_ua_guiSettingItemListView* self = new ( ELeave ) Csymbian_ua_guiSettingItemListView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void Csymbian_ua_guiSettingItemListView::ConstructL() + { + // [[[ begin generated region: do not modify [Generated Code] + BaseConstructL( R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_VIEW ); + // ]]] end generated region [Generated Code] + + // add your own initialization code here + } + +/** + * @return The UID for this view + */ +TUid Csymbian_ua_guiSettingItemListView::Id() const + { + return TUid::Uid( ESymbian_ua_guiSettingItemListViewId ); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void Csymbian_ua_guiSettingItemListView::HandleCommandL( TInt aCommand ) + { + // [[[ begin generated region: do not modify [Generated Code] + TBool commandHandled = EFalse; + switch ( aCommand ) + { // code to dispatch to the AknView's menu and CBA commands is generated here + + case EAknSoftkeySave: + commandHandled = HandleControlPaneRightSoftKeyPressedL( aCommand ); + break; + case ESymbian_ua_guiSettingItemListViewMenuItem1Command: + commandHandled = HandleChangeSelectedSettingItemL( aCommand ); + break; + default: + break; + } + + + if ( !commandHandled ) + { + + } + // ]]] end generated region [Generated Code] + + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void Csymbian_ua_guiSettingItemListView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + // [[[ begin generated region: do not modify [Generated Contents] + SetupStatusPaneL(); + + CEikButtonGroupContainer* cba = AppUi()->Cba(); + if ( cba != NULL ) + { + cba->MakeVisible( EFalse ); + } + + if ( iSymbian_ua_guiSettingItemList == NULL ) + { + iSettings = TSymbian_ua_guiSettingItemListSettings::NewL(); + iSymbian_ua_guiSettingItemList = new ( ELeave ) CSymbian_ua_guiSettingItemList( *iSettings, this ); + iSymbian_ua_guiSettingItemList->SetMopParent( this ); + iSymbian_ua_guiSettingItemList->ConstructFromResourceL( R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_SYMBIAN_UA_GUI_SETTING_ITEM_LIST ); + iSymbian_ua_guiSettingItemList->ActivateL(); + iSymbian_ua_guiSettingItemList->LoadSettingValuesL(); + iSymbian_ua_guiSettingItemList->LoadSettingsL(); + AppUi()->AddToStackL( *this, iSymbian_ua_guiSettingItemList ); + } + // ]]] end generated region [Generated Contents] + + } + +/** + */ +void Csymbian_ua_guiSettingItemListView::DoDeactivate() + { + // [[[ begin generated region: do not modify [Generated Contents] + CleanupStatusPane(); + + CEikButtonGroupContainer* cba = AppUi()->Cba(); + if ( cba != NULL ) + { + cba->MakeVisible( ETrue ); + cba->DrawDeferred(); + } + + if ( iSymbian_ua_guiSettingItemList != NULL ) + { + AppUi()->RemoveFromStack( iSymbian_ua_guiSettingItemList ); + delete iSymbian_ua_guiSettingItemList; + iSymbian_ua_guiSettingItemList = NULL; + delete iSettings; + iSettings = NULL; + } + // ]]] end generated region [Generated Contents] + + } + +// [[[ begin generated function: do not modify +void Csymbian_ua_guiSettingItemListView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_SETTING_ITEM_LIST_TITLE_RESOURCE ); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + + } +// ]]] end generated function + +// [[[ begin generated function: do not modify +void Csymbian_ua_guiSettingItemListView::CleanupStatusPane() + { + } +// ]]] end generated function + +/** + * Handle status pane size change for this view (override) + */ +void Csymbian_ua_guiSettingItemListView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + +/** + * Handle the selected event. + * @param aCommand the command id invoked + * @return ETrue if the command was handled, EFalse if not + */ +TBool Csymbian_ua_guiSettingItemListView::HandleChangeSelectedSettingItemL( TInt aCommand ) + { + iSymbian_ua_guiSettingItemList->ChangeSelectedItemL(); + return ETrue; + } + +/** + * Handle the rightSoftKeyPressed event. + * @return ETrue if the command was handled, EFalse if not + */ +TBool Csymbian_ua_guiSettingItemListView::HandleControlPaneRightSoftKeyPressedL( TInt aCommand ) + { + TUint8 domain[256] = {0}; + TPtr8 cDomain(domain, sizeof(domain)); + TUint8 user[64] = {0}; + TPtr8 cUser(user, sizeof(user)); + TUint8 pass[64] = {0}; + TPtr8 cPass(pass, sizeof(pass)); + + cDomain.Copy(iSettings->Ed_registrar()); + cUser.Copy(iSettings->Ed_user()); + cPass.Copy(iSettings->Ed_password()); + symbian_ua_set_account((char*)domain, (char*)user, (char*)pass, false, false); + + AppUi()->ActivateLocalViewL(TUid::Uid(ESymbian_ua_guiContainerViewId)); + return ETrue; + } + +/** + * Handle the selected event. + * @param aCommand the command id invoked + * @return ETrue if the command was handled, EFalse if not + */ +TBool Csymbian_ua_guiSettingItemListView::HandleCancelMenuItemSelectedL( TInt aCommand ) + { + AppUi()->ActivateLocalViewL(TUid::Uid(ESymbian_ua_guiContainerViewId)); + return ETrue; + } + |