From: HyungKyu Song Date: Fri, 15 Feb 2013 15:53:31 +0000 (+0900) Subject: Tizen 2.0 Release X-Git-Tag: accepted/tizen_2.0/20130215.202321 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Faccepted%2Ftizen_2.0%2F20130215.202321;p=apps%2Fosp%2FPhone.git Tizen 2.0 Release --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c4f0386 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,44 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# Target name and PKGID +## TODO : set application name and ID +SET(this_target Phone) +SET(PKGID zktdpemtmw) + +# include directory +INCLUDE_DIRECTORIES( + /usr/include/glib-2.0 + /usr/lib/glib-2.0/include + /usr/include/osp + /usr/include/vconf + /usr/include/media + /usr/include/telephony-client + /usr/include/contacts-svc + inc + ) + +# Source files +FILE(GLOB ${this_target}_SOURCE_FILES + src/*.cpp +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") + + +# Create executable +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") +ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES}) + +# Set link libraries and link options +## TODO : add more link libraries and options +TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp osp-appfw osp-uifw osp-social osp-messaging osp-media osp-image osp-image-core) +TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib capi-media-sound-manager SLP-tapi vconf contacts-service2) +TARGET_LINK_LIBRARIES(${this_target} -Xlinker --allow-shlib-undefined -pthread -pie) + +# Copy info, data, res, and icons directories +INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${PKGID}/bin) + +# Copy resource +INSTALL(FILES ${CMAKE_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${PKGID}/info) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ../usr/apps/${PKGID}) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/shared DESTINATION ../usr/apps/${PKGID}) diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..9ec42be --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE.Flora file for Flora License, Version 1 terms and conditions. \ No newline at end of file diff --git a/inc/PhnActiveCallForm.h b/inc/PhnActiveCallForm.h new file mode 100644 index 0000000..39abb8a --- /dev/null +++ b/inc/PhnActiveCallForm.h @@ -0,0 +1,129 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnActiveCallForm.h + * @brief This is the header file for the %ActiveCallForm class. + * + * This header file contains the declarations for %ActiveCallForm class. + */ +#ifndef _PHN_ACTIVE_CALL_FORM_H_ +#define _PHN_ACTIVE_CALL_FORM_H_ + +#include +#include +#include "PhnBaseForm.h" + +class CallButtonsPanel; +class DtmfKeyPadPanel; +class CallInfo; + +/** + * @class ActiveCallForm + * @brief This class presents a form based UI for dialing call, active call, conference call, + * single active call, multiple active call scenarios. + * + */ +class ActiveCallForm + : public BaseForm + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + ActiveCallForm(FormType formType); + virtual ~ActiveCallForm(void); + //From BaseForm + virtual void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + // Handle the call swap notification in multiple call screen + void HandleCallSwapN(Tizen::Base::Collection::IList* pCallList); + +private: + // Create the call buttons panel and add to form + result InitializeCallButtonsPanel(void); + // Set the correct bitmaps and action listeners for swap button + void InitializeSwapButton(void); + // Set the action listener for manage conf call button + void InitializeManageConfCallButton(void); + // Set the correct bitmaps and action listeners for hold button + void InitializeHoldButton(void); + // Set the state of the hold button according to call state + void SetHoldButtonStatus(bool toHoldCall); + // This function is used to fetch person details using phone number. + void ShowPersonDetails(const Tizen::Base::String& phoneNumber, const Tizen::Base::String& contactLblName, const Tizen::Base::String& nameLblName, bool isSecondCaller, CallInfo* pCallInfo); + // Method to show phone number on screen for all calls except conference call. + void ShowPhoneNumber(const Tizen::Base::String& phoneNumber, const Tizen::Base::String& contactLblName); + // Method to show caller name for all calls. + void ShowCallerName(const Tizen::Base::String& callerName, const Tizen::Base::String& nameLblName); + // This function draws the caller's photo onto screen. + void ShowCallerPhoto(Tizen::Graphics::Bitmap* pPhotoId, bool isSecondCaller); + //This function is used to show small Thumbnail size photo of caller. + void ShowCallersPhotoThumbnail(const Tizen::Graphics::Bitmap& pPhotoId); + // Method to show call duration/state(held) for call in progress + void ShowTimerInfo(const Tizen::Base::String& timerLblName, bool isOnHold, long long startTime = 0); + // Method to set the show state of all the labels when DTMF keypad is launched + void SetShowStateOnKeypad(bool showState); + // Method to populate the list shown on "More" option + void CreateMoreOptionsMenuList(void); + // Method to destroy the list shown on "More" option + void DestroyMoreOptionsMenuList(void); + //Used to Show DTMF keypad + void ShowDTMFKeypad(void); + //Used to hide DTMF Keypad + void HideDTMFKeypad(void); + //Used to show text in text field + void SetTextToDTMFTextField(const Tizen::Base::String& dtmfStr); + + //From IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + + //From IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + +private: + //Start time for Active call + long long __activeCallStartTime; + //Timer used to show call time + Tizen::Base::Runtime::Timer* __pActiveCallTimer; + //Custom Buttons Panel + CallButtonsPanel* __pCallButtonsPanel; + DtmfKeyPadPanel* __pDTMFKeypad; + //Option Menu List for conference call + Tizen::Ui::Controls::ListView* __pMoreOptionsList; + Tizen::Ui::Controls::Label* __pMoreOptionsListAnchor; + Tizen::Ui::Controls::Label* __pSmallPhotoLabel; + CallInfo* __pActiveCallInfo; + CallInfo* __pHeldCallInfo; +}; + +#endif //_PHN_ACTIVE_CALL_FORM_H_ diff --git a/inc/PhnAppUtility.h b/inc/PhnAppUtility.h new file mode 100644 index 0000000..f746bde --- /dev/null +++ b/inc/PhnAppUtility.h @@ -0,0 +1,67 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnAppUtility.h + * @brief This is the header file for the %AppUtility class. + * + * This header file contains the declarations for %AppUtility class. + */ +#ifndef _PHN_APP_UTILITY_H_ +#define _PHN_APP_UTILITY_H_ + +#include +#include + +enum KeypadTextPosition +{ + POSITION_LEFT, + POSITION_RIGHT, + POSITION_CENTER, + POSITION_TOP_LEFT, + POSITION_TOP_CENTER, + POSITION_BOTTOM_LEFT, + POSITION_BOTTOM_CENTER +}; + +/** + * @class AppUtility + * @brief This class provides common functionalities across application through static member functions. + * Its instance cannot needed. + * + */ +class AppUtility +{ +private: + AppUtility(void); + AppUtility(const AppUtility& obj); + virtual ~AppUtility(void); + +public: + /** + * Fetches the String from resources based on + * resource id provided by "stringId". + */ + static Tizen::Base::String GetResourceString(const Tizen::Base::String& stringId); + + /** + * Fetches the Bitmap from resources and + * scales it to specified width and height, if provided. + */ + static Tizen::Graphics::Bitmap* GetBitmapFromResourcesN(const Tizen::Base::String& imagePath, int imgWidth = 0, int imgHeight = 0); +}; + +#endif // _PHN_APP_UTILITY_H_ diff --git a/inc/PhnBaseForm.h b/inc/PhnBaseForm.h new file mode 100644 index 0000000..eecec1c --- /dev/null +++ b/inc/PhnBaseForm.h @@ -0,0 +1,92 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnBaseForm.h + * @brief This is the header file for the %BaseForm class. + * + * This header file contains the declarations for %BaseForm class. + */ +#ifndef _PHN_BASE_FORM_H_ +#define _PHN_BASE_FORM_H_ + +#include +#include +#include +#include +#include "PhnITelephonyEventListener.h" +#include "PhnErrorMsgPopup.h" + +class CallInfo; +class CallPresentationModel; + +enum FormType +{ + FORMTYPE_OUTGOINGCALL, + FORMTYPE_EMERGENCYOUTGOINGCALL, + FORMTYPE_INCOMINGCALL, + FORMTYPE_ACTIVECALL, + FORMTYPE_EMERGENCYACTIVECALL, + FORMTYPE_ACTIVECONFCALL, + FORMTYPE_CONFCALLLIST, + FORMTYPE_ENDCALL, + FORMTYPE_MULTIPLECALLS, +}; + +/** + * @class BaseForm + * @brief This class presents a form based UI all call scenarios and provides + * common functionalities in all call forms. + * + */ +class BaseForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IOrientationEventListener + , public ITelephonyEventListener + , public IPopupClosedEventListener +{ +public: + BaseForm(FormType formType); + virtual ~BaseForm(void); + virtual void Initialize(void) = 0; + +public: + //Used to add user specific code after controls are added to form + virtual result OnInitializing(void); + + //From 'Tizen::Ui::IActionEventListener' + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //Event Listener methods from ITelephonyEventListener + virtual void HandleCallConnected(Tizen::Base::Collection::IListT& pCallList); + virtual void HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT& pCallList); + virtual void HandleConferenceCall(CallInfo& pCallInfo); + virtual void HandleIncomingCall(CallInfo& pCallInfo); + virtual void HandleCallSwapOccured(Tizen::Base::Collection::IListT& pCallList); + virtual void HandleConferenceChange(void); + virtual void HandleTelephonyError(int errorCode); + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + //From IOrientationEventListener + virtual void OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus); +protected: + FormType __formType; + //Ownership + ErrorMsgPopup* __pErrorMsgPopup; + CallPresentationModel* __pCallPresentor; +}; + +#endif // _PHN_BASE_FORM_H_ diff --git a/inc/PhnCallButtonsPanel.h b/inc/PhnCallButtonsPanel.h new file mode 100644 index 0000000..daeb81b --- /dev/null +++ b/inc/PhnCallButtonsPanel.h @@ -0,0 +1,107 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallButtonsPanel.h + * @brief This is the header file for the %CallButtonsPanel class. + * + * This header file contains the declarations for %CallButtonsPanel class. + */ +#ifndef _PHN_CALL_BUTTONS_PANEL_H_ +#define _PHN_CALL_BUTTONS_PANEL_H_ + +#include +#include +#include +#include "PhnBaseForm.h" +#include "PhnTypes.h" + +/** + * @class CallButtonsPanel + * @brief This class presents a panel based UI for keypads used in active call + * and end call scenarios. + * + */ +class CallButtonsPanel + : public Tizen::Ui::Controls::Panel +{ +private: + enum ButtonState + { + BTN_NORMAL, + BTN_PRESS, + BTN_DIM, + }; + +public: + CallButtonsPanel(void); + virtual ~CallButtonsPanel(void); + + bool ConstructPanel(Tizen::Ui::IActionEventListener* pEventListener, FormType parentFormType); + + /** + * Overrides this method to provide user-specific initialization code after the control is added to a container. + * @remarks OnInitializing() is called when the control is about to be added to a container. + * @remarks To cancel adding this control to the parent, return E_FAILURE in this method. + * @see OnTerminating() + */ + virtual result OnInitializing(void); + + /** + * Overrides this method to provide user-specific termination code. + * @return An error code + * @remarks OnTerminating() is called right before the control is removed successfully from the container. + * @remarks To cancel removing this control from the parent, return E_FAILURE in this method. + * @see OnInitializing() + */ + virtual result OnTerminating(void); + //Called to change state, when keypad is opened or closed. + void SetKeypadButtonState(CommandIds cmdId); + //used to set or change speaker button state. + void SetSpeakerButtonState(CommandIds cmdId); + //used to set or change Mute button state. + void SetMuteButtonState(CommandIds cmdId); + //used to set the button panel state in end call form based on type of call. + void SetEndCallPanelState(bool isEnabled); + //Used to enable or disable "Add Call" Button + void EnableAddCallButton(bool enable); + +protected: + // Construct the panel to be shown in "End Call" form + result ConstructEndCallPanel(void); + // Construct the panel to be shown in "Active Call" form + result ConstructActiveCallPanel(void); + // Draws the background for the panel + result AddBackgroundBitmap(void); + // Draws the bitmap at the correct position on the button + void SetBitmapsToButton(const Tizen::Base::String& buttonId, const Tizen::Base::String& buttonName, const Tizen::Base::String& imgPath, ButtonState state); + // Draws the text at the correct position on the button + void SetEnrichedTextToButton(const Tizen::Base::String& buttonName, Tizen::Graphics::Canvas* pCanvas, ButtonState state, int verticalPos); + // Adds the action listener for the buttons + void AddKeyPadActionListener(const Tizen::Base::String& buttonId, CommandIds cmdId); + //Disable the unused buttons for Outgoing / Emergency Forms + void DisableKeysForOutgoingCall(void); + + //set the buttons in the panel as the top controls. Chk if its needed in RC2 + void SetButtonPosition(void); + +private: + //action listener + Tizen::Ui::IActionEventListener* __pActionListener; + FormType __parentFormType; +}; + +#endif /* _PHN_CALL_BUTTONS_PANEL_H_ */ diff --git a/inc/PhnCallInfo.h b/inc/PhnCallInfo.h new file mode 100644 index 0000000..28da3ad --- /dev/null +++ b/inc/PhnCallInfo.h @@ -0,0 +1,160 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallInfo.h + * @brief This is the header file for the %CallInfo class. + * + * This header file contains the declarations for %CallInfo class. + */ +#ifndef _PHN_CALL_INFO_H_ +#define _PHN_CALL_INFO_H_ + +#include +#include +#include "PhnTypes.h" + +/** + * @class CallInfo + * @brief This class holds information about currently active Single party, + * mutli-party or conference calls. + * + */ +class CallInfo + : public Tizen::Base::Object +{ +public: + enum CallType + { + VOICE_CALL, + VIDEO_CALL, // Currently not supported + }; + +public: + // Default Constructor. + CallInfo(void); + virtual ~CallInfo(void); + + //returns if a call is conference call or not + bool IsConferenceCall(void); + //Sets the conferenceflag for a call + void SetConference(bool isConferenceCall); + //returns if a call is emergency call or not + bool IsEmergency(void); + //Sets if a call is emergency call + void SetEmergency(bool isEmergency); + //get the call Handle + Tizen::Base::Long* GetCallHandle(void); + //Set the call handle + void SetCallHandle(unsigned int handle); + //Get for Contact Number for the call + Tizen::Base::String& GetContactNumber(void); + //Set the contact number for the call + void SetContactNumber(Tizen::Base::String& contactNumber); + //Sets the contact info for the call + void SetContactInfo(const Tizen::Social::Contact& contact); + //returns if a call is held call or not + bool IsOnHold(void); + //Sets the held call for the call + void SetOnHold(bool onHold); + //get the connected time for the call + long long GetCallConnectTime(void); + //Sets the connected time when call started + void SetCallConnectTime(long long connectTime); + //get the notified / dialed time when call started + long long GetCallNotificationTime(void); + //Sets the notified / dialed time when call started + void SetCallNotificationTime(long long callNotificationTime); + //gets the end call cause + Tizen::Base::String& GetEndCallCause(void); + //Sets the end call cause + void SetEndCallCause(Tizen::Base::String& pEndCause); + //gets the caller list for a conference call + Tizen::Base::Collection::IListT* GetCallerList(void); + //Adds a call to conference call list + result AddCallToCallerList(CallInfo& callInfo); + //removes a call from the conference call list + result RemoveCallFromCallerList(int index); + //returns the number of calls in conference + int GetCallerListCount(void); + //sets the type of the call for the logs application + void SetCalllogType(CallLogType callLogType); + //returns the type of the call log + CallLogType GetCalllogType(void); + /** + * This is the equality operator for this CallInfo. + * returns true, if both have same value for call handle. + * + * @param[in] rhs A reference to the %CallInfo instance + */ + bool operator ==(const CallInfo& rhs) const; + + /** + * This is the InEquality operator for this CallInfo. + * returns true, if value for call handle is different. + * + * @param[in] rhs A reference to the %CallInfo instance + */ + bool operator !=(const CallInfo& rhs) const; + + /** + * This is the assignment operator for this class. + * @param[in] rhs A reference to the %CallInfo instance + */ + CallInfo& operator =(const CallInfo& rhs); + + // this funtion fetches the contact person's name. + Tizen::Base::String* FetchCallerNameN(void); + // this funtion fetches the contact person's photo id, if present. + Tizen::Graphics::Bitmap* FetchCallerPhotoN(void); + //returns true if number is present in contacts + bool IsNumberPresent(void); + +private: + bool __isConfCall; + CallType __callType; + + ///Calllog type information like outgoing, incoming, missed call + CallLogType __calllogType; + + //To uniquely identify both Single / Conf. Call. + Tizen::Base::Long* __pCallHandle; + + bool __isEmergency; + + //applicable only for Single Call + Tizen::Base::String __contactNumber; + + //call is held + bool __isOnHold; + + //system time when call connected + long long __callConnectTime; + + //system time when the call was notified / dialed + long long __callNotificationTime; + + //end call cause + Tizen::Base::String* __pEndCallCause; + + //callHandles for individual callers in conf. calls + Tizen::Base::Collection::ArrayListT* __pParticipantCallHandles; + + //used to store previously fetched contact. + Tizen::Social::Contact* __pContact; +}; + +#endif // _PHN_CALL_INFO_H_ diff --git a/inc/PhnCallOptionPopup.h b/inc/PhnCallOptionPopup.h new file mode 100644 index 0000000..3affa00 --- /dev/null +++ b/inc/PhnCallOptionPopup.h @@ -0,0 +1,71 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallOptionPopup.h + * @brief This is the header file for the %CallOptionPopup class. + * + * This header file contains the declarations for %CallOptionPopup class. + */ +#ifndef _PHN_CALL_OPTION_POPUP_H_ +#define _PHN_CALL_OPTION_POPUP_H_ + +#include +#include + +#include "PhnIPopupItemSelectListener.h" +#include "PhnCallPresentationModel.h" +#include "PhnTypes.h" + +/** + * @class CallOptionPopup + * @brief This class presents a Popup based UI and functionality for popup + * shown for incoming call scenarios. + * + */ +class CallOptionPopup + : public Tizen::Ui::Controls::Popup + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::IActionEventListener +{ + +public: + CallOptionPopup(IPopupItemSelectListener& listener, CallPresentationModel& callPresenter); + virtual ~CallOptionPopup(void); + result Initialize(void); + // IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + //IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + // From IActionEventListener + void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + void ConstructListData(void); + +private: + Tizen::Base::Collection::ArrayList* __pContactList; + IPopupItemSelectListener& __popupListener; + CallPresentationModel& __callPresenter; +}; + +#endif // _PHN_CALL_OPTION_POPUP_H_ diff --git a/inc/PhnCallPresentationModel.h b/inc/PhnCallPresentationModel.h new file mode 100644 index 0000000..d877908 --- /dev/null +++ b/inc/PhnCallPresentationModel.h @@ -0,0 +1,151 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallPresentationModel.h + * @brief This is the header file for the %CallPresentationModel class. + * + * This header file contains the declarations for %CallPresentationModel class. + */ +#ifndef _PHN_CALL_PRESENTATION_MODEL_H_ +#define _PHN_CALL_PRESENTATION_MODEL_H_ + +#include +#include "PhnTypes.h" +#include "PhnITelephonyEventListener.h" +#include "PhnCalllogManager.h" + +class CallInfo; +class TelephonyManager; +class SettingsPresentationModel; + +/** + * @class CallPresentationModel + * @brief CallPresentationModel is Singleton class and acts as interface between + * events from other managers and all the views. + * + */ +class CallPresentationModel: public ITelephonyEventListener + , public Tizen::App::IAppControlResponseListener +{ +public: + //create a singleton instance + static CallPresentationModel* GetInstance(void); + +private: + CallPresentationModel(void); + CallPresentationModel(CallPresentationModel& presentor); + virtual ~CallPresentationModel(void); + CallPresentationModel& operator =(const CallPresentationModel& presentor); + + + result Construct(void); + static void CreateInstance(void); + static void DestroyInstance(void); + +public: + //set the telephony event listener + void SetTelEventListener(ITelephonyEventListener* pTelEventListener); + + //Dial an outgoing call + void DialCall(Tizen::Base::String& contactNumber, bool isEmergency); + //End the call + void EndCall(Tizen::Base::Long callHandle); + void EndCall(Tizen::Base::String& contactNumber); + //End the conference call + bool EndConferenceCall(void); + /** + * Hold the call. + * @returns true if successful. + */ + bool HoldCall(Tizen::Base::Long callHandle); + /** + * Unhold the call. + * @returns true if successful. + */ + bool UnHoldCall(Tizen::Base::Long callHandle); + //Hold conference call + bool HoldConferenceCall(void); + //UnHold conference call + bool ActivateConferenceCall(void); + //Join active and held call to conference call. + void JoinCall(void); + //Swap between active and held call + void SwapCalls(void); + //Mute or Unmute Call + bool SetMuteStatus(bool setMute); + //Get the call Muted status + bool IsCallMuted(void); + //Set speaker to On or Off mode. + bool SetSpeakerStatus(bool setSpeaker); + //Get the speaker status + bool IsSpeakerOn(void); + //Send DTMF strings + void SendDTMFSignal(Tizen::Base::String& textToBeSent); + //Function to get the conference call info + CallInfo* GetConferenceCallInfoN(void); + //Split this call from the conference call + void SplitFromConference(SplitConfCallerCmdIds splitCallerCmdId, Tizen::Base::Collection::IListT* pConfCallList); + //End this single call from the conference call + void EndCallFromConference(EndConfCallerCmdIds endCallerCmdId, Tizen::Base::Collection::IListT* pConfCallList); + //returns true, if split operation is allowed. Else, returns false. + bool IsSplitAllowed(void); + //Accept the incoming call as per the options + void AcceptIncomingCall(CallAnswerOptions answerOptions,int callHandle); + //Reject an incoming call and send message, if required. + bool RejectCall(int callHandle, bool sendMsg, const Tizen::Base::String& contactNumber); + //Get the current call count + int GetCurrentCallCount(void); + //Get the current call list + Tizen::Base::Collection::IListT* GetCallListN(void); + //Check if modem and sim initialization is complete. + bool CheckSimInitializationIsCompleted(); + //This function returns true, if contact number is emergency no. + bool IsEmergencyNumber(const Tizen::Base::String& phoneNumber, bool isSimInitialized); + //Start the alert in case of incoming call + void StartAlert(CallInfo& incomingCallInfo); + //Stop the alert in case of incoming call + void StopAlert(void); + //Gets the contact for the given phonenumber.returns null if not present. + Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber); + //Fetch the incoming call details. + CallInfo* FetchIncomingCallDetailsN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber); + //Function is used to auto reject the call based on call settings and return true, if rejected. + bool CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo); + + //Event Listener methods from ITelephonyEventListener + virtual void HandleCallConnected(Tizen::Base::Collection::IListT& pCallList); + virtual void HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT& pCallList); + virtual void HandleConferenceCall(CallInfo& pCallInfo); + virtual void HandleIncomingCall(CallInfo& pCallInfo); + virtual void HandleCallSwapOccured(Tizen::Base::Collection::IListT& pCallList); + virtual void HandleConferenceChange(void); + virtual void HandleTelephonyError(int errorCode); + //From IAppControlResponseListener + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + +private: + static CallPresentationModel* __pInstance; + //to forward telephony events + ITelephonyEventListener* __pTelEventListener; + TelephonyManager* __pTelephonyMgr; + SettingsPresentationModel* __pSettingsPresentor; + // This is only to save PhoneApp from closing when only 1 incoming call is present and + // incoming call is rejected with "Reject With message" by opening Msg AppControl. + bool __isMessageAppControlRunning; +}; + +#endif // _PHN_CALL_PRESENTATION_MODEL_H_ diff --git a/inc/PhnCallRejectInfo.h b/inc/PhnCallRejectInfo.h new file mode 100644 index 0000000..730ac35 --- /dev/null +++ b/inc/PhnCallRejectInfo.h @@ -0,0 +1,71 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallRejectInfo.h + * @brief This is the header file for the %CallRejectInfo class. + * + * This header file contains the declarations for %CallRejectInfo class. + */ +#ifndef _PHN_CALL_REJECT_INFO_H_ +#define _PHN_CALL_REJECT_INFO_H_ + +#include +#include "PhnSettingsConstants.h" + +/** + * @class CallRejectInfo + * @brief This class holds information about currently active Single party calls. + * + */ +class CallRejectInfo + : public Tizen::Base::Object +{ + +public: + // Default Constructor + CallRejectInfo(void); + virtual ~CallRejectInfo(void); + /** + * This is the equality operator for this CallRejectInfo. + * returns true, if both have same value for call handle. + * + * @param[in] rhs A reference to the %CallRejectInfo instance + */ + bool operator ==(const CallRejectInfo& rhs) const; + + /** + * This is the InEquality operator for this CallRejectInfo. + * returns true, if value for call handle is different. + * + * @param[in] rhs A reference to the %CallRejectInfo instance + */ + bool operator !=(const CallRejectInfo& rhs) const; + + /** + * This is the assignment operator for this class. + * @param[in] rhs A reference to the %CallRejectInfo instance + */ + CallRejectInfo& operator =(const CallRejectInfo& rhs); + +public: + int rowId; + Tizen::Base::String phoneNumber; + CallRejectMatchCondition rejectCondition; + bool isActivated; +}; + +#endif // _PHN_CALL_REJECT_INFO_H_ diff --git a/inc/PhnCallSettingDataService.h b/inc/PhnCallSettingDataService.h new file mode 100644 index 0000000..37a3813 --- /dev/null +++ b/inc/PhnCallSettingDataService.h @@ -0,0 +1,179 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallSettingDataService.h + * @brief This is the header file for the %CallSettingDataService class. + * + * This header file contains the declarations for %CallSettingDataService class. + */ +#ifndef _PHN_CALL_SETTING_DATA_SERVICE_H_ +#define _PHN_CALL_SETTING_DATA_SERVICE_H_ + +#include +#include +#include +#include "PhnCallRejectInfo.h" +#include "PhnSpeedDialInfo.h" + +/** + * @class CallSettingDataService + * @brief This class providing database service APIS to CallRejectInfo Application forms + * + */ +class CallSettingDataService +{ +public: + /** + * Creates an instance of its own. + * creates CallSettingDataService(singleton) if it does not exist else returns the existing form + */ + static CallSettingDataService* CreateInstance(void); + + virtual ~CallSettingDataService(void); + + ///Opens the Database. + /** + * Only one Database is maintained. Its name is hardcoded. + * It is assumed that OpenDB is called once while starting the application and CloseDB is called once while closing application. + */ + result OpenDatabase(void); + + ///Closes the Database + result CloseDatabase(void); + + ///Creates a database table to store CallRejectInfo information + result CreateCallRejectTableDatabase(void); + ///Creates a database table to store SpeedDial information + result CreateSpeedDialTableDatabase(void); + ///Adds a CallRejectInfo to the database + result AddCallRejectInfoToDatabase(CallRejectInfo* pNewItem); + + ///Deletes a CallRejectInfo from Database + /** + * @param an array of indexs of the CallRejectInfos to be deleted + * @param number of CallRejectInfo to be deleted + */ + result DeleteCallRejectInfoListFromDatabase(Tizen::Base::Collection::ArrayList* pIndexArray); + + /// Deletes a CallRejectInfo from Database + /** + * @param index of the CallRejectInfo to be deleted + */ + result DeleteCallRejectInfoFromDatabase(int index); + + ///Updates the CallRejectInfo details(contents, modification time etc) in Database + /** + * @param index of the CallRejectInfo to be updated + * @param a reference to CallRejectInfoInfo structure having the updated info + */ + result UpdateCallRejectInfoDatabase(int aIndex, CallRejectInfo* pCallRejectInfoItem); + + ///Gets one CallRejectInfo from the database + /** + * @param index of the CallRejectInfo to be fetched + * @param a reference to CallRejectInfoInfo structure into which the CallRejectInfo data is to be stored + */ + result GetCallRejectInfoFromDatabase(int aIndex, CallRejectInfo& dbItem); + + /// Gets all the CallRejectInfo from database into the linked list + /** + * @param a linked list reference to store the result + */ + result GetAllCallRejectInfoFromDatabaseN(Tizen::Base::Collection::ArrayListT& callRejectInfoList); + + ///Finds the number of entries in the database + /** + * @param an int reference to store the result + */ + result GetCallRejectCount(int& count); + + ///Searches for a keyword in the CallRejectInfo Contents from Database + /** + * @param search keyword + * @param Linked list to store the result of the search + */ + bool IsCallToBeRejected(Tizen::Base::String& phoneNumber); + + ///Adds a SpeedDialInfo to the database + result AddSpeedDialInfoToDatabase(SpeedDialInfo* pNewItem); + + /// Deletes a SpeedDialInfo from Database + /** + * @param index of the SpeedDialInfo to be deleted + */ + result DeleteSpeedDialInfoFromDatabase(int aIndex); + ///Updates the SpeedDialInfo details(contents, modification time etc) in Database + /** + * @param index of the SpeedDialInfo to be updated + * @param a reference to SpeedDialInfo structure having the updated info + */ + result UpdateSpeedDialInfoDatabase(int aIndex, SpeedDialInfo* pSpeedDialInfoItem); + + /// Gets all the SpeedDialInfo from database into the linked list + /** + * @param a linked list reference to store the result + */ + Tizen::Base::Collection::IMapT* GetAllSpeedDialInfoMapFromDatabaseN(void); + + //Gets the SpeedDialContact mapped against "aIndex", if any. Else returns null. + Tizen::Base::String* GetSpeedDialContactN(int aIndex); + +private: + /** + * Constructor + * made private as CallSettingDataService a singleton. + */ + CallSettingDataService(void); + + /** + * Copy constructor + * made private as CallSettingDataService a singleton. + */ + CallSettingDataService(const CallSettingDataService& dataService); + + /** + * Operator = + * made private as CallSettingDataService a singleton. + */ + CallSettingDataService& operator =(const CallSettingDataService& dataService); + + //checks if the condition is applicable for the passed phoneNumber + bool CheckRejectCondition(Tizen::Base::String& phoneNumber, CallRejectInfo& callRejectInfo); + + ///singleton CallSettingDataService object + static CallSettingDataService* __pCallSettingDataService; + + void SyncWithCurrentAddressbookStatus(Tizen::Base::Collection::HashMapT* pSpeedDialInfoList); + + /// Database object + /** + * Its made static as we need only one instance of it across different CallSettingDataService object calls. + * Its created while calling OpenDB and distructed while calling CloseDB. + */ + static Tizen::Io::Database* __pDatabase; + + ///name of the database + const Tizen::Base::String __strDbName; + + /// an Enumerator used to iterate through the results of a database query. + Tizen::Io::DbEnumerator* __pEnum; + + /// Used to create and execute database statements(queries) + Tizen::Io::DbStatement* __pStmt; +}; + +#endif /* _PHN_CALL_SETTING_DATA_SERVICE_H_ */ diff --git a/inc/PhnCalllogManager.h b/inc/PhnCalllogManager.h new file mode 100644 index 0000000..8e6c1e6 --- /dev/null +++ b/inc/PhnCalllogManager.h @@ -0,0 +1,174 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCalllogManager.h + * @brief This is the header file for the %CallLogManager class. + * + * This header file contains the declarations for %CallLogManager, %CallLogDetails, %LogListComparer class. + */ + +#ifndef _PHN_CALL_LOG_MANAGER_H_ +#define _PHN_CALL_LOG_MANAGER_H_ +#include "contacts.h" +#include +#include "PhnCallInfo.h" +#include "PhnTypes.h" +#include "PhnICalllogChangeListener.h" + +class CallLogDetails; + +/** + * @class LogListComparer + * @brief LogListComparer provides comparison functions used to + * sort an arraylist of CallLogDetails. + * + */ +class LogListComparer +: public Tizen::Base::Collection::IComparerT +{ +public: + LogListComparer() {}; + virtual ~LogListComparer() {}; + result Compare (const CallLogDetails& obj1, const CallLogDetails& obj2, int& cmp) const; +}; + +/** + * @class CallLogDetails + * @brief CallLogDetails used to store information call logs. + * + */ +class CallLogDetails +: public Tizen::Base::Object +{ +public: + CallLogDetails(); + virtual ~CallLogDetails(); + bool operator ==(const CallLogDetails& rhs) const; + bool operator !=(const CallLogDetails& rhs) const; + CallLogDetails& operator =(const CallLogDetails& rhs); + + void SetCalllogDbId(int id); + int GetCalllogDbId(void); + void SetCalllogType(contacts_phone_log_type_e type); + CallLogType GetCalllogType(void); + void SetContactDbId(int id); + int GetContactDbId(void); + void SetFirstName(char* name); + char* GetFirstName(void); + void SetLastName(char* name); + char* GetLastName(void); + void SetDisplayName(char* name); + char* GetDisplayName(void); + void SetContactImagePath(char* path); + char* GetContactImagePath(void); + void SetPhoneNumber(char* number); + char* GetPhoneNumber(void); + void SetShortMessage(char* message); + char* GetShortMessage(void); + void SetStartTime(time_t time); + time_t GetStartTime(void); + void SetDuration(int duration); + int GetDuration(void); + void ConvertTimetoDateTime(void); + Tizen::Base::DateTime GetDateTime(void); + +private: + //TODO: Naming conventions to be followed. + //NOTE: Below fields are not owned. + int calllog_db_id; /**< Call log entry id */ + CallLogType calllog_type; /**< Call log entry type */ + int contact_db_id; /**< Contact's id in database */ + char* first_name; /**< Contact's first name (also known as given name) */ + char* last_name; /**< Contact's last name (also known as family name) */ + char* display_name; /**< Display name (how contact's name should be presented) */ + char* contact_image_path; /**< Path to image with contact's picture */ + // contact_number_type_e phone_number_type; /**< Phone number type (i.e.: work, cell) */ + char* phone_number; /**< Phone number */ + char* short_message; /**< Short message for this log */ + time_t startTime; /**< Timestamp of this change */ + int duration_sec; + Tizen::Base::DateTime dateTime; + +}; + +/** + * @class CallLogManager + * @brief CallLogManager is a singleton class used to save and retrieve call log related data. + * + */ +class CallLogManager +{ +public: + static CallLogManager* GetInstance(void); + +private: + CallLogManager(void); + virtual ~CallLogManager(void); + result Construct(void); + static void CreateInstance(void); + static void DestroyInstance(void); +public: + + result AddCallogInfoToDatabase(CallInfo* calllogInfo); + void ResetAndNotifyCalllogData(void); + //Tizen::Base::Collection::HashMapT* GetCallogListByNumberFromDatabaseN(char* number); + Tizen::Base::Collection::ArrayListT* GetCallogListByNumberFromDatabaseN(char* number); + unsigned long GetDuration(long long start_time); + bool GetAllCallogDataFromDatabseCB(); + bool GetCallogListByNumberFromDatabaseCB(char *number); + void changed_db_cb(); + void CopyDataToCallLogDetails(CallLogDetails* calllogInfo , contacts_record_h record); + + result GetCallLogItemAtIndex(int index, CallLogDetails& calllogInfo); + + Tizen::Base::Collection::IListT* GetCalllogListKeys(void); + Tizen::Base::Collection::IListT* GetCalllogListValues(void); + Tizen::Base::Collection::IMapEnumeratorT* GetCalllogListEnum(void); + + Tizen::Base::Collection::IListT* GetCalllogListByNumKeys(void); + Tizen::Base::Collection::IListT* GetCalllogListByNumValues(void); + Tizen::Base::Collection::IMapEnumeratorT* GetCalllogListByNumEnum(void); + void DeleteCalllogByDbId(int dbId); + void DeleteAllCalllog(void); + int GetAllCalllogCount(void); + int GetCalllogCountByNumber(void); + //Used to get the latest dialed or incoming number from call log database. + Tizen::Base::String* GetLatestCallLogFromDbN(void); + //Used to fetch list of call from unknown numbers from logs. + Tizen::Base::Collection::HashMapT* GetCallogListByUnknownNumberFromDatabaseN(char* number); + + + void SortCalllogList(void); + void SortCalllogListByNumber(void); + + void AddCalllogChangeListener(ICalllogChangeListener& listner ); + void RemoveCalllogChangeListner(ICalllogChangeListener& listner ); + void GetCalllogContactName(Tizen::Base::String number,Tizen::Base::String& name); +private: + + static CallLogManager* __pCallogManager; + Tizen::Base::Collection::LinkedListT* __pCalllogList; + Tizen::Base::Collection::HashMapT* __pCalllogDBIds; + //Tizen::Base::Collection::HashMapT* __pCalllogListByNumber; + Tizen::Base::Collection::ArrayListT* __pCalllogListByNumber; + Tizen::Base::Collection::HashMapT* __pCalllogUnkownListByNumber; + char* __pNumber; + Tizen::Base::Collection::ArrayListT* __pCalllogChangeListerners; +}; + + +#endif // _PHN_CALL_LOG_MANAGER_H_ diff --git a/inc/PhnCommonUtils.h b/inc/PhnCommonUtils.h new file mode 100644 index 0000000..6b136c9 --- /dev/null +++ b/inc/PhnCommonUtils.h @@ -0,0 +1,148 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCommonUtils.h + * @brief This is the header file for the %DialUtil class. + * + * This header file contains the declarations for commonly used functions. + */ +#ifndef _PHN_COMMON_UTILS_H_ +#define _PHN_COMMON_UTILS_H_ + +#include +#include + +enum DialerFontStyle +{ + FONT_CALLING_TEXT, + FONT_KEYPAD_NUMBER, + FONT_KEYPAD_TEXT, + FONT_KEYPAD_P, + FONT_KEYPAD_PLUS, + FONT_KEYPAD_CANCEL, + FONT_SUGGESTION_NAME, + FONT_SUGGESTION_MOBILE, + FONT_SUGGESTION_NUMBER, + FONT_SUGGESTION_LIST_NUMBER, + FONT_HIGHLIGHT_SEARCH_KEYWORD +}; + +//Command Ids used in Dialer tab. Always append new command ids at bottom. +enum DialCommandIds +{ + NUM_KEY1 = 1, + NUM_KEY2, + NUM_KEY3, + NUM_KEY4, + NUM_KEY5, + NUM_KEY6, + NUM_KEY7, + NUM_KEY8, + NUM_KEY9, + PAUSE_KEY, + NUM_KEY0, + HASH_KEY, + VIDEOCALL_KEY, + CALL_KEY, + CLEAR_KEY, + CANCEL_KEY, + DIAL_CMD_TOTAL_COUNT, +}; + +enum LogContextActionIds +{ + IDA_LIST_ELEMENT_CALL = 105, + IDA_LIST_ELEMENT_VIDEO_CALL, + IDA_LIST_ELEMENT_MESSAGE, + IDA_LIST_ELEMENT_DELETE, + +}; + + +extern const int ID_NAME_STRING; +extern const int ID_NUMBER_STRING; +extern const int ID_TIME_STRING; +extern const int ID_CONTACT_BITMAP; +extern const int ID_CALLTYPE_BITMAP; + + +extern const int X_TEXT_LINE1_ITEM; +extern const int Y_TEXT_LINE1_ITEM; +extern const int H_TEXT_LINE1_ITEM; +extern const int W_TEXT_LINE1_ITEM; + +extern const int X_TEXT_LINE2_ITEM; +extern const int Y_TEXT_LINE2_ITEM; +extern const int H_TEXT_LINE2_ITEM; +extern const int W_TEXT_LINE2_ITEM; + +extern const int X_TEXT_TIME_ITEM; +extern const int Y_TEXT_TIME_ITEM; +extern const int H_TEXT_TIME_ITEM; +extern const int W_TEXT_TIME_ITEM; + +extern const int X_CONTACT_BITMAP_ITEM; +extern const int Y_CONTACT_BITMAP_ITEM; +extern const int H_CONTACT_BITMAP_ITEM; +extern const int W_CONTACT_BITMAP_ITEM; + +extern const int X_CALLTYPE_BITMAP_ITEM; +extern const int Y_CALLTYPE_BITMAP_ITEM; +extern const int H_CALLTYPE_BITMAP_ITEM; +extern const int W_CALLTYPE_BITMAP_ITEM; + +extern const int X_DIALER_BTN_TXT; +extern const int W_DIALER_BTN_NUM_TXT; +extern const int W_DIALER_BTN_ALPHA_TXT; + +/** + * @class DialUtil + * @brief This class provides static public utility functions to dialer module. + * + */ +class DialUtil +{ +private: + DialUtil(void){}; + DialUtil(const DialUtil& obj){}; + virtual ~DialUtil(void){}; + +public: + //used to get text font for button in dialer tab. + static Tizen::Graphics::Font* GetTextFontN(int textFontStyle); + //used to get text color for button in dialer tab. + static Tizen::Graphics::Color* GetTextColorN(int textColor, int buttonStatus); + //Function to check if keyword is numeric. This function assumes that a string starting with digit will be numeric. + //If needed, it might be implemented in more generic way to check all characters for digits. + static bool IsNumericString(Tizen::Base::String& keyWord); + //Sets the 'bgImg' image to 'pCanvas' Canvas, if image is a 9-patch image. + static void Draw9PatchToCanvas(Tizen::Graphics::Canvas& pCanvas, const Tizen::Base::String& bgImg); + //Used to set image to canvas. + static void DrawImageToCanvas(const Tizen::Base::String& image, Tizen::Graphics::Dimension imageDimention, Tizen::Graphics::Canvas& pCanvas, int pos); + //Used to convert text to Enriched text and set it to canvas. + static void DrawTextToCanvas(const Tizen::Base::String& buttonText1, int fontSize, Tizen::Graphics::Canvas& pCanvas, int pos, int buttonStatus); + //Used to set nnormal, pressed image to button. + static void DrawCanvasToButton(Tizen::Graphics::Canvas* pCanvasNormal, Tizen::Graphics::Canvas* pCanvasPressed, Tizen::Ui::Controls::Button* pButton); + //Used to convert provided digit to its equivalent String instance. + static Tizen::Base::String ConvertDialedNumberToString(int dialNumber); + //Function used to fetch a list of possible names mapped to 'nextCharPos'. + static Tizen::Base::Collection::IList* FetchPossibleNamesListN(const Tizen::Base::String& prevSearchStr, int nextCharPos); + //Function used to convert substring of 'name' to keys typed, eg. Ani -> 264 + static void ConvertNameToNumericKeys(Tizen::Base::String& subContactName, Tizen::Base::String& possibleKeysTyped); +}; + +#endif /* _PHN_COMMON_UTILS_H_ */ diff --git a/inc/PhnConfCallerListForm.h b/inc/PhnConfCallerListForm.h new file mode 100644 index 0000000..38d4b34 --- /dev/null +++ b/inc/PhnConfCallerListForm.h @@ -0,0 +1,89 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnConfCallerListForm.h + * @brief This is the header file for the %ConfCallerListForm class. + * + * This header file contains the declarations for %ConfCallerListForm class. + */ +#ifndef _PHN_CONF_CALLER_LIST_FORM_H_ +#define _PHN_CONF_CALLER_LIST_FORM_H_ + +#include +#include +#include +#include "PhnBaseForm.h" +#include "PhnTypes.h" + +class CallInfo; + +/** + * @class ConfCallerListForm + * @brief This class presents a form based UI for participants list of conference call. + * + */ +class ConfCallerListForm + : public BaseForm + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + ConfCallerListForm(void); + virtual ~ConfCallerListForm(void); + //From BaseForm + virtual void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //Disable all the elements + void DisableAllControls(void); + // + // From 'Container'. + // Called when the container needs to draw itself. @n + // Users can override this method to display user-specific drawings. @n + // This method is called after the container has drawn itself, but just before the container draws its child controls. + // + virtual result OnDraw(void); + // Handle change in conf call list + void HandleCallChange(void); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + // Add the action listener for the buttons + void AddActionListener(const Tizen::Base::String& keyName, CommandIds cmdId); + // Activate the panels to be shown according to the number of calls + void ActivatePanels(void); + // Activate each individual element in the panel + void ActivatePanelAndAddActionListener(const Tizen::Base::String& panelName, const Tizen::Base::String& lineLabelName, const Tizen::Base::String& splitButtonName, const Tizen::Base::String& endButtonName, const Tizen::Base::String& callerLabelName, SplitConfCallerCmdIds splitCmdId, EndConfCallerCmdIds EndCmdId, const Tizen::Base::String& displayName); + // Method to show call duration/state(held) for call in progress + void ShowTimerInfo(const Tizen::Base::String& timerLblName, long long startTime = 0); + // Method to set "Hold" Button status + void SetHoldButtonStatus(bool isCallOnHold); + +private: + CallInfo* __pConfCallInfo; + //Timer used to show call time + Tizen::Base::Runtime::Timer* __pConfCallTimer; +}; + +#endif //_PHN_CONF_CALLER_LIST_FORM_H_ diff --git a/inc/PhnCustomItemBgElement.h b/inc/PhnCustomItemBgElement.h new file mode 100644 index 0000000..58cec72 --- /dev/null +++ b/inc/PhnCustomItemBgElement.h @@ -0,0 +1,45 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCustomItemBgElement.h + * @brief This is the header file for the %CustomItemBgElement class. + * + * This header file contains the declarations for %CustomItemBgElement class. + */ +#ifndef _PHN_CUSTOM_ITEM_BG_ELEMENT_H_ +#define _PHN_CUSTOM_ITEM_BG_ELEMENT_H_ + +#include +#include + +/** + * @class CustomItemBgElement + * @brief This class presents a custom drawing for list item in settings forms. + * + */ +class CustomItemBgElement + : public Tizen::Ui::Controls::ICustomElement +{ +public: + CustomItemBgElement(void); + virtual ~CustomItemBgElement(void); + + //From ICustomElement + virtual bool OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status); +}; + +#endif // _PHN_CUSTOM_ITEM_BG_ELEMENT_H_ diff --git a/inc/PhnDialAppForm.h b/inc/PhnDialAppForm.h new file mode 100644 index 0000000..a2c3184 --- /dev/null +++ b/inc/PhnDialAppForm.h @@ -0,0 +1,58 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialAppForm.h + * @brief The Dial application form + * + */ +#ifndef _PHN_DIAL_APP_FORM_H_ +#define _PHN_DIAL_APP_FORM_H_ + +#include +#include + +/** + * @class DialAppForm + * @brief This class presents a main form for Phone application. + * + */ +class DialAppForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + DialAppForm(void); + virtual ~DialAppForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +protected: + static const int ID_HEADER_DIALER; + static const int ID_HEADER_LOGS; + +private: + ///Form Footer + Tizen::Ui::Controls::Footer* __pFormFooter; +}; + +#endif //_PHN_DIAL_APP_FORM_H_ diff --git a/inc/PhnDialContactInfo.h b/inc/PhnDialContactInfo.h new file mode 100644 index 0000000..10995c1 --- /dev/null +++ b/inc/PhnDialContactInfo.h @@ -0,0 +1,82 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialContactInfo.h + * @brief This is the header file for the %DialContactInfo class. + * + * This header file contains the declarations for %DialContactInfo class. + */ +#ifndef _PHN_DIAL_CONTACT_INFO_H_ +#define _PHN_DIAL_CONTACT_INFO_H_ + +#include + +/** + * @class DialContactInfo + * @brief This is a light-weight class used to provides display name, + * phone number and Thumbnail using simple methods. + * + */ +class DialContactInfo: public Tizen::Base::Object +{ +public: + DialContactInfo(void); + virtual ~DialContactInfo(void); + /* + //Used to create new 'DialContactInfo' object which is clone of 'this' object. + DialContactInfo* CloneN(void); + */ + //display name + void SetDisplayName(Tizen::Base::String& pDisplayName); + Tizen::Base::String& GetDisplayName(void) const; + //phone number + void SetPhoneNumber(Tizen::Base::String& pPhoneNumber); + Tizen::Base::String& GetPhoneNumber(void) const; + //matched search string + void AddSearchKey(Tizen::Base::String& pSearchString); + void RemoveSearchKey(int index); + void ReplaceSearchKey(int index, Tizen::Base::String& pSearchString); + //Used to get the first matched search key + Tizen::Base::String* GetSearchKey(void); + Tizen::Base::Collection::IList* GetSearchKeyList(void); + //Used to transfer ownership of 'pBitmap' to 'DialContactInfo'. + void SetThumbnail(Tizen::Graphics::Bitmap* pBitmap); + Tizen::Graphics::Bitmap* GetThumbnailN(void) const; + //Coll Log Db Id + void SetCallLogDbId(int callLogDbId); + int GetCallLogDbId(void); + //Checks whether the value of the specified instance is equal to the value of the current instance of %Object. + virtual bool Equals(const Object& obj) const; + /** + * Used to return new 'DialContactInfo' object with the same state + * as the object on which this function is called. + */ + DialContactInfo* CloneN(void); + +private: + //Copy Constructor - we dont want any bitwise copy. + DialContactInfo(const DialContactInfo& obj); + +private: + int __callLogDbId; + Tizen::Base::String* __pDisplayName; + Tizen::Base::String* __pPhoneNumber; + Tizen::Graphics::Bitmap* __pThumbnail; + Tizen::Base::Collection::ArrayList* __pSearchKeyList; +}; + +#endif // _PHN_DIAL_CONTACT_INFO_H_ diff --git a/inc/PhnDialPresentationModel.h b/inc/PhnDialPresentationModel.h new file mode 100644 index 0000000..eeaeaf8 --- /dev/null +++ b/inc/PhnDialPresentationModel.h @@ -0,0 +1,84 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialPresentationModel.h + * @brief This is the header file for the %DialPresentationModel class. + * + * This header file contains the declarations for %DialPresentationModel class. + */ +#ifndef PHNDIALPRESENTATIONMODEL_H_ +#define PHNDIALPRESENTATIONMODEL_H_ + +#include +#include +#include "PhnRetrieveSuggestionsTasks.h" + +class DialContactInfo; +class DialTabDialer; +class SettingsManager; + +/** + * @class DialPresentationModel + * @brief This class acts as an interface between the Dialer Screen and core engine. + */ +class DialPresentationModel + : public Tizen::App::IAppControlResponseListener + , public ISuggestionsRetrievedEventListener +{ +public: + DialPresentationModel(DialTabDialer& pParentPanel); + ~DialPresentationModel(); + + /** + * Used to fetch the contacts suggestion list. + * Starts a new thread for async search of contacts, call logs with phone number and name. + */ + bool FetchSuggestionList(const Tizen::Base::String& searchString); + //Used to fetch Speed dial mapping for pressed button, if present. + Tizen::Base::String* FetchSpeedDialNumberN(int actionId); + //Used to fetch contact at specified index from search result list. + DialContactInfo* GetSuggestionAtIndex(int index); + //Used to fetch the no. of suggested contacts in search result list. + int GetNumberOfSuggestions(void); + //clear search results + void ClearSearchResults(void); + //Used to open contacts "Add" AppControl + void AddContactsToAddressBook(Tizen::Base::String& contactNumber); + //Used to open Messaging "Compose" AppControl + void OpenMessagingAppControl(Tizen::Base::String& contactNumber); + //Used to fetch latest dialed or caller number from call logs + Tizen::Base::String* FetchLatestNumberFromLogsN(void); + +protected: + //Called when the application control is completed. + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + // Called when the retrieval of contact suggestion list is completed + virtual void HandleContactsRetrievalCompleted(Tizen::Base::Collection::IList* pContactsList); + +private: + SettingsManager* __pSettingsManager; + Tizen::Base::Collection::ArrayList* __pNumberSuggestionList; + //Used to Control access to __pNumberSuggestionList + Tizen::Base::Runtime::Mutex __mutex; + Tizen::Base::String* __pSearchString; + /// Worker thread + Tizen::Base::Runtime::Thread* __pSearchThread; + RetrieveContactsListTask* __pAsyncSearchTask; + DialTabDialer& __pParentPanel; +}; + +#endif /* PHNDIALPRESENTATIONMODEL_H_ */ diff --git a/inc/PhnDialerKeypad.h b/inc/PhnDialerKeypad.h new file mode 100644 index 0000000..16c3c0b --- /dev/null +++ b/inc/PhnDialerKeypad.h @@ -0,0 +1,97 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialerKeypad.h + * @brief This is the header file for the %DialerKeypad class. + * + * This header file contains the declarations for %DialerKeypad class. + */ +#ifndef _PHN_DIALER_KEYPAD_H_ +#define _PHN_DIALER_KEYPAD_H_ + +#include +#include +#include + +/** + * @class DialerKeypad + * @brief This class presents a Panel based UI for keypads used in Dialer Tab. + * + */ +class DialerKeypad + : public Tizen::Ui::Controls::Panel +{ +private: + enum ButtonState + { + BTN_NORMAL, + BTN_PRESS, + BTN_DIM, + }; + +public: + enum DialerState + { + DIALER_STATE_FIRST_SCENE = 0, + DIALER_STATE_NORMAL_APPCONTROL, + DIALER_STATE_EMERGENCY_APPCONTROL, + DIALER_STATE_ADD_CALL, + }; + + DialerKeypad(DialerState openedState); + virtual ~DialerKeypad(void); + + bool ConstructPanel(Tizen::Ui::IActionEventListener* pActionListener, Tizen::Ui::ITouchLongPressGestureEventListener* pLongTapListener); + /** + * Overrides this method to provide user-specific initialization code after the control is added to a container. + * @remarks OnInitializing() is called when the control is about to be added to a container. + * @remarks To cancel adding this control to the parent, return E_FAILURE in this method. + * @see OnTerminating() + */ + virtual result OnInitializing(void); + /** + * Overrides this method to provide user-specific termination code. + * @return An error code + * @remarks OnTerminating() is called right before the control is removed successfully from the container. + * @remarks To cancel removing this control from the parent, return E_FAILURE in this method. + * @see OnInitializing() + */ + virtual result OnTerminating(void); + +private: + // Set Bitmap to the Buttons in panel. + void SetBitmapToKeypadButtons(void); + //Adds Action listener and Long press detectors to buttons. + void AddListenersToButtons(void); + //used to determine whether to show cancel button + bool IsShowCancelButton(void); + //used to determine whether to show voice mail + bool IsShowVoiceMailIcon(void); + //used to determine whether to show video call button + bool IsShowVideoCallButton(void); + +private: + //Acts as Action listener & LongPress Gesture Listener + Tizen::Ui::IActionEventListener* __pParentActionListener; + Tizen::Ui::ITouchLongPressGestureEventListener* __pParentLongTapListener; + //Long press gesture detectors for buttons + Tizen::Base::Collection::ArrayList* __pLongPressDetectors; + //Identifies dialer keypad opened from which state + DialerState __openedState; +}; + +#endif // _PHN_DIALER_KEYPAD_H_ diff --git a/inc/PhnDtmfKeypadPanel.h b/inc/PhnDtmfKeypadPanel.h new file mode 100644 index 0000000..a0d2d25 --- /dev/null +++ b/inc/PhnDtmfKeypadPanel.h @@ -0,0 +1,80 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDtmfKeypadPanel.h + * @brief This is the header file for the %DtmfKeyPadPanel class. + * + * This header file contains the declarations for %DtmfKeyPadPanel class. + */ +#ifndef _PHN_DTMF_KEYPAD_PANEL_H_ +#define _PHN_DTMF_KEYPAD_PANEL_H_ + +#include +#include + +/** + * @class DtmfKeyPadPanel + * @brief This class presents a panel based UI for DTMF keypad + * shown while active call scenarios. + * + */ +class DtmfKeyPadPanel + : public Tizen::Ui::Controls::Panel +{ +public: + DtmfKeyPadPanel(void); + virtual ~DtmfKeyPadPanel(void); + bool Initialize(Tizen::Ui::IActionEventListener* pEventListener,Tizen::Graphics::Rectangle& boundsRect); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + +protected: + + enum DialerFontStyle + { + FONT_CALLING_TEXT, + FONT_KEYPAD_NUMBER, + FONT_KEYPAD_TEXT, + FONT_KEYPAD_P, + FONT_KEYPAD_PLUS, + FONT_KEYPAD_CANCEL + }; + //Add action listener. + void AddListenersToButtons(); + result SetBackgroundtoButton(); + // Draws the bitmap at the correct position on the buttons + void SetBitmapsToButton(Tizen::Base::String& buttonId,const Tizen::Base::String& buttonText,int actionID); + //Constructs the canvas and adds the bitmap to the buttons + result ConstructButtonCanvas(Tizen::Graphics::Canvas& pCanvas, Tizen::Ui::Controls::Button* pButton, const Tizen::Base::String& bgImg,int buttonStatus); + // Draws the image at the correct position on the button + void DrawImageToCanvas(const Tizen::Base::String& image, Tizen::Graphics::Dimension imageDimention, Tizen::Graphics::Canvas& pCanvas, int pos); + // Draws the text at the correct position on the button + void DrawTextToCanvas(const Tizen::Base::String& buttonText1, int fontSize, Tizen::Graphics::Canvas& pCanvas, int pos, int buttonStatus); + // retrieves the position for the text/image in the button + void GetPositionToDraw(Object* item, Tizen::Graphics::Canvas* pCanvas, int itemType, int pos, Tizen::Graphics::Point* itemPos); + // Gets the font based on the style + Tizen::Graphics::Font* GetTextFontN(int textFontStyle); + // Get the color to be set for the text + Tizen::Graphics::Color* GetTextColorN(int textColor, int buttonStatus); + +private: + //action listener + Tizen::Ui::IActionEventListener* __pActionListener; +}; + +#endif // _PHN_DTMF_KEYPAD_PANEL_H_ diff --git a/inc/PhnEmergencyDialForm.h b/inc/PhnEmergencyDialForm.h new file mode 100644 index 0000000..39e75fa --- /dev/null +++ b/inc/PhnEmergencyDialForm.h @@ -0,0 +1,78 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnEmergencyDialForm.h + * @brief This is the header file for the EmergencyDialForm class. + * + * This header file contains the declarations for EmergencyDialForm class. + */ +#ifndef _PHN_EMERGENCY_DIAL_FORM_H_ +#define _PHN_EMERGENCY_DIAL_FORM_H_ + +#include +#include + +class DialerKeypad; +class ErrorMsgPopup; + +/** + * @class EmergencyDialForm + * @brief This class presents Emergency dial form. + * + */ +class EmergencyDialForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::IActionEventListener + , public IPopupClosedEventListener + , public Tizen::Ui::ITouchLongPressGestureEventListener +{ +public: + EmergencyDialForm(void); + virtual ~EmergencyDialForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + //Event Listeners from TouchLongPressGestureDetector + // Called when a long press gesture is detected. + virtual void OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector); + //Called when a long press detection is canceled. + virtual void OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector){} + + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + +private: + //Used to construct dialer keypad. + void ConstructKeypad(void); + //Used to show formatted contact number in text field. + void ShowFormattedText(Tizen::Ui::Controls::EditField* pEditField, int actionId); + //Used to prepare for MOCall and switch to emergency outgoing call screen. + void SwitchToOutgoingCallScreen(const Tizen::Base::String& contactNumber); + +private: + DialerKeypad* __pDialKeypad; + ErrorMsgPopup* __pErrorMsgPopup; +}; + +#endif // _PHN_EMERGENCY_DIAL_FORM_H_ diff --git a/inc/PhnEndCallForm.h b/inc/PhnEndCallForm.h new file mode 100644 index 0000000..4dda6e4 --- /dev/null +++ b/inc/PhnEndCallForm.h @@ -0,0 +1,116 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnEndCallForm.h + * @brief This is the header file for the %EndCallForm class. + * + * This header file contains the declarations for %EndCallForm class. + */ +#ifndef _PHN_END_CALL_FORM_H_ +#define _PHN_END_CALL_FORM_H_ + +#include +#include +#include +#include "PhnBaseForm.h" +#include "PhnTypes.h" +#include "PhnIAppStateChangeListner.h" + +class CallButtonsPanel; + +/** + * @class EndCallForm + * @brief This class presents a form based UI for end call scenarios. + * + */ +class EndCallForm + : public BaseForm + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::App::IAppControlResponseListener + , public IAppStateChangeListener +{ +public: + EndCallForm(void); + virtual ~EndCallForm(void); + //From BaseForm + virtual void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + /** + * Called when the container needs to draw itself. @n + * Users can override this method to display user-specific drawings. @n + * This method is called after the container has drawn itself, but just before the container draws its child controls. + */ + virtual result OnDraw(void); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + /** + * Called when the application control is completed. + * @param[in] providerId The provider ID + * @param[in] operationId The operation ID used in application control invocation + * @param[in] pResultList The list of callback strings of application control + * @remarks The specified @c pResultList provides the result code for the first array element. + * @remarks When the invoked application control is terminated without sending a result, + * then this method is invoked with @c pResultList and it contains App::APPCONTROL_RESULT_TERMINATED. + * @remarks Switching forms using Tizen::Ui::Controls::Frame::SetCurrentForm() in this listener disables the upcoming form + * (UiApp::OnForeground()). If UiApp::OnForeground() is being used in the application logic, + * it is recommended to avoid switching forms in this listener. + * @see Tizen::App::AppControl + */ + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + //Used to set the contact button state in the end call form + void SetContactButtonState(bool showState); + //Called when App comes to foreground + virtual void OnForeground(void); + //Called when App goes to background + virtual void OnBackground(void); + +private: + //initialise the end call panel + void InitializeCallButtonsPanel(void); + //Add the action listener for the buttons + void AddKeyPadActionListener(const Tizen::Base::String& keyName, CommandIds cmdId); + // Method to show phone number on screen for all calls except conference call. + void ShowPhoneNumber(const Tizen::Base::String& phoneNumber, const Tizen::Base::String& lblName); + // Method to show caller name and photo for all calls. + void ShowPersonDetails(const Tizen::Base::String& phoneNumber, const Tizen::Base::String& nameLblName, const Tizen::Base::String& photoLblName, CallInfo* pCallInfo); + // Method to show thumbnail + void ShowCallersPhotoThumbnail(const Tizen::Graphics::Bitmap& pPhotoId); + //private method to handle whether to close App or goto initial scene, after no more active calls are left. + void HandleLastCallCompletion(void); + +private: + //Custom Buttons Panel + CallButtonsPanel* __pCallButtonsPanel; + Tizen::Base::String* __pContactNumber; + //Timer used to show End call scene for 3 sec + Tizen::Base::Runtime::Timer* __pEndCallEventTimer; + Tizen::Ui::Controls::Label* __pSmallPhotoLabel; + bool __isMsgAppControlLaunched; + bool __isContactAppControlLaunched; +}; + +#endif // _PHN_END_CALL_FORM_H_ diff --git a/inc/PhnErrorMsgPopup.h b/inc/PhnErrorMsgPopup.h new file mode 100644 index 0000000..58f1f62 --- /dev/null +++ b/inc/PhnErrorMsgPopup.h @@ -0,0 +1,78 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnErrorMsgPopup.h + * @brief This is the header file for the %ErrorMsgPopup class. + * + * This header file contains the declarations for %ErrorMsgPopup class. + */ +#ifndef _PHN_ERROR_MSG_POPUP_H_ +#define _PHN_ERROR_MSG_POPUP_H_ + +#include +#include + +/** + * @class IPopupClosedEventListener + * @brief This interface is used to notify the popup is closed event to Scenes. + * + */ +class IPopupClosedEventListener +{ +public: + virtual ~IPopupClosedEventListener(void){}; + // Called when the error message Pop-up is closed. + virtual void HandlePopupClosed(void) = 0; +}; + +/** + * @class ErrorMsgPopup + * @brief This class shows message popup in error condition. + * + */ +class ErrorMsgPopup: public Tizen::Ui::Controls::Popup + ,public Tizen::Base::Runtime::ITimerEventListener +{ +public: + ErrorMsgPopup(IPopupClosedEventListener* pEventListener); + virtual ~ErrorMsgPopup(void); + /** + * Function is used to show error message popup + * based on the error code received. + */ + void ShowErrorMsgPopupN(int errorCode); + + //From ITimerEventListener + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + void ConstructPopup(int errorCode); + //Function is used to fetch error messages based on error code + Tizen::Base::String FetchErrorMessage(int errorCode); + //draws and shows the popup on screen + void ShowPopup(void); + +private: + //Timer used to show message + Tizen::Base::Runtime::Timer* __pTimer; + //Listener to popup closed event. + IPopupClosedEventListener* __pEventListener; + //used to close the popup + int __popupModalResult; +}; + +#endif // _PHN_ERROR_MSG_POPUP_H_ diff --git a/inc/PhnIAppStateChangeListner.h b/inc/PhnIAppStateChangeListner.h new file mode 100644 index 0000000..67b3915 --- /dev/null +++ b/inc/PhnIAppStateChangeListner.h @@ -0,0 +1,37 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnIAppStateChangeListner.h + * @brief This is the header file for the IPhnIAppStateChangeListner class. + */ + +#ifndef _PHN_STATE_CHANGE_LISTNER_H_ +#define _PHN_STATE_CHANGE_LISTNER_H_ + +#include + +class IAppStateChangeListener + : public Tizen::Base::Object +{ +public: + virtual ~IAppStateChangeListener(void) {} + + virtual void OnForeground(void) = 0; + virtual void OnBackground(void) = 0; +}; + +#endif /* _PHN_STATE_CHANGE_LISTNER_H_ */ diff --git a/inc/PhnICalllogChangeListener.h b/inc/PhnICalllogChangeListener.h new file mode 100644 index 0000000..5a0d29a --- /dev/null +++ b/inc/PhnICalllogChangeListener.h @@ -0,0 +1,39 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file PhnICalllogChangeListener.h + * @brief This is the header file for the %ICalllogChangeListener class. + * + * This header file contains the declarations for %ICalllogChangeListener class. + */ +#ifndef _PHN_CALL_LOG_CHANGE_LISTENER_H_ +#define _PHN_CALL_LOG_CHANGE_LISTENER_H_ + +/** + * @class ICalllogChangeListener + * @brief This class presents call back function from call log module. + * + */ +class ICalllogChangeListener +{ +public: + virtual ~ICalllogChangeListener(void){}; + + virtual void OnCalllogChanged(void) = 0; + +}; + +#endif //_PHN_CALL_LOG_CHANGE_LISTENER_H_ diff --git a/inc/PhnIPopupItemSelectListener.h b/inc/PhnIPopupItemSelectListener.h new file mode 100644 index 0000000..ea42236 --- /dev/null +++ b/inc/PhnIPopupItemSelectListener.h @@ -0,0 +1,48 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnIPopupItemSelectListener.h + * @brief This is the header file for the %IPopupItemSelectListener class. + * + * This header file contains the declarations for %IPopupItemSelectListener class. + */ +#ifndef _IPOPUP_ITEM_SELECT_LISTENER_H_ +#define _IPOPUP_ITEM_SELECT_LISTENER_H_ + +#include + +/** + * @class IPopupItemSelectListener + * @brief Class IPopupItemSelectListener is listener for popup object deletion. + * + */ +class IPopupItemSelectListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + */ + virtual ~IPopupItemSelectListener(void) {} + + /** + * On Item selected. + */ + virtual void OnItemSelected(int itemIndex) = 0; +}; + +#endif // _IPOPUP_ITEM_SELECT_LISTENER_H_ diff --git a/inc/PhnISettingsEventListener.h b/inc/PhnISettingsEventListener.h new file mode 100644 index 0000000..2a164c9 --- /dev/null +++ b/inc/PhnISettingsEventListener.h @@ -0,0 +1,52 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnISettingsEventListener.h + * @brief This is the header file for the %ISettingsEventListener class. + * + * This header file contains the declarations for %ISettingsEventListener class. + */ +#ifndef _PHN_I_SETTINGS_EVENT_LISTENER_H_ +#define _PHN_I_SETTINGS_EVENT_LISTENER_H_ + +#include "PhnSettingsConstants.h" + +/** + * @class ISettingsEventListener + * @brief This interface is used to listen to events from Telephony Manager. + * + */ +class ISettingsEventListener +{ +public: + virtual ~ISettingsEventListener(void){}; + + //Handle the response for getCallWaiting request + virtual void HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated) = 0; + //Handle the response for setCallWaiting request + virtual void HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled) = 0; + //Handle the response for getCallForwarding request + virtual void HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime) = 0; + //Handle the response for setCallForwarding request + virtual void HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime) = 0; + //Handle the response for setcallBarring request + virtual void HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) = 0; + //Handle the response for getCallBarring request + virtual void HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) = 0; +}; + +#endif // _PHN_I_SETTINGS_EVENT_LISTENER_H_ diff --git a/inc/PhnITelephonyEventListener.h b/inc/PhnITelephonyEventListener.h new file mode 100644 index 0000000..996e2cb --- /dev/null +++ b/inc/PhnITelephonyEventListener.h @@ -0,0 +1,90 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnITelephonyEventListener.h + * @brief This is the header file for the %ITelephonyEventListener class. + * + * This header file contains the declarations for %ITelephonyEventListener class. + */ +#ifndef _PHN_I_TELEPHONY_EVENT_LISTENER_H_ +#define _PHN_I_TELEPHONY_EVENT_LISTENER_H_ + +#include "PhnCallInfo.h" + +/** + * @class ITelephonyEventListener + * @brief This interface is used to listen to events from Telephony Manager. + * + */ +class ITelephonyEventListener +{ +public: + virtual ~ITelephonyEventListener(void){}; + + /** + * Called when the dialed call / incoming call is accepted. + * Implement this to handle voice call events. + * @param[out] pCallList - list of active calls. + */ + virtual void HandleCallConnected(Tizen::Base::Collection::IListT& pCallList) = 0; + + /** + * This function is called when a call is disconnected. It returns the list of active calls, if any is existing. + * Otherwise it returns the last ended call along with call duration and cause to show. + * + * @param[out] isLastCall - true, if this call was last call. + * @param[out] pCallList - list of calls - ended Call if last call, otherwise currently active call. + */ + virtual void HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT& pCallList) = 0; + + /** + * This function is called when two calls are joined and a conference call is setup. + * + * @param[in] pCallInfo - The conference call information data. + */ + virtual void HandleConferenceCall(CallInfo& pCallInfo) = 0; + + /** + * This function is called when incoming call is received. + * + * @param[in] pCallInfo - The conference call information data. + */ + virtual void HandleIncomingCall(CallInfo& pCallInfo) = 0; + + /** + * Called when the dialed call / incoming call is accepted. + * Implement this to handle voice call events. + * @param[out] pCallList - list of active calls. + */ + virtual void HandleCallSwapOccured(Tizen::Base::Collection::IListT& pCallList) = 0; + + /** + * Called when the conference list changes. + * Implement this to handle voice call events. + * @param[out] pCallInfo - The conference call information data. + */ + virtual void HandleConferenceChange(void) = 0; + + /** + * Telephony event callback sent to listeners to handle + * error and show customized error message. + * @ param[out] errorCode - error cause returned by SLP TAPI. + */ + virtual void HandleTelephonyError(int errorCode) = 0; +}; + +#endif // _PHN_I_TELEPHONY_EVENT_LISTENER_H_ diff --git a/inc/PhnIncomingCallForm.h b/inc/PhnIncomingCallForm.h new file mode 100644 index 0000000..b8937c5 --- /dev/null +++ b/inc/PhnIncomingCallForm.h @@ -0,0 +1,150 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnIncomingCallForm.h + * @brief This is the header file for the %IncomingCallForm class. + * + * This header file contains the declarations for %IncomingCallForm class. + */ +#ifndef _PHN_INCOMING_CALL_FORM_H_ +#define _PHN_INCOMING_CALL_FORM_H_ + +#include +#include +#include +#include "PhnBaseForm.h" +#include "PhnTypes.h" +#include "PhnIPopupItemSelectListener.h" +#include "PhnCallOptionPopup.h" + +/** + * @class IncomingCallForm + * @brief This class presents a form based UI for incoming call scenarios. + * + */ +class IncomingCallForm + : public BaseForm + , public Tizen::Ui::Controls::ITableViewItemEventListener + , public Tizen::Ui::Controls::ITableViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::ITouchEventListener + , public IPopupItemSelectListener +{ +public: + IncomingCallForm(void); + virtual ~IncomingCallForm(void); + //From BaseForm + virtual void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + /** + * Called when the container needs to draw itself. @n + * Users can override this method to display user-specific drawings. @n + * This method is called after the container has drawn itself, but just before the container draws its child controls. + */ + virtual result OnDraw(void); + + // From 'ITableViewItemProvider' - Gets the total number of items in the specified group. + virtual int GetItemCount(void); + // From 'ITableViewItemProvider' - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int itemIndex, int itemWidth); + // From 'ITableViewItemProvider' - Deletes the specified item. + virtual bool DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + // From 'ITableViewItemProvider' - Updates the specified item. + virtual void UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem){}; + // From 'ITableViewItemProvider' - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + // From 'ITableViewItemEventListener' - Called when the state of a TableViewItem in the TableView is changed. + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + // From 'ITableViewItemEventListener' - Called when the TableViewContextItem is opened or closed. + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + // From 'ITableViewItemEventListener' - Called when the item is reordered. + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo){}; + + //From ITouchEventListener + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}; + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}; + virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}; + virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}; + virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}; + virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + + //From IPopupEventListener + void OnItemSelected(int itemIndex); +private: + // Method to fetch person details using phone number. + void ShowPersonDetails(const Tizen::Base::String& phoneNumber, const Tizen::Base::String& contactLblName, const Tizen::Base::String& nameLblName, CallInfo* pCallInfo); + // Method to show caller name for all calls. + void SetTextToLabel(const Tizen::Base::String& textToBeSet, const Tizen::Base::String& lblName); + // This function draws the caller's photo onto screen. + void ShowCallerPhoto(const Tizen::Graphics::Bitmap* pPhotoId); + //This function is used to show small Thumbnail size photo of caller. + void ShowCallersPhotoThumbnail(const Tizen::Graphics::Bitmap& pPhotoId); + // Method to show call duration/state(held) for call in progress + void ShowTimerInfo(const Tizen::Base::String& timerLblName, const Tizen::Base::String& textToBeDisplayed); + // Method to hide the "Reject with Message" panel + void HideRejectPanel(void); + // Method to create the Tableview to show the list of messages for the "Reject with Message" panel + void InitializeTableView(void); + // Method to create the canvas for the "Reject with Message" Button + void SetBitmapToRejectMessageButton(const Tizen::Base::String& btnName, const Tizen::Base::String& bgBitmap + , const Tizen::Base::String& arrowBitmap, const Tizen::Base::String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap); + void HandleMultipleCallSelection(int itemIndex); + +private: + //contact number for incoming call + Tizen::Base::String* __pActiveContactNo; + //Call Handle for the incoming call + int __incomingCallHandle; + //List for holding the rejectMessages from settings + Tizen::Base::Collection::IListT* __pRejectMessageList; + bool __isAnswerCallStarted; + bool __isRejectCallStarted; + Tizen::Base::Collection::ArrayList* __pAcceptArrowLabelsList; + Tizen::Base::Collection::ArrayList* __pRejectArrowLabelsList; + Tizen::Graphics::Bitmap* __pRejectCircle; + Tizen::Graphics::Bitmap* __pAcceptCircle; + Tizen::Graphics::Bitmap* __pAcceptDial; + Tizen::Graphics::Bitmap* __pRejectDial; + Tizen::Graphics::Bitmap* __pAcceptArrow; + Tizen::Graphics::Bitmap* __pRejectArrow; + Tizen::Ui::Controls::Label* __pAcceptLabel; //for dial + Tizen::Ui::Controls::Label* __pRejectLabel; + Tizen::Ui::Controls::Label* __pAcceptArrowLabel; + Tizen::Ui::Controls::Label* __pRejectArrowLabel; + Tizen::Ui::Controls::Panel* __pCallHandlePanel; + Tizen::Ui::Animations::VisualElement* __pAcceptVisElem; + Tizen::Ui::Animations::VisualElement* __pRejectVisElem; + Tizen::Ui::Animations::VisualElement* __pRejectFinalVisElem; + Tizen::Ui::Animations::VisualElement* __pAcceptFinalVisElem; + Tizen::Ui::Animations::VisualElement* __pAcceptArrowVisElem; + Tizen::Ui::Animations::VisualElement* __pRejectArrowVisElem; + CallOptionPopup* __pOptionPopup; + Tizen::Ui::Controls::Label* __pSmallPhotoLabel; +}; + +#endif // _PHN_INCOMING_CALL_FORM_H_ diff --git a/inc/PhnLogsDetailForm.h b/inc/PhnLogsDetailForm.h new file mode 100644 index 0000000..95df8bc --- /dev/null +++ b/inc/PhnLogsDetailForm.h @@ -0,0 +1,161 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnLogsDetailForm.h + * @brief This is the header file for the %DlLogsDetailForm class. + * + * This header file contains the declarations for %DlLogsDetailForm class. + */ +#ifndef _PHN_LOGS_DETAIL_FORM_H_ +#define _PHN_LOGS_DETAIL_FORM_H_ + +#include +#include +#include "PhnLogsDetailItemProvider.h" + +class CallLogDetails; +class CallLogManager; + +/** + * @class DlLogsDetailForm + * @brief This class presents a form based UI for call log details scene. + * + */ +class DlLogsDetailForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::App::IAppControlResponseListener + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ + +// Construction +public: + ///DlLogsDetailForm constructor + DlLogsDetailForm(void); + + ///DlLogsDetailForm destructor + virtual ~DlLogsDetailForm(void); + + ///Initializes the DlLogsDetailForm form + /* + * @param: Whether Initialize is success or not + */ + bool Initialize(); + + ///This functions gets called during form OnInitializing + /* + * @param: result + */ + result OnInitializing(void); + + ///This functions gets called during form terminating + /* + * @param: result + */ + result OnTerminating(void); + + ///IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + ///IFormBackEventListener method + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + + void SetFormMode(bool mode); + + void SetAllListItems(bool checked); + + void UnCheckAllItems(void); + + void GetUpdatedListFromDatabase(char* number); + + bool DeleteSelectedCalllog(void); + + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status); + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction); + + ///ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + ///ISceneEventListener + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + void UpdateForm(void); + /** + * Called when the application control is completed. + */ + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + +private: + ///Call button + Tizen::Ui::Controls::Button* __pButtonCall; + + ///Message button + Tizen::Ui::Controls::Button* __pButtonMessage; + + ///Contact Image + Tizen::Ui::Controls::Button* __pButtonContactImage; + + ///Contact name + Tizen::Ui::Controls::Label* __pLabelName; + + ///Contact number + Tizen::Ui::Controls::Label* __pLabelNumber; + Tizen::Ui::Controls::Label* __pLabelNumberUnsaved; + Tizen::Ui::Controls::Label* __pLabelBlocked; + + ///Form footer + Tizen::Ui::Controls::Footer* __pFormFooter; + + ///Delete footer item + Tizen::Ui::Controls::FooterItem __pFooterItemDelete; + + ///Delete footer item + Tizen::Ui::Controls::FooterItem __pFooterItemCancel; + + ///Grouped list view + Tizen::Ui::Controls::ListView* __pList; + + Tizen::Ui::Controls::CheckButton* __pSelectAll; + + //Selected pop up label + Tizen::Ui::Controls::Label* __pSelectedLabel; + + ///Grouped list view item provider + DlLogsDetailItemDataProvider* __pDataProvider; + + ///List view height + int __listHeight; + + ///form mode + bool __isEditMode; + + bool __isSelectAll; + bool __isPresentInContacts; + + int __listItemCount; + int __selectedItemCount; + //Tizen::Base::Collection::HashMapT* __calllogListByNum; + Tizen::Base::Collection::ArrayListT* __calllogListByNum; + CallLogManager* __pCallMgr; + int __calllogCount; + Tizen::Base::String __number; + bool __isMsgAppControlLaunched; +}; + +#endif /*_PHN_LOGS_DETAIL_FORM_H_*/ diff --git a/inc/PhnLogsDetailItemProvider.h b/inc/PhnLogsDetailItemProvider.h new file mode 100644 index 0000000..5d219d5 --- /dev/null +++ b/inc/PhnLogsDetailItemProvider.h @@ -0,0 +1,93 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnActiveCallForm.h + * @brief This is the header file for the %DlLogsDetailItemDataProvider class. + * + * This header file contains the declarations for %DlLogsDetailItemDataProvider class. + */ +#ifndef _PHN_LOGS_DETAIL_ITEM_PROVIDER_H_ +#define _PHN_LOGS_DETAIL_ITEM_PROVIDER_H_ + +#include +#include + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +class CallLogManager; +class CallLogDetails; + +/** + * @class DlLogsDetailItemDataProvider + * @brief This class provides Item provider for list memo + * + */ +class DlLogsDetailItemDataProvider + : public IListViewItemProvider +{ +public: + DlLogsDetailItemDataProvider(void); + + ~DlLogsDetailItemDataProvider(void); + + ///IListViewItemProvider method + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + + ///IListViewItemProvider method + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + + ///IListViewItemProvider method + virtual int GetItemCount(void); + + void SetViewMode(bool mode); + + void ResetDetailsList(void); + +protected: + static const int ID_NAME_STRING; + static const int ID_NUMBER_STRING; + static const int ID_TIME_STRING; + static const int ID_CALLTYPE_BITMAP; + + static const int X_TEXT_LINE1_ITEM; + static const int Y_TEXT_LINE1_ITEM; + static const int H_TEXT_LINE1_ITEM; + static const int W_TEXT_LINE1_ITEM; + + static const int X_TEXT_LINE2_ITEM; + static const int Y_TEXT_LINE2_ITEM; + static const int H_TEXT_LINE2_ITEM; + static const int W_TEXT_LINE2_ITEM; + + static const int X_TEXT_TIME_ITEM; + static const int Y_TEXT_TIME_ITEM; + static const int H_TEXT_TIME_ITEM; + static const int W_TEXT_TIME_ITEM; + + + static const int X_CALLTYPE_BITMAP_ITEM; + static const int Y_CALLTYPE_BITMAP_ITEM; + static const int H_CALLTYPE_BITMAP_ITEM; + static const int W_CALLTYPE_BITMAP_ITEM; +private: + bool __isEditMode; + CallLogManager* __pCallMgr; + Tizen::Base::Collection::IListT* __pCalllogListByNumber; +}; + +#endif /* _PHN_LOGS_DETAIL_ITEM_PROVIDER_H_ */ diff --git a/inc/PhnPanelFactory.h b/inc/PhnPanelFactory.h new file mode 100644 index 0000000..44d14cb --- /dev/null +++ b/inc/PhnPanelFactory.h @@ -0,0 +1,46 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPanelFactory.h + * @brief This is the header file for the %PanelFactory class. + * + * This header file contains the declarations for %PanelFactory class. + */ +#ifndef _PHN_PANEL_FACTORY_H_ +#define _PHN_PANEL_FACTORY_H_ + +#include + +extern const wchar_t* PANEL_DIALER; +extern const wchar_t* PANEL_LOGS; + +/** + * @class PanelFactory + * @brief This class provides the Panel factory for Dial application + * + */ +class PanelFactory + : public Tizen::Ui::Scenes::IPanelFactory +{ +public: + PanelFactory(void); + virtual ~PanelFactory(void); + + virtual Tizen::Ui::Controls::Panel* CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _PHN_PANEL_FACTORY_H_ diff --git a/inc/PhnPhoneApp.h b/inc/PhnPhoneApp.h new file mode 100644 index 0000000..3751455 --- /dev/null +++ b/inc/PhnPhoneApp.h @@ -0,0 +1,100 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPhoneApp.h + * @brief This is the header file for the %PhoneApp class. + * + * This header file contains the declarations for %PhoneApp class. + */ +#ifndef _PHN_PHONE_APP_H_ +#define _PHN_PHONE_APP_H_ + +#include +#include +#include +#include + +class IAppStateChangeListener; + +/** + * @class PhoneApp + * @brief PhoneApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + * + */ +class PhoneApp + : public Tizen::App::UiApp + , public Tizen::System::IScreenEventListener + , public Tizen::App::IAppControlProviderEventListener +{ +public: + + static Tizen::App::UiApp* CreateInstance(void); + +public: + PhoneApp(void); + virtual ~PhoneApp(void); + +public: + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + bool OnAppInitialized(void); + bool OnAppWillTerminate(void); + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + void OnForeground(void); + void OnBackground(void); + void OnLowMemory(void); + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + void OnScreenOn(void); + void OnScreenOff(void); + + // Called when the application control request is received from the caller application. + virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData); + + //Used to query whether application is initialized as AppControl. + bool IsOpenAsAppControl(void); + //Used to get the initial scene Id + Tizen::Ui::Scenes::SceneId GetInitialScene(void); + //Used to set initial scene id + void SetInitialScene(Tizen::Ui::Scenes::SceneId initialSceneId); + //Used to get launch arguments at application launch + Tizen::Base::Collection::IList* GetAppLaunchArguments(void); + + void AddAppStateChangeListener(const IAppStateChangeListener& listener); + void RemoveAppStateChangeListener(const IAppStateChangeListener& listener); + +private: + //internal function to process AppControl request. + void ProcessAppControlRequest(RequestId reqId, const Tizen::Base::String& operationId,const Tizen::Base::Collection::IMap* pArgsMap); + //internal function to handle AppControl Request for Incoming call. + void HandleIncomingCallAppControlRequest(RequestId reqId,const Tizen::Base::Collection::IMap* pArgsMap); + //internal function to handle AppControl Request for Dial. + void HandleDialerAppControlRequest(RequestId reqId,const Tizen::Base::Collection::IMap* pArgsMap); + //internal function to handle AppControl Request for dial call. + void HandleDialCallAppControlRequest(RequestId reqId,const Tizen::Base::Collection::IMap* pArgsMap); + //internal function to handle AppControl Request for call Settings. + void HandleSettingsAppControlRequest(RequestId reqId,const Tizen::Base::Collection::IMap* pArgsMap); + +private: + //Used to implement AppControl Specific features. + bool __isOpenAsAppControl; + Tizen::Base::Collection::ArrayList* __pLaunchArgs; + //Used to store initial scene id + Tizen::Ui::Scenes::SceneId __initialSceneId; + Tizen::Base::Collection::ArrayList __listenerList; +}; + +#endif // _PHN_PHONE_APP_H_ diff --git a/inc/PhnPhoneAppFrame.h b/inc/PhnPhoneAppFrame.h new file mode 100644 index 0000000..e1eb37a --- /dev/null +++ b/inc/PhnPhoneAppFrame.h @@ -0,0 +1,46 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPhoneAppFrame.h + * @brief This is the header file for the %PhoneAppFrame class. + * + * This header file contains the declarations for %PhoneAppFrame class. + */ +#ifndef _PHN_PHONE_APP_FRAME_H_ +#define _PHN_PHONE_APP_FRAME_H_ + +#include +#include + +/** + * @class PhoneAppFrame + * @brief This class presents a main application frame and performs scene registration. + * + */ +class PhoneAppFrame + : public Tizen::Ui::Controls::Frame +{ +public: + PhoneAppFrame(void); + virtual ~PhoneAppFrame(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif // _PHN_PHONE_APP_FRAME_H_ diff --git a/inc/PhnPhoneFormFactory.h b/inc/PhnPhoneFormFactory.h new file mode 100644 index 0000000..a03a08f --- /dev/null +++ b/inc/PhnPhoneFormFactory.h @@ -0,0 +1,88 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPhoneFormFactory.h + * @brief This is the header file for the %FormFactory class. + * + * This header file contains the declarations for %FormFactory class. + */ +#ifndef _PHN_PHONE_FORM_FACTORY_H_ +#define _PHN_PHONE_FORM_FACTORY_H_ + +#include +#include "PhnBaseForm.h" + +//Corresponding Call form name +extern const wchar_t* IDL_FORM_OUTCALL; +extern const wchar_t* IDL_FORM_OUT_EMERGENCYCALL; +extern const wchar_t* IDL_FORM_INCOMINGCALL; +extern const wchar_t* IDL_FORM_ACTIVECALL; +extern const wchar_t* IDL_FORM_ACTIVE_EMERGENCYCALL; +extern const wchar_t* IDL_FORM_CONFCALL; +extern const wchar_t* IDL_FORM_CONFCALLLIST; +extern const wchar_t* IDL_FORM_ENDCALL; +extern const wchar_t* IDL_FORM_MULTIPLEACTIVECALL; +//Corresponding Settings form name +extern const wchar_t* IDL_FORM_SETTINGS_PREFIX; +extern const wchar_t* IDL_FORM_MAIN_SETTING_MENU; +extern const wchar_t* IDL_FORM_CALL_REJECTLIST_MENU; +extern const wchar_t* IDL_FORM_CALL_REJECTMSGS_MENU; +extern const wchar_t* IDL_FORM_SPEED_DIAL; +extern const wchar_t* IDL_FORM_MORE_OPTIONS; +extern const wchar_t* IDL_FORM_CALL_STATUSTONES; +extern const wchar_t* IDL_FORM_CALLTYPE_FORWARD; +extern const wchar_t* IDL_FORM_CALL_FORWARD_OPTIONS; +extern const wchar_t* IDL_FORM_CALLTYPE_BARRING; +extern const wchar_t* IDL_FORM_CALL_BARRING_OPTIONS; +extern const wchar_t* IDL_FORM_CALL_WAITING_OPTIONS; +extern const wchar_t* IDL_FORM_ADD_REJECT_NUMBER; +extern const wchar_t* IDL_FORM_AUTO_AREA_CODE; +extern const wchar_t* IDL_FORM_ADD_REJECT_MSG; +extern const wchar_t* IDL_FORM_EDIT_REJECT_MSG; +extern const wchar_t* IDL_FORM_FORWARD_TO_NUMBER; +extern const wchar_t* IDL_FORM_NOREPLY_FORWARD_TO_NUMBER; +extern const wchar_t* IDL_FORM_SCENE_SET_BARRING_PWD; +extern const wchar_t* IDL_FORM_DEL_NUMBER; +extern const wchar_t* IDL_FORM_DEL_MESSAGE; +//Dialer & Call Log Form names +extern const wchar_t* IDL_FORM_DIAL_APP; +extern const wchar_t* IDL_FORM_CALL_LOG_DETAIL; + +/** + * @class FormFactory + * @brief This class presents a form factory functionality for all forms. + * + */ +class FormFactory + : public Tizen::Ui::Scenes::IFormFactory +{ +public: + FormFactory(void); + virtual ~FormFactory(void); + + //Factory Method from IFormFactory + virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); + +private: + //Used to create forms related to Voice Call module + Tizen::Ui::Controls::Form* CreateVoiceCallForm(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); + //Used to create forms related to Call Settings module + Tizen::Ui::Controls::Form* CreateCallSettingsForm(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); + +}; + +#endif // _PHN_PHONE_FORM_FACTORY_H_ diff --git a/inc/PhnRetrieveSuggestionsTasks.h b/inc/PhnRetrieveSuggestionsTasks.h new file mode 100644 index 0000000..b94650c --- /dev/null +++ b/inc/PhnRetrieveSuggestionsTasks.h @@ -0,0 +1,119 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnRetrieveSuggestionsTasks.h + * @brief This is the header file for the %RetrieveContactsListTask class. + * + * This header file contains the declarations for %RetrieveContactsListTask class. + */ +#ifndef _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_ +#define _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_ + +#include +#include + +class DialContactInfo; +//class CallLogDetails; + +/** + * @class ISuggestionsRetrievedEventListener + * @brief This is event listener interface for informing that + * the retrieval of contact suggestion list is completed. + */ +class ISuggestionsRetrievedEventListener +{ +public: + virtual ~ISuggestionsRetrievedEventListener(void){}; + + /** + * Called when the retrieval of contact suggestion list is completed. + * Ownership transferred for 'pContactsMap' to listener. + */ + virtual void HandleContactsRetrievalCompleted(Tizen::Base::Collection::IList* pContactsMap) = 0; +}; + +/** + * @class RetrieveContactsListTask + * @brief This Class used to provide Thread functionality for all Search Tasks asynchronously. + * + */ +class RetrieveContactsListTask + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IRunnable +{ +public: + RetrieveContactsListTask( ISuggestionsRetrievedEventListener& pEventListener); + //Destructor + ~RetrieveContactsListTask(void); + //2nd phase contruct to initialize search string and old search results if present. + result Construct(Tizen::Base::String& searchString,const Tizen::Base::Collection::IList* oldSearchResults); + ///called when the thread for search task starts + virtual Tizen::Base::Object* Run(void); + +private: + //internal function to search speed-dial numbers and add to list + void SearchSpeedDialForNumberN(void); + //internal function to search contacts by phone number and add to list. + void SearchContactsForNumber(void); + //internal function to searches call logs for phone number and add to list. + /*void SearchCallLogsForNumber(void);*/ + //internal function to search contacts by name and add to list. + void SearchContactsForName(void); + //internal function to save contacts starting with 'searchStr'. + void SearchContactsWithInitialChar(Tizen::Base::String& searchStr); + //internal function to update the already fetched suggestion list + void UpdateSuggestionList(void); + + //internal function to save searched contact by number to single consolidated list. + void SaveContactsToListByNumber(Tizen::Base::Collection::IList& saveList, Tizen::Base::String& matchedString); + /** + * internal function to convert Contact to DialContactInfo. + * return null, if the contact does not have any phone numbers assigned to it. + */ + DialContactInfo* ConvertToDialContactN(Tizen::Social::Contact& contact, Tizen::Base::String& matchedString); + /*DialContactInfo* ConvertLogDetailsToDialContactN(CallLogDetails& logDetails);*/ + +private: + Tizen::Social::Addressbook* __pAddressBook; + ISuggestionsRetrievedEventListener& __pEventListener; + Tizen::Base::Collection::ArrayList* __pContactsList; + Tizen::Base::String* __pNumberStr; +}; + +/** + * @class SuggestionListComparer + * @brief This Class is used to compare 2 objects of 'DialContactInfo' type and returns the comparison results. + * This class can be used to sort an ArrayList of 'DialContactInfo' objects. + */ +class SuggestionListComparer +: public Tizen::Base::Collection::IComparer +{ +public: + SuggestionListComparer(){}; + virtual ~SuggestionListComparer(){}; + /** + * Used to compare two reference of 'DialContactInfo' and return 'cmpResult' as the comparison result. + * + * @code + * < 0 if the value of @c obj1 is less than the value of @c obj2 + * == 0 if the value of @c obj1 is equal to the value of @c obj2 + * > 0 if the value of @c obj1 is greater than the value of @c obj2 + */ + virtual result Compare(const Tizen::Base::Object& objRef1, const Tizen::Base::Object& objRef2, int& cmpResult) const; +}; + +#endif // _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_ diff --git a/inc/PhnSceneRegister.h b/inc/PhnSceneRegister.h new file mode 100644 index 0000000..51547d8 --- /dev/null +++ b/inc/PhnSceneRegister.h @@ -0,0 +1,77 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSceneRegister.h + * @brief This is the header file for the %SceneRegister class. + * + * This header file contains the declarations for %SceneRegister class. + */ +#ifndef _PHN_SCENE_REGISTER_H_ +#define _PHN_SCENE_REGISTER_H_ + +//Constants - Call Scene name +extern const wchar_t* IDSCN_SCENE_OUTCALL; +extern const wchar_t* IDSCN_SCENE_OUT_EMERGENCYCALL; +extern const wchar_t* IDSCN_SCENE_INCOMINGCALL; +extern const wchar_t* IDSCN_SCENE_ACTIVECALL; +extern const wchar_t* IDSCN_SCENE_ACTIVE_EMERGENCYCALL; +extern const wchar_t* IDSCN_SCENE_CONFCALL; +extern const wchar_t* IDSCN_SCENE_CONFCALLLIST; +extern const wchar_t* IDSCN_SCENE_ENDCALL; +extern const wchar_t* IDSCN_SCENE_MULTIPLEACTIVECALL; +//Settings Scene name +extern const wchar_t* IDSCN_SCENE_MAIN_SETTING_MENU; +extern const wchar_t* IDSCN_SCENE_CALL_REJECTLIST_MENU; +extern const wchar_t* IDSCN_SCENE_CALL_REJECTMSGS_MENU; +extern const wchar_t* IDSCN_SCENE_SPEED_DIAL; +extern const wchar_t* IDSCN_SCENE_MORE_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALL_STATUSTONES; +extern const wchar_t* IDSCN_SCENE_CALLTYPE_FORWARD; +extern const wchar_t* IDSCN_SCENE_CALL_FORWARD_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALLTYPE_BARRING; +extern const wchar_t* IDSCN_SCENE_CALL_BARRING_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALL_WAITING_OPTIONS; +extern const wchar_t* IDSCN_SCENE_ADD_REJECT_NUMBER; +extern const wchar_t* IDSCN_SCENE_AUTO_AREA_CODE; +extern const wchar_t* IDSCN_SCENE_ADD_REJECT_MSG; +extern const wchar_t* IDSCN_SCENE_EDIT_REJECT_MSG; +extern const wchar_t* IDSCN_SCENE_FORWARD_TO_NUMBER; +extern const wchar_t* IDSCN_SCENE_NOREPLY_FORWARD_TO_NUMBER; +extern const wchar_t* IDSCN_SCENE_SET_BARRING_PWD; +extern const wchar_t* IDSCN_SCENE_DEL_NUMBER; +extern const wchar_t* IDSCN_SCENE_DEL_MESSAGE; +//Dialer & Call Log Scene names +extern const wchar_t* IDSCN_DIALER; +extern const wchar_t* IDSCN_CALL_LOG; +extern const wchar_t* IDSCN_CALL_LOG_DETAILS; + +/** + * @class SceneRegister + * @brief This class presents function to register all scenes. + * + */ +class SceneRegister +{ +public: + SceneRegister(void); + ~SceneRegister(void); + + //This function is used to register all scenes. + static result RegisterAllScenes(void); +}; + +#endif // _PHN_SCENE_REGISTER_H_ diff --git a/inc/PhnSettingsAddNumberForm.h b/inc/PhnSettingsAddNumberForm.h new file mode 100644 index 0000000..1dec11c --- /dev/null +++ b/inc/PhnSettingsAddNumberForm.h @@ -0,0 +1,166 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsAddNumberForm.h + * @brief This is the header file for the %SettingsAddNumberForm class. + * + * This header file contains the declarations for %SettingsAddNumberForm class. + */ +#ifndef _PHN_SETTINGS_ADD_NUMBER_FORM_H_ +#define _PHN_SETTINGS_ADD_NUMBER_FORM_H_ + +#include +#include + +/** + * @class SettingsAddNumberForm + * @brief This class presents a settings form based UI for call settings. + * + */ +class SettingsAddNumberForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::ITextEventListener + , public Tizen::Ui::IKeypadEventListener + , public Tizen::App::IAppControlResponseListener +{ +public: + enum FormType + { + FORMTYPE_NUMBER_TO_REJECT, + FORMTYPE_AUTO_AREA_CODE, + }; + +public: + SettingsAddNumberForm(FormType formType); + virtual ~SettingsAddNumberForm(void); + void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + //From IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //From ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + + //From IKeypadEventListener + virtual void OnKeypadWillOpen(Tizen::Ui::Control& source); + virtual void OnKeypadOpened(Tizen::Ui::Control& source){}; + virtual void OnKeypadClosed(Tizen::Ui::Control& source){}; + virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}; + virtual void OnKeypadBoundsChanged(Tizen::Ui::Control& source){}; + + //Launches contacts app control for pick operation + void LaunchContactsAppControl(void); + //From IAppControlResponseListener + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + + // Called when a text is changed. + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + // Called when a change made to the text is canceled. + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + +private: + // This function is used to collapse selective groups while form initialization only. + void CollapseSelectiveGroups(Tizen::Ui::Controls::GroupedTableView* pMainMenuTableView); + //Function is used to initialize header and headerItems. + void InitializeHeader(void); + //Function is used to initialize numeric edit field. + void InitializeNumberEditField(void); + //Initialize group table view. + result InitializeGroupedTableView(void); + // This function is used to create list items which come under "GROUP_CRITERIA_OPTIONS". + Tizen::Ui::Controls::TableViewItem* CreateCriteriaOptionsMenuItem(int itemIndex, int itemWidth); + // This function is used to create "GROUP_SELECT_CRITERIA". + Tizen::Ui::Controls::TableViewItem* CreateExpandableCriteriaItem(int itemWidth); + //function is used to set and change expand icon to expandable item based on its state. + void SetExpandIconToItem(Tizen::Ui::Controls::TableViewItem* pItem, bool isExpanded); + // This function is used to handle selection of 'GROUP_SELECT_CRITERIA'. + void ToggleGroupExpansion(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex); + // This function is used to handle selection of matching criteria. + void HandleMatchingCriteriaSelected(Tizen::Ui::Controls::GroupedTableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status); + //Function is used to go to previous form, based on current form state. + void GoBackToPreviousForm(void); + Tizen::Base::String FetchTextForCriteria(int itemIndex); + //Used to show error message box + void ShowDuplicateErrorMessageBox(Tizen::Base::String& message); + +private: + //Main Group Items for group list view + enum CriteriaGroupId + { + GROUP_SELECT_CRITERIA = 0, + GROUP_CRITERIA_OPTIONS, + GROUP_TOTALCOUNT, + }; + //Items for 'GROUP_SELECT_CRITERIA' + enum GroupSelectCriteriaItems + { + SELECTCRITERIA_MATCH_CRITERIA, + SELECTCRITERIA_TOTALCOUNT, //No of options in "caller id" drop down menu + }; + //Items for 'GROUP_CRITERIA_OPTIONS' + enum GroupCriteriaOptionsItems + { + CRITERIAOPTIONS_EXACT, + CRITERIAOPTIONS_STARTSWITH, + CRITERIAOPTIONS_ENDSWITH, + CRITERIAOPTIONS_INCLUDE, + CRITERIAOPTIONS_TOTALCOUNT, + }; + //used to store form state. + FormType __formType; + GroupCriteriaOptionsItems __selectedCriteria; + bool __isCriteriaOptionsMenuExpanded; + Tizen::Base::String __activePrefixDialingNumber; + bool __isContactAppControlLaunched; +}; + +#endif //_PHN_SETTINGS_ADD_NUMBER_FORM_H_ diff --git a/inc/PhnSettingsBarringPwdForm.h b/inc/PhnSettingsBarringPwdForm.h new file mode 100644 index 0000000..5cf0ed5 --- /dev/null +++ b/inc/PhnSettingsBarringPwdForm.h @@ -0,0 +1,77 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsBarringPwdForm.h + * @brief This is the header file for the %SettingsBarringPwdForm class. + * + * This header file contains the declarations for %SettingsBarringPwdForm class. + */ +#ifndef _PHN_SETTINGS_BARRING_PWD_FORM_H_ +#define _PHN_SETTINGS_BARRING_PWD_FORM_H_ + +#include +#include +#include "PhnErrorMsgPopup.h" +#include "PhnSettingsConstants.h" + +/** + * @class SettingsBarringPwdForm + * @brief This class presents a settings form based UI for call settings barring password. + * + */ +class SettingsBarringPwdForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::ITextEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Scenes::ISceneEventListener + , public IPopupClosedEventListener +{ +public: + SettingsBarringPwdForm(void); + virtual ~SettingsBarringPwdForm(void); + void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + //From IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //From ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + //From ITextEventListener + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + +private: + //Function is used to initialise header and header items. + void InitializeHeader(void); + void ShowErrorMessage(int errorCode); + +private: + //call Barring condition to be set + CallBarringType __callBarringCondition; + //State of the condition to be set; + bool __conditionState; + //Ownership + ErrorMsgPopup* __pErrorMsgPopup; +}; + +#endif //_PHN_SETTINGS_BARRING_PWD_FORM_H_ diff --git a/inc/PhnSettingsCallForwardWaitBarrForm.h b/inc/PhnSettingsCallForwardWaitBarrForm.h new file mode 100644 index 0000000..7c329a3 --- /dev/null +++ b/inc/PhnSettingsCallForwardWaitBarrForm.h @@ -0,0 +1,197 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsCallForwardWaitBarrForm.h + * @brief This is the header file for the %SettingsCallForwardWaitBarrForm class. + * + * This header file contains the declarations for %SettingsCallForwardWaitBarrForm class. + */ +#ifndef _PHN_SETTINGS_CALL_FORWARD_WAIT_BARR_FORM_H_ +#define _PHN_SETTINGS_CALL_FORWARD_WAIT_BARR_FORM_H_ + +#include +#include +#include "PhnErrorMsgPopup.h" +#include "PhnISettingsEventListener.h" + +class SettingsPresentationModel; + +/** + * @class SettingsCallForwardWaitBarrForm + * @brief This class presents a settings form based UI for call settings - Forwarding, waiting, barring call . + * + */ +class SettingsCallForwardWaitBarrForm + : public ISettingsEventListener + , public IPopupClosedEventListener + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + enum FormType + { + FORMTYPE_CALLFORWARDING_TYPE, //decide voice/video type for forwarding + FORMTYPE_VOICE_CALLFORWARDING, //actual options for call forwarding + FORMTYPE_CALLBARRING_TYPE, //decide voice/video type for barring + FORMTYPE_VOICE_CALLBARRING, //actual options for call barring + FORMTYPE_CALL_WAITING, //call waiting options + }; + +public: + SettingsCallForwardWaitBarrForm(FormType formType); + virtual ~SettingsCallForwardWaitBarrForm(void); + void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + //From IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //From IFormBackEventListener + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + //From ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + + //From ISettingsEventListener + virtual void HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated); + virtual void HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled); + virtual void HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime); + virtual void HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime); + virtual void HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated); + virtual void HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated); + + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + +private: + //Function is used to initialize group table menu + result InitializeGroupedTableView(void); + // Function is used to create list items which come under "CallTypeItemIds" + Tizen::Ui::Controls::TableViewItem* CreateSettingCallTypeMenuItem(int itemIndex, int itemWidth); + // Function is used to handle item selection which come under "CallTypeItemIds" + void HandleCallTypeSelected(int itemIndex); + // Function is used to create list items under "CallForwardItemIds" + Tizen::Ui::Controls::TableViewItem* CreateCallForwardingOptions(int itemIndex, int itemWidth); + // Function is used to handle item selection for "CallForwardItemIds" + void HandleCallForwardingOptionSelected(int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status); + // Function is used to create list items only which come under "CallBarringItemIds" + Tizen::Ui::Controls::TableViewItem* CreateCallBarringOptions(int itemIndex, int itemWidth); + // Function is used to handle item selection for "CallBarringItemIds" + void HandleCallBarringOptionSelected(int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status); + // This function is used to create list items which come under "CallBarringItemIds" + Tizen::Ui::Controls::TableViewItem* CreateCallWaitingOptions(int itemIndex, int itemWidth); + // Function is used to handle item selection for "CallWaitingItemIds" + void HandleCallWaitingOptionSelected(Tizen::Ui::Controls::TableViewItem* pItem, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status); + // Used to show error message popup + void ShowErrorMessage(int errorCode); + //used to un-check all items in group + void UncheckAllOptions(void); + //Used to fetch processing animation and construct animation list. + void ConstructAnimationList(void); + +private: + //Groups supported by group table view + enum CallGroupTypes + { + CALLTYPE_GROUP, + CALLWAITING_GROUP, + CALLBARRING_GROUP, + CALLFORWARDING_GROUP, + CALLGROUP_COUNT, + }; + //Setting ids for "CALLFORWARDING_GROUP" group + enum CallForwardItemIds + { + CALLFORWARD_ALWAYS, + CALLFORWARD_IF_BUSY, + CALLFORWARD_IF_NO_REPLY, + CALLFORWARD_IF_OUT_OF_REACH, + CALLFORWARD_TOTALITEMCOUNT, //always the last element to get settings count + }; + //Setting ids for "CALLBARRING_GROUP" group + enum CallBarringItemIds + { + CALLBARRING_ALL_OUTGOING_CALL, + CALLBARRING_INTERNATIONAL_CALL, + CALLBARRING_INTERNATIONAL_EXCEPT_HOME, + CALLBARRING_ALL_INCOMING_CALL, + CALLBARRING_INCOMING_WHILE_ROAMING, + CALLBARRING_TOTALCOUNT, //always the last element to get settings count + }; + //Setting ids for "CALLWAITING_GROUP" group + enum CallWaitingItemIds + { + CALLWAITING_ITEM, + CALLWAITING_TOTALCOUNT, //always the last element to get settings count + }; + + enum CallTypeItemIds + { + CALLTYPE_VOICE_CALL, +// CALLTYPE_VIDEO_CALL, + CALLTYPE_TOTALCOUNT, //always the last element to get group count + }; + + //used to record which view to open - Call Forwarding, Barring, Waiting. + FormType __formType; + SettingsPresentationModel* __pSettingsPresentor; + //Ownership + ErrorMsgPopup* __pErrorMsgPopup; + //used to check if 'CALLFORWARD_ALWAYS' is activated + bool __isCallForwardAlwaysActivated; + //For processing animation + Tizen::Base::Collection::ArrayList* __pAnimationFrameList; + //Used to check if call waiting status is available. + bool __isCallWaitingStatusAvailable; + //Used to check call waiting is Enabled + bool __isCallWaitingEnabled; +}; + +#endif //_PHN_SETTINGS_CALL_FORWARD_WAIT_BARR_FORM_H_ diff --git a/inc/PhnSettingsCallStatusTonesForm.h b/inc/PhnSettingsCallStatusTonesForm.h new file mode 100644 index 0000000..404f365 --- /dev/null +++ b/inc/PhnSettingsCallStatusTonesForm.h @@ -0,0 +1,127 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsCallStatusTonesForm.h + * @brief This is the header file for the %SettingsCallStatusTonesForm class. + * + * This header file contains the declarations for %SettingsCallStatusTonesForm class. + */ +#ifndef _PHN_SETTINGS_CALL_STATUS_TONES_FORM_H_ +#define _PHN_SETTINGS_CALL_STATUS_TONES_FORM_H_ + +#include +#include + +class SettingsPresentationModel; + +/** + * @class SettingsCallStatusTonesForm + * @brief This class presents a settings form based UI for call settings - call status tones. + * + */ +class SettingsCallStatusTonesForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + SettingsCallStatusTonesForm(void); + virtual ~SettingsCallStatusTonesForm(void); + void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + +private: + //create call reminders status menu + result InitializeGroupedTableView(void); + +private: + //Groups for menu + enum TonesMenuGroupId + { + GROUP_CALL_CONNECT, + GROUP_CALL_CONNECT_HLPTXT, + GROUP_CALL_REMINDER, + GROUP_CALL_REMINDER_HLPTXT, + GROUP_CALL_END, + GROUP_CALL_END_HLPTXT, + GROUP_TOTALCOUNT, //always the last element to get group count + }; + + //Items for "GROUP_CALL_CONNECT" group + enum CallConnectItems + { + CALLCONNECT_CONNECT_TONE, + CALLCONNECT_TOTALCOUNT, + }; + + //Items for "GROUP_CALL_REMINDER" group + enum CallReminderItems + { + CALLREMINDER_MINUTE_REMINDERS, + CALLREMINDER_TOTALCOUNT, + }; + + //Items for "GROUP_CALL_END" group + enum CallEndItems + { + CALLEND_END_TONE, + CALLEND_TOTALCOUNT, + }; + + //Singleton. + SettingsPresentationModel* __pSettingsPresentor; +}; + +#endif //_PHN_SETTINGS_CALL_STATUS_TONES_FORM_H_ diff --git a/inc/PhnSettingsConstants.h b/inc/PhnSettingsConstants.h new file mode 100644 index 0000000..a75ab29 --- /dev/null +++ b/inc/PhnSettingsConstants.h @@ -0,0 +1,289 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsConstants.h + * @brief This is the header file for providing common constants across application. + * + */ +#ifndef _PHN_SETTINGS_CONSTANTS_H_ +#define _PHN_SETTINGS_CONSTANTS_H_ + +#include +#include +#include + +enum ActionId +{ + IDA_VOICEMAIL = 1, + IDA_SELECT_PHOTO2, + IDA_SELECT_PHOTO3, + IDA_SELECT_PHOTO4, + IDA_SELECT_PHOTO5, + IDA_SELECT_PHOTO6, + IDA_SELECT_PHOTO7, + IDA_SELECT_PHOTO8, + IDA_SELECT_PHOTO9, + IDA_SELECT_CONTACT, +}; + +enum FooterActionId +{ + IDA_ADD_FOOTER_ITEMID = IDA_SELECT_CONTACT + 1, + IDA_DELETE_FOOTER_ITEMID, + IDA_CANCEL_FOOTER_ITEMID, + IDA_NOACTION_ITEMID, +}; + +enum HeaderActionId +{ + IDA_SAVE_HEADER_ITEMID = IDA_NOACTION_ITEMID + 1, + IDA_CANCEL_HEADER_ITEMID, +}; + +enum PopupActionId +{ + IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP = IDA_CANCEL_HEADER_ITEMID + 1, + IDA_UPDATE_SPEED_DIAL, + IDA_REMOVE_SPEED_DIAL, +}; +enum CallForwardCondition +{ + CALL_FORWARD_ALL, /* Forward All Calls */ + CALL_FORWARD_BUSY, /* Forward if Busy */ + CALL_FORWARD_NO_REPLY, /* Forward if No Reply */ + CALL_FORWARD_NOT_REACHABLE /* Forward if Not Reachable */ +}; + +enum CallBarringType +{ + CALL_BARRING_ALL_OUTGOING, /* Barring All Outgoing Calls */ + CALL_BARRING_INTERNATIONAL_OUTGOING, /* Barring Outgoing International Calls */ + CALL_BARRING_INTERNATIONAL_EXCEPT_HOME, /* Barring Outgoing International Calls except to Home Country */ + CALL_BARRING_ALL_INCOMING, /* Barring All Incoming Calls */ + CALL_BARRING_INCOMING_ROAMING /* Barring Incoming Calls when roam*/ +}; + +enum CallLineIdentity +{ + CALL_LINE_IDENTITY_DEFAULT = 0, /**< Calling line identity will be sent. Based on network setting, Line identity will presented to the called party. */ + CALL_LINE_IDENTITY_SHOW, /**< Display calling line identity */ + CALL_LINE_IDENTITY_HIDE /**< Hide the display of Calling line identity */ +}; + +enum CallRejectMatchCondition +{ + CALL_REJECT_MATCH_EXACTLY = 1, + CALL_REJECT_MATCH_START, + CALL_REJECT_MATCH_END, + CALL_REJECT_MATCH_INCLUDE, +}; + +enum CallRejectUpdateField +{ + CALL_REJECT_UPDATE_RULE = 1, + CALL_REJECT_UPDATE_NUMBER, + CALL_REJECT_UPDATE_ACTIVATE +}; + +enum CallAlertStatus +{ + CALL_ALERT_OFF = 0, + CALL_ALERT_SOUND, + CALL_ALERT_VIBRATE +}; + +enum CallState +{ + /** No call connected */ + CALL_STATE__CALL_OFF = 0, + /** Voice call is connecting */ + CALL_STATE_CALL_VOICE_CONNECTING, + /** Voice call is connected */ + CALL_STATE_CALL_VOICE_ACTIVE, + /** Video call is connecting */ + CALL_STATE_CALL_VIDEO_CONNECTING, + /** Video call is connecting */ + CALL_STATE_CALL_VIDEO_ACTIVE, + + CALL_STATE_MAX + +}; + +//Settings UI contants +// Colors used in List views // +extern const unsigned int COLOR_GROUP_ITEM_BG; +extern const unsigned int COLOR_LIST_MENU_ITEM; +extern const unsigned int COLOR_SECONDDEPTH_ITEM_BG; +extern const unsigned int COLOR_HELP_ITEM_BG; +extern const unsigned int COLOR_NORMAL_MAIN_TXT; +extern const unsigned int COLOR_NORMAL_SUB_TXT; +extern const unsigned int COLOR_PRESS_SUB_TXT; +extern const unsigned int COLOR_PRESS_MAIN_TXT; +extern const unsigned int COLOR_HELP_TXT; +extern const unsigned int COLOR_LEFT_HEADER_EXPAND_ITEMS; +//Main List Option text +extern const unsigned int COLOR_MAIN_TXT; +//Main List text +extern const int FONT_SIZE_MAIN_TXT; +extern const int FONT_SIZE_SUB_TXT; +//Help text +extern const int FONT_SIZE_HELP_TXT; +extern const int W_HDR_FTR_ICON; +extern const int H_HDR_FTR_ICON; +//Processing Animation constants +extern const int IDI_ANIM_DURATION; +extern const int IDI_ANIM_PROGRESS_COUNT; +//Delete List +extern const unsigned int COLOR_NORMAL_ITEM_BG; +extern const unsigned int COLOR_PRESS_ITEM_BG; +extern const unsigned int COLOR_SELECTALL_ITEM_BG; + +// Dimensions used in List views // +// menu item height +extern const int H_LIST_HIDDENGROUP_ITEM; +extern const int H_LIST_NORMAL_MENU_ITEM; +extern const int H_LIST_DROPDOWN_MENU_ITEM; +extern const int H_LIST_MENU_SINGLELINE_HLPTXT_ITEM; +extern const int H_LIST_MENU_TWOLINE_HLPTXT_ITEM; +//text item height +extern const int H_LIST_NORMAL_TXT_ITEM; +extern const int H_LIST_SUB_TXT_ITEM; +//Two line text for Drop down menu item +extern const int H_LIST_DROPDOWN_TXT_ITEM; +//single line text +extern const int X_LIST_MENU_TEXT_ITEM; +extern const int Y_LIST_MENU_TEXT_ITEM; +//Help text +extern const int X_LIST_MENU_HLPTXT_ITEM; +extern const int Y_LIST_MENU_HLPTXT_ITEM; +//custom Item for Bg line +extern const int Y_CUSTOM_BG_ELEMENT; +//Position for delete list item +extern const int X_DEL_LIST_ELEMENT; +extern const int Y_DEL_LIST_ELEMENT; + +// Dimensions for icons // +//Expand icon for DropDown Menu Items +extern const int W_EXPAND_ICON; +extern const int H_EXPAND_ICON; +extern const int W_SLIDER_ICON; +extern const int H_SLIDER_ICON; +//contact icon for Add Rejected Number view +extern const int W_CONTACT_ICON; +extern const int H_CONTACT_ICON; +//Dimensions for custom bg line +extern const int W_CUSTOM_BG_ELEMENT; +//Item Width for delete list +extern const int W_DELETE_LIST_ITEM; +//Width of Blue Header Rectangle for expandable group items +extern const int W_LEFT_HEADER_EXPAND_ITEMS; + +// String Constants - Bitmap File +extern const wchar_t* IDB_CONTROLBAR_SAVE_ICON; +extern const wchar_t* IDB_CONTROLBAR_ICON_DELETE; +extern const wchar_t* IDB_CANCEL_BTN_NORMAL; +extern const wchar_t* IDB_VOICECALL_ICON; +extern const wchar_t* IDB_LIST_EXPAND; +extern const wchar_t* IDB_LIST_EXPAND_PRESSED; +extern const wchar_t* IDB_LIST_OPENED; +extern const wchar_t* IDB_LIST_OPENED_PRESSED; +extern const wchar_t* IDB_BACK_HEADER_ITEM; +extern const wchar_t* IDB_BACK_HEADER_ITEM_PRESSED; +extern const wchar_t* IDB_CANCEL_FOOTER_ITEM; +extern const wchar_t* IDB_PROCESSING_ICONS; + +//control name +extern const wchar_t* IDC_GROUPEDTABLEVIEW; +extern const wchar_t* IDC_LISTVIEW; +extern const wchar_t* IDC_NUMBER_EDITFIELD; +extern const wchar_t* IDC_SELECT_CONTACT_BUTTON; +extern const wchar_t* IDC_FOWARDING_NUMBER_EDITFIELD; +extern const wchar_t* IDC_VOICEMAIL_BUTTON; +extern const wchar_t* IDC_REJECTMSG_EXPANDABLEEDITAREA; +extern const wchar_t* IDC_EDITFIELD; +extern const wchar_t* IDC_SELECTEDOPTION_SUBTEXT_LABEL; +extern const wchar_t* IDC_ANIMATION_CONTROL; + +//resource string contants +extern const wchar_t* IDS_ADD_BTN_STRING; +extern const wchar_t* IDS_DELETE_BTN_STRING; +extern const wchar_t* IDS_CANCEL_BTN_STRING; +extern const wchar_t* IDS_REMOVE_CONTACT; +extern const wchar_t* IDS_DELETE_NUMBER_TITLE; +extern const wchar_t* IDS_DELETE_MSGS_TITLE; +extern const wchar_t* IDS_SELECT_ALL_LIST_ITEM_STRING; +extern const wchar_t* IDS_DEFAULT_REJECT_ITEM_STRING; +extern const wchar_t* IDS_SETTINGS_MATCHCRITERIA_STRING; +extern const wchar_t* IDS_CALLERID_BYNETWORK_STRING; +extern const wchar_t* IDS_CALLERID_SHOW_STRING; +extern const wchar_t* IDS_CALLERID_HIDE_STRING; +extern const wchar_t* IDS_SETTING_CALLALERT_OFF_STRING; +extern const wchar_t* IDS_SETTING_CALLALERT_SOUND_STRING; +extern const wchar_t* IDS_SETTING_CALLALERT_VIBRATE_STRING; +extern const wchar_t* IDS_SETTING_BARRING_STRING; +extern const wchar_t* IDS_SETTING_WAITING_STRING; +extern const wchar_t* IDS_SETTING_WAITING_HLP_STRING; +extern const wchar_t* IDS_SETTING_STATUS_TONES_STRING; +extern const wchar_t* IDS_SETTING_STATUS_TONES_HLP_STRING; +extern const wchar_t* IDS_SETTING_AUTO_AREACODE_STRING; +extern const wchar_t* IDS_SETTING_AUTO_AREACODE_HLP_STRING; +extern const wchar_t* IDS_SETTING_REJECT_STRING; +extern const wchar_t* IDS_SETTING_REJECT_HLP_STRING; +extern const wchar_t* IDS_SETTING_REJECT_MSG_STRING; +extern const wchar_t* IDS_SETTING_REJECT_MSG_HLP_STRING; +extern const wchar_t* IDS_SETTING_SPEEDDIAL_STRING; +extern const wchar_t* IDS_SETTING_FORWARDING_STRING; +extern const wchar_t* IDS_SETTING_MORE_MAIN_STRING; +extern const wchar_t* IDS_SETTING_MORE_SUB_STRING; +extern const wchar_t* IDS_SETTING_WAITING_TIME_STRING; +extern const wchar_t* IDS_SETTING_WAIT_INTERVAL_STRING; +extern const wchar_t* IDS_SETTING_CONNECTTONE_STRING; +extern const wchar_t* IDS_SETTING_CONNECTTONE_HLP_STRING; +extern const wchar_t* IDS_SETTING_REMINDERS_STRING; +extern const wchar_t* IDS_SETTING_REMINDERS_HLP_STRING; +extern const wchar_t* IDS_SETTING_ENDTONE_STRING; +extern const wchar_t* IDS_SETTING_ENDTONE_HLP_STRING; +extern const wchar_t* IDS_SETTING_FORWARD_CALLTYPE_TITLE; +extern const wchar_t* IDS_SETTING_BARRING_CALLTYPE_TITLE; +extern const wchar_t* IDS_SETTING_VOICEFORWARD_OPTIONS_TITLE; +extern const wchar_t* IDS_SETTING_VOICEBARRING_OPTIONS_TITLE; +extern const wchar_t* IDS_SETTING_WAITING_OPTIONS_TITLE; +extern const wchar_t* IDS_SETTING_CALLTYPE_VOICE_STRING; +extern const wchar_t* IDS_SETTING_VOICEFORWARD_ALWAYS; +extern const wchar_t* IDS_SETTING_VOICEFORWARD_IFBUSY; +extern const wchar_t* IDS_SETTING_VOICEFORWARD_NOREPLY; +extern const wchar_t* IDS_SETTING_VOICEFORWARD_OUTOFREACH; +extern const wchar_t* IDS_SETTING_DEACTIVATE_STATUS; +extern const wchar_t* IDS_SETTING_VOICEBARRING_OUTGOING; +extern const wchar_t* IDS_SETTING_VOICEBARRING_INTERNATIONAL; +extern const wchar_t* IDS_SETTING_VOICEBARRING_EXCEPTHOME; +extern const wchar_t* IDS_SETTING_VOICEBARRING_INCOMING; +extern const wchar_t* IDS_SETTING_VOICEBARRING_WHENROAMING; +extern const wchar_t* IDS_SETTING_CALL_WAITING_OPTIONS; +extern const wchar_t* IDS_MATCHCRITERIA_EXACT; +extern const wchar_t* IDS_MATCHCRITERIA_START; +extern const wchar_t* IDS_MATCHCRITERIA_END; +extern const wchar_t* IDS_MATCHCRITERIA_INCLUDE; +extern const wchar_t* IDS_SETTING_CALLERID_MAIN_STR; +extern const wchar_t* IDS_SETTING_CALLERID_SUB_STR; +extern const wchar_t* IDS_SETTING_CALL_ALERT_MAIN_STR; +extern const wchar_t* IDS_SETTING_CALL_ALERT_SUB_STR; +extern const wchar_t* IDS_SETTING_SAVE_HEADER_ITEM; +extern const wchar_t* IDS_SETTING_DONE_HEADER_ITEM; +extern const wchar_t* IDS_NOT_ASSIGNED_STR; + +#endif // _PHN_SETTINGS_CONSTANTS_H_ diff --git a/inc/PhnSettingsDeleteListForm.h b/inc/PhnSettingsDeleteListForm.h new file mode 100644 index 0000000..a08728a --- /dev/null +++ b/inc/PhnSettingsDeleteListForm.h @@ -0,0 +1,111 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsDeleteListForm.h + * @brief This is the header file for the %SettingsDeleteListForm class. + * + * This header file contains the declarations for %SettingsDeleteListForm class. + */ +#ifndef _PHN_SETTINGS_DELETE_LIST_FORM_H_ +#define _PHN_SETTINGS_DELETE_LIST_FORM_H_ + +#include +#include +#include "PhnCallRejectInfo.h" + +class SettingsPresentationModel; + +/** + * @class SettingsDeleteListForm + * @brief This class presents a settings form based UI for call settings - delete numbers to reject, + * delete rejection messages. + * + */ +class SettingsDeleteListForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + enum ListOfType + { + LISTOF_NUMBERS, + LISTOF_MESSAGES, + }; + +public: + SettingsDeleteListForm(ListOfType listOfType); + virtual ~SettingsDeleteListForm(void); + void Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //Initialize list view's main menu + result InitializeListView(void); + + void InitializeSelectLabel(); + + //From IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + + //From IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + +private: + // Funtion is used to fetch list of rejected call numbers. + void FetchNumbersRejectList(void); + // Funtion is used to fetch list of "reject with messages". + void FetchRejectMsgsList(void); + // Funtion is used to initialise footer and footer items. + void InitializeFooter(void); + // Function is used to create "rejected number" items for list view. + Tizen::Ui::Controls::CustomItem* CreateListItemForNumbers(int index, int itemWidth); + // Function is used to create "reject with message" items for list view. + Tizen::Ui::Controls::CustomItem* CreateListItemForMsgs(int index, int itemWidth); + //used to select all items when selecting "Select All" + void SelectAllItems(bool isSelect); + //used to delete rejected numbers list + void DeleteRejectNumbersList(void); + //used to delete rejected messages list + void DeleteRejectMsgsList(void); + +private: + ListOfType __listOfType; + //list of rejected numbers + Tizen::Base::Collection::ArrayListT* __pNumbersList; + //list of reject msgs + Tizen::Base::Collection::IMapT* __pMsgsMap; + //not owned + SettingsPresentationModel* __pSettingsPresentor; + int __checkedItemCount; + //Selected pop up label + Tizen::Ui::Controls::Label* __pSelectedLabel; +}; + +#endif //_PHN_SETTINGS_DELETE_LIST_FORM_H_ diff --git a/inc/PhnSettingsEditRejectMsgForm.h b/inc/PhnSettingsEditRejectMsgForm.h new file mode 100644 index 0000000..76679a4 --- /dev/null +++ b/inc/PhnSettingsEditRejectMsgForm.h @@ -0,0 +1,76 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsEditRejectMsgForm.h + * @brief This is the header file for the %SettingsEditRejectMsgForm class. + * + * This header file contains the declarations for %SettingsEditRejectMsgForm class. + */ +#ifndef _PHN_SETTINGS_EDIT_REJECT_MSG_FORM_H_ +#define _PHN_SETTINGS_EDIT_REJECT_MSG_FORM_H_ + +#include +#include + +class SettingsPresentationModel; + +/** + * @class SettingsEditRejectMsgForm + * @brief This class presents a settings form based UI for editing reject messages from call settings. + * + */ +class SettingsEditRejectMsgForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::ITextEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + enum FormMode + { + FORMMODE_NEW_MESSAGE, + FORMMODE_EDIT_MESSAGE, + }; + +public: + SettingsEditRejectMsgForm(FormMode formMode); + virtual ~SettingsEditRejectMsgForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From ITextEventListener + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + +private: + //Funtion is used to initialise header and header items. + void InitializeHeader(void); + +private: + int __itemIndex; + //used to store form mode. + FormMode __formMode; + SettingsPresentationModel* __pSettingsPresentor; +}; + +#endif //_PHN_SETTINGS_EDIT_REJECT_MSG_FORM_H_ diff --git a/inc/PhnSettingsForwardToNumberForm.h b/inc/PhnSettingsForwardToNumberForm.h new file mode 100644 index 0000000..d020c8c --- /dev/null +++ b/inc/PhnSettingsForwardToNumberForm.h @@ -0,0 +1,181 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsForwardToNumberForm.h + * @brief This is the header file for the %SettingsForwardToNumberForm class. + * + * This header file contains the declarations for %SettingsForwardToNumberForm class. + */ +#ifndef _PHN_SETTINGS_FORWARD_TO_NUMBER_FORM_H_ +#define _PHN_SETTINGS_FORWARD_TO_NUMBER_FORM_H_ + +#include +#include +#include "PhnSettingsConstants.h" +#include "PhnErrorMsgPopup.h" + +class SettingsPresentationModel; + +/** + * @class SettingsForwardToNumberForm + * @brief This class presents a settings form based UI for saving forwarding call settings. + * + */ +class SettingsForwardToNumberForm + : public IPopupClosedEventListener + , public ISettingsEventListener + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IKeypadEventListener + , public Tizen::Ui::ITextEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::App::IAppControlResponseListener +{ +public: + enum ForwardCondition + { + FORWARDCONDITION, + FORWARDCONDITION_NOREPLY, + }; + +public: + SettingsForwardToNumberForm(ForwardCondition forwardCondition); + virtual ~SettingsForwardToNumberForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + + //From IKeypadEventListener + virtual void OnKeypadWillOpen(Tizen::Ui::Control& source); + virtual void OnKeypadOpened(Tizen::Ui::Control& source){}; + virtual void OnKeypadClosed(Tizen::Ui::Control& source); + virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}; + virtual void OnKeypadBoundsChanged(Tizen::Ui::Control& source){}; + + //From ISettingsEventListener + virtual void HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated){}; + virtual void HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled){}; + virtual void HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime); + virtual void HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime){}; + virtual void HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated){}; + virtual void HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated){}; + + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + + //Launches contacts app control for pick operation + void LaunchContactsAppControl(void); + //From IAppControlResponseListener + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + // Called when a text is changed. + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + // Called when a change made to the text is canceled. + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + +private: + // This function is used to collapse selective groups while form initialization only. + void CollapseSelectiveGroups(Tizen::Ui::Controls::GroupedTableView* pMainMenuTableView); + // Function is used to initialise header and headerItems. + void InitializeHeader(void); + // Funtion is use dto initalise numeric edit field. + void InitializeNumberEditField(void); + // Function is used to initialise group table view and add item provider. + result InitializeGroupedTableView(void); + // Function is used to create list items which come under "GroupWaitTimeOptionsItems". + Tizen::Ui::Controls::TableViewItem* CreateWaitingTimeOptionsMenuItems(int itemIndex, int itemWidth); + // This function is used to create "SELECTWAITTIME_WAIT_TIME". + Tizen::Ui::Controls::TableViewItem* CreateExpandableWaitingItem(int itemWidth); + //Funtion is used to set or change expand icon based on item's state. + void SetExpandIconToItem(Tizen::Ui::Controls::TableViewItem* pItem, bool isExpanded); + // This function is used to handle selection of 'GroupSelectWaitTimeItems'. + void ToggleGroupExpansion(Tizen::Ui::Controls::GroupedTableView& tableView, int itemIndex); + // This function is used to handle selection of waiting time. + void HandleSelectedWaitingTime(Tizen::Ui::Controls::GroupedTableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status); + Tizen::Base::String FetchTextForSelectedOption(int selectedWaitTimeOption); + void ShowErrorMessage(int errorCode); + +private: + //Main groups available in list view. + enum WaitingTimeGroupId + { + GROUP_SELECT_WAIT_TIME, + GROUP_WAIT_TIME_OPTIONS, + GROUP_TOTALCOUNT, + }; + //Items for 'GROUP_SELECT_WAIT_TIME' + enum GroupSelectWaitTimeItems + { + SELECTWAITTIME_WAIT_TIME, + SELECTWAITTIME_TOTALCOUNT, //No of options in "GROUP_ENTER_WAIT" drop down menu + }; + //Items for 'GROUP_WAIT_TIME_OPTIONS' + enum GroupWaitTimeOptionsItems + { + WAITTIMEOPTIONS_FIVE_SEC = 5, + WAITTIMEOPTIONS_TEN_SEC = 10, + WAITTIMEOPTIONS_FIFTEEN_SEC = 15, + WAITTIMEOPTIONS_TWENTY_SEC = 20, + WAITTIMEOPTIONS_TWENTYFIVE_SEC = 25, + WAITTIMEOPTIONS_THIRTY_SEC = 30, + }; + + ForwardCondition __forwardCondition; + //call forward condition to be set + CallForwardCondition __callForwardCondition; + SettingsPresentationModel* __pSettingsPresentor; + GroupWaitTimeOptionsItems __selectedWaitTime; + bool __isWaitTimeOptionsMenuExpanded; + //Ownership + ErrorMsgPopup* __pErrorMsgPopup; +}; + +#endif //_PHN_SETTINGS_FORWARD_TO_NUMBER_FORM_H_ diff --git a/inc/PhnSettingsMainMenuForm.h b/inc/PhnSettingsMainMenuForm.h new file mode 100644 index 0000000..bdc31a5 --- /dev/null +++ b/inc/PhnSettingsMainMenuForm.h @@ -0,0 +1,125 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsMainMenuForm.h + * @brief This is the header file for the %SettingsMainMenuForm class. + * + * This header file contains the declarations for %SettingsMainMenuForm class. + */ +#ifndef _PHN_SETTINGS_MAIN_MENU_FORM_H_ +#define _PHN_SETTINGS_MAIN_MENU_FORM_H_ + +#include +#include + +/** + * @class SettingsMainMenuForm + * @brief This class presents a main menu form based UI for call settings. + * + */ +class SettingsMainMenuForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + SettingsMainMenuForm(void); + virtual ~SettingsMainMenuForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + +private: + //Function is used to initialize group table view. + result InitializeGroupedTableView(void); + +private: + //Groups for main menu + enum MainMenuGroupId + { + GROUP_CALL_REJECTION, + GROUP_CALL_REJECTION_HLPTXT, + GROUP_REJECT_MSG, + GROUP_REJECT_MSG_HLPTXT, + GROUP_MAIN_CALL_SETTINGS, +// GROUP_VIDEOCALL_SETTING, +// GROUP_VOICEMAIL_SETTING, + GROUP_TOTALCOUNT, //always the last element to get group count + }; + + //Items for 'GROUP_CALL_REJECTION' + enum GroupCallRejectionItems + { + CALLREJECTION_CALLREJECT_SETTINGS, + CALLREJECTION_TOTALCOUNT, + }; + + //Items for 'GROUP_REJECT_MSG' + enum GroupRejectMsgItems + { + REJECTMSG_REJECT_MESSAGES_SETTINGS, + REJECTMSG_TOTALCOUNT, + }; + + //Setting id's for "GROUP_MAIN_CALL_SETTINGS" group + enum GroupMainCallSettingsItems + { + MAINCALLSETTINGS_SPEEDDIAL, + MAINCALLSETTINGS_CALLFORWARDING, + MAINCALLSETTINGS_MORECALLSETTINGS, + MAINCALLSETTINGS_TOTALCOUNT, //always the last element to get settings count + }; +}; + +#endif //_PHN_SETTINGS_MAIN_MENU_FORM_H_ diff --git a/inc/PhnSettingsManager.h b/inc/PhnSettingsManager.h new file mode 100644 index 0000000..8457bc8 --- /dev/null +++ b/inc/PhnSettingsManager.h @@ -0,0 +1,200 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsManager.h + * @brief This is the header file for the %SettingsManager class. + * + * This header file contains the declarations for %SettingsManager class. + */ +#ifndef _PHN_SETTINGS_MANAGER_H_ +#define _PHN_SETTINGS_MANAGER_H_ + +#include +#include +#include +#include "ITapiCall.h" +#include "ITapiSs.h" +#include "tapi_common.h" +#include "TapiUtility.h" +#include "TelCall.h" +#include "TelSs.h" +#include "vconf.h" +#include "PhnCallRejectInfo.h" +#include "PhnISettingsEventListener.h" +#include "PhnSettingsConstants.h" +#include "PhnCallSettingDataService.h" + +/** + * @class SettingsManager + * @brief This class provides functionality to set and fetch settings related to voice call, e.g. Call barring, + * call forwarding, etc. + */ +class SettingsManager +{ +public: + //create a singleton instance + static SettingsManager* GetInstance(void); + +private: + //constructor + SettingsManager(void); + SettingsManager(SettingsManager& manager); + SettingsManager& operator =(const SettingsManager& manager); + + result Construct(void); + static void CreateInstance(void); + static void DestroyInstance(void); + +public: + // Add the observer for setting events + void AddSettingEventListener(ISettingsEventListener* pSettingsEventListener); + //remove the observer for setting events + void RemoveSettingEventListener(ISettingsEventListener* pSettingsEventListener); + // Set the call Forwarding status + int SetCallForwardStatus(const Tizen::Base::String& phoneNumber, CallForwardCondition callFwdCondition, bool activateFwding, int noReplyTime = TAPI_SS_CF_NO_REPLY_TIME_30_SECS); + // Get the call Forwarding status + int GetCallForwardStatus(CallForwardCondition callFwdCondition); + // callback function to handle response for set call forward request + static void HandleSetForwardResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // callback function to handle response for get call forward request + static void HandleGetForwardResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // Set the call barring status + int SetCallBarringStatus(const Tizen::Base::String& password, CallBarringType callBarringType, bool activateBarring); + // callback function to handle response for set call barring request + static void HandleSetBarringResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // Get the call barring status + int GetCallBarringStatus(CallBarringType callBarringType); + // callback function to handle response for set call barring request + static void HandleGetBarringResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // Set the call waiting status + int SetCallWaitingStatus(bool activateWaiting); + // callback function to handle response for set call waiting request + static void HandleSetWaitingResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // Get the call waiting status + int GetCallWaitingStatus(void); + // callback function to handle response for set call waiting request + static void HandleGetWaitingResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData); + // Get the reject message list + Tizen::Base::Collection::IMapT* GetRejectMessageListN(void); + // Add/edit the message list at the given index + result SetRejectMessage(int messageIndex, const Tizen::Base::String& rejectMessage); + // delete the message from the list + result RemoveRejectMessage(const Tizen::Base::Collection::IListT& deleteKeyList); + // get the prefix dialing list + Tizen::Base::Collection::IList* GetPrefixDialListN(void); + // Set the number to the prefix dial list + result SetPrefixDialNumber(int phoneNumberIndex, const Tizen::Base::String& phoneNumber); + // Get the number set at 'phoneNumberIndex'. + result GetPrefixDialNumberAtIndex(int phoneNumberIndex, Tizen::Base::String& phoneNumber); + // delete the number from the list + result RemovePrefixDialNumber(int phoneNumberIndex); + // Set the prefix dial status + result SetPrefixDialingStatus(bool enablePrefixDialing); + // Set the active prefix dial to be used + result SetActivePrefixDialingValue(int prefixDialIndex); + // Get the active prefix dial to be used + result GetActivePrefixDialingValue(int& prefixDialIndex); + // Get the prefix dialing status + bool GetPrefixDialingStatus(void); + // Set the video call image path + result SetVideoCallImagePath(const Tizen::Base::String& imagePath); + // Get the video call image path + result GetVideoCallImagePath(Tizen::Base::String& imagePath); + // Set the call line identity + result SetCallLineIdentity(CallLineIdentity identity); + // Get the call line identity + result GetCallLineIdentity(CallLineIdentity& identity); + // Add the number to the call reject list + result AddToCallRejectList(const Tizen::Base::String& phoneNumber, CallRejectMatchCondition rejectCondition); + // Get the call reject list + Tizen::Base::Collection::IListT* GetCallRejectList(void); + // Update the call reject number already present + result UpdateCallRejectRow(int rowId, const Tizen::Base::String& phoneNumber, bool activate, CallRejectMatchCondition rejectCondition); + // Remove the call reject item + result RemoveCallRejectRow(int rowId); + // Set the reject "unknown" status + result SetUnknownRejectStatus(bool activate); + // Get the reject "unknown" status + bool GetUnknownRejectStatus(void); + // checks if the call is to be rejected + bool IsCallToBeRejected(Tizen::Base::String& phoneNumber); + // Set the call alert status + result SetCallAlertStatus(CallAlertStatus callAlertStatus); + // Get the call alert status + result GetCallAlertStatus(CallAlertStatus& callAlertStatus); + // Set the call connect tone status + result SetCallConnectToneStatus(bool activate); + // Get the call connect tone status + bool GetCallConnectToneStatus(void); + // Set the minute minder tone status + result SetMinuteMinderToneStatus(bool activate); + // Get the minute minder tone status + bool GetMinuteMinderToneStatus(void); + // Set the call End tone status + result SetCallEndToneStatus(bool activate); + // Get the call End tone status + bool GetCallEndToneStatus(void); + //Set the speed dial mapping + result SetSpeedDialMapping(const Tizen::Base::String& contactId, int numberToMap); + // Get the speed dial mapping list + Tizen::Base::Collection::IMapT* GetSpeedDialMappingN(void); + //Remove the speed dial mapping + result RemoveSpeedDialMapping(int rowId); + //Change the speed dial mapped + result UpdateSpeedDialMapping(int rowId, const Tizen::Base::String& contactId, int numberToMap); + //fetch the mapped speed dial contact no. + Tizen::Base::String* GetMappedSpeedDialNumberN(int aIndex); + //Fetch Contacts details by contact id + Tizen::Social::Contact* FetchContactDetailsN(const Tizen::Base::String& contactId); + //Sets the Call State + result SetCallState(CallState callState); + +private: + + enum ForwardResponseType + { + SET_CALLFORWARD_RESPONSE, + GET_CALLFORWARD_RESPONSE, + }; + enum BarringResponseType + { + SET_CALLBARRING_RESPONSE, + GET_CALLBARRING_RESPONSE, + }; + enum WaitingResponseType + { + SET_CALLWAITING_RESPONSE, + GET_CALLWAITING_RESPONSE, + }; +private: + virtual ~SettingsManager(void); + //notify event listeners for Setting or Getting Call Forwarding status events. + void NotifyForwardingEventListeners(ForwardResponseType responseType, bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime); + //notify event listeners for Setting or Getting Call Barring status events. + void NotifyBarringEventListeners(BarringResponseType responseType, bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated); + //notify event listeners for Setting or Getting Call Waiting status events. + void NotifyWaitingEventListeners(WaitingResponseType responseType, bool isCallSuccessful, bool isCallWaitingActivated); + +private: + static SettingsManager* __pInstance; + //handle to Telephony API + TapiHandle* __pTapiHandle; + Tizen::Base::Collection::ArrayListT* __pSettingsEventListener; + CallSettingDataService* __pCallSettingDataService; +}; + +#endif // _PHN_SETTINGS_MANAGER_H_ diff --git a/inc/PhnSettingsMoreOptionsForm.h b/inc/PhnSettingsMoreOptionsForm.h new file mode 100644 index 0000000..e0f56b7 --- /dev/null +++ b/inc/PhnSettingsMoreOptionsForm.h @@ -0,0 +1,180 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsMoreOptionsForm.h + * @brief This is the header file for the %SettingsMoreOptionsForm class. + * + * This header file contains the declarations for %SettingsMoreOptionsForm class. + */ +#ifndef _PHN_SETTINGS_MORE_OPTIONS_FORM_H_ +#define _PHN_SETTINGS_MORE_OPTIONS_FORM_H_ + +#include +#include + +class SettingsPresentationModel; + +/** + * @class SettingsMoreOptionsForm + * @brief This class presents a additional settings form for call settings. + * + */ +class SettingsMoreOptionsForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + SettingsMoreOptionsForm(void); + virtual ~SettingsMoreOptionsForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + // Function is used to initialise group table view. + result InitializeGroupedTableView(void); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + +private: + // This function is used to collapse selective groups while form initialization only. + void CollapseSelectiveGroups(Tizen::Ui::Controls::GroupedTableView* pMoreOptionsTableView); + // This function is used to create list items which come under "GROUP_CALLERID" & "GROUP_CALL_ALERT". + Tizen::Ui::Controls::TableViewItem* CreateExpandableItem(int groupIndex, int itemIndex, int itemWidth); + // This function is used to create list items which come under "GROUP_CALLERID_OPTIONS" + Tizen::Ui::Controls::TableViewItem* CreateCallerIdOptionsItem(int itemIndex, int itemWidth); + // This function is used to create list items which come under "GROUP_CALL_ALERT_OPTIONS" + Tizen::Ui::Controls::TableViewItem* CreateCallerAlertOptionsItem(int itemIndex, int itemWidth); + // This function is used to create list menu items + Tizen::Ui::Controls::TableViewItem* CreateSettingMenuItem(int groupIndex, int itemIndex, int itemWidth); + // Funtion is used to set icon to Expandable items based on its state. + void SetExpandIconToItem(Tizen::Ui::Controls::TableViewItem* pItem, bool isExpanded); + // Function is used to handle item selection for individual items. + void HandleSelectedSettings(int groupIndex, int itemIndex); + // Function is used to handle item selection for "GROUP_CALLERID_OPTIONS" + void HandleSelectedCallerIdOptions(Tizen::Ui::Controls::GroupedTableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus state); + // Function is used to handle item selection for "GROUP_CALL_ALERT_OPTIONS" + void HandleSelectedCallAlertOptions(Tizen::Ui::Controls::GroupedTableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus state); + Tizen::Base::String FetchSubTextForSelectedCallerId(); + Tizen::Base::String FetchSubTextForSelectedCallerAlert(); + +private: + //Groups + enum MoreMenuGroupId + { + GROUP_CALLERID, + GROUP_CALLERID_OPTIONS, + GROUP_CALL_SETTINGS, + GROUP_CALL_SETTINGS_HLPTXT, + GROUP_CALL_REMINDER, + GROUP_CALL_REMINDER_HLPTXT, + GROUP_CALL_ALERT, + GROUP_CALL_ALERT_OPTIONS, + GROUP_AREACODE, + GROUP_AREACODE_HLPTXT, + GROUP_TOTALCOUNT, //always the last element to get group count + }; + //Items for 'GROUP_CALLERID' + enum GroupCallerIdItems + { + CALLERID_CALLER_SETTING, + CALLERID_TOTALCOUNT, + }; + //Items for 'GROUP_CALLERID_OPTIONS' + enum GroupCallerIdOptionsItems + { + CALLEROPTIONS_BY_NETWORK, + CALLEROPTIONS_SHOW, + CALLEROPTIONS_HIDE, + CALLEROPTIONS_TOTALCOUNT, //No of options in "caller id" drop down menu + }; + //Items for "GROUP_CALL_SETTINGS" group + enum CallSettingsItems + { + CALLSETTINGS_CALL_BARRING, + CALLSETTINGS_CALL_WAITING, + CALLSETTINGS_TOTALCOUNT, + }; + //Items for "GROUP_CALL_REMINDER" group + enum CallReminderItems + { + CALLREMINDER_STATUS_TONES, + CALLREMINDER_TOTALCOUNT, + }; + //Item for "GROUP_CALL_ALERT" + enum GroupCallAlertItems + { + CALLALERT_SETTING, + CALLALERT_TOTALCOUNT, + }; + //Option Items for "GROUP_CALL_ALERT_OPTIONS" + enum GroupCallAlertOptionsItems + { + CALLALERT_OPTIONS_OFF, + CALLALERT_OPTIONS_SOUND, + CALLALERT_OPTIONS_VIBRATION, + CALLALERT_OPTIONS_TOTALCOUNT, + }; + //Item for "GROUP_AREACODE" group + enum GroupAreaCodeItems + { + AREACODE_AUTO_AREA_CODE, + AREACODE_TOTALCOUNT, + }; + + SettingsPresentationModel* __pSettingsPresentor; + bool __isCallerIdExpanded; + bool __isCallAlertExpanded; + Tizen::Base::String __autoAreaCode; +}; + +#endif //_PHN_SETTINGS_MORE_OPTIONS_FORM_H_ diff --git a/inc/PhnSettingsPresentationModel.h b/inc/PhnSettingsPresentationModel.h new file mode 100644 index 0000000..6472f2d --- /dev/null +++ b/inc/PhnSettingsPresentationModel.h @@ -0,0 +1,151 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsPresentationModel.h + * @brief This is the header file for the %SettingsPresentationModel class. + * + * This header file contains the declarations for %SettingsPresentationModel class. + */ +#ifndef _PHN_SETTINGS_PRESENTATION_MODEL_H_ +#define _PHN_SETTINGS_PRESENTATION_MODEL_H_ + +#include +#include "PhnISettingsEventListener.h" + +class SettingsManager; +class CallRejectInfo; +class SpeedDialInfo; + +/** + * @class SettingsPresentationModel + * @brief This class provides data to settings forms and provides functions + * to interact with Settings manager. + * + */ +class SettingsPresentationModel: public ISettingsEventListener +{ +public: + //create a singleton instance + static SettingsPresentationModel* GetInstance(void); + +private: + SettingsPresentationModel(void); + SettingsPresentationModel(SettingsPresentationModel& presentor); + virtual ~SettingsPresentationModel(void); + SettingsPresentationModel& operator =(const SettingsPresentationModel& presentor); + + //perform 2nd phase initialization + result Construct(void); + static void CreateInstance(void); + static void DestroyInstance(void); + +public: + // Add the observer for setting events + result AddSettingEventListener(ISettingsEventListener* pSettingsEventListener); + //remove the observer for setting events + void RemoveSettingEventListener(void); + + // Get the reject message list + Tizen::Base::Collection::IMapT* GetRejectMessageListN(void); + // Add the number to the call reject list + result AddToCallRejectList(const Tizen::Base::String& phoneNumber, CallRejectMatchCondition rejectCondition); + // Get the call reject list + Tizen::Base::Collection::IListT* GetCallRejectList(void); + // Set the number to the prefix dial list + result SetPrefixDialNumber(int phoneNumberIndex, const Tizen::Base::String& phoneNumber); + // Set the active prefix dial to be used + result SetActivePrefixDialingValue(int prefixDialIndex); + // Set the prefix dial status + result SetPrefixDialingStatus(bool enablePrefixDialing); + // Get the active prefix dial number to be used + result GetActivePrefixDialNumber(Tizen::Base::String& phoneNumber); + // Set the call barring status + int SetCallBarringStatus(const Tizen::Base::String& password, CallBarringType callBarringType, bool activateBarring); + // Get the call Forwarding status + int GetCallForwardStatus(CallForwardCondition callFwdCondition); + // Set the call Forwarding status + int SetCallForwardStatus(const Tizen::Base::String& phoneNumber, CallForwardCondition callFwdCondition, bool activateFwding, int noReplyTime); + // Get the call barring status + int GetCallBarringStatus(CallBarringType callBarringType); + // Set the call waiitng status + int SetCallWaitingStatus(bool activateWaiting); + // Get the call waiting status + int GetCallWaitingStatus(void); + // Set the call connect tone status + result SetCallConnectToneStatus(bool activate); + // Get the call connect tone status + bool GetCallConnectToneStatus(void); + // Set the minute minder tone status + result SetMinuteMinderToneStatus(bool activate); + // Get the minute minder tone status + bool GetMinuteMinderToneStatus(void); + // Set the call End tone status + result SetCallEndToneStatus(bool activate); + // Get the call End tone status + bool GetCallEndToneStatus(void); + // Update the call reject number already present + result UpdateCallRejectRow(int rowId, const Tizen::Base::String& phoneNumber, bool activate, CallRejectMatchCondition rejectCondition); + // Remove the call reject item + result RemoveCallRejectRow(int rowId); + // Add/edit the message list at the given index + result SetRejectMessage(int messageIndex, const Tizen::Base::String& rejectMessage); + // delete the message from the list + result RemoveRejectMessage(const Tizen::Base::Collection::IListT& deleteKeyList); + // checks if the call is to be rejected + bool IsCallToBeRejected(Tizen::Base::String& phoneNumber); + //Set the speed dial mapping + result SetSpeedDialMapping(const Tizen::Base::String& contactId, int numberToMap); + // Get the speed dial mapping list + Tizen::Base::Collection::IMapT* GetSpeedDialMappingN(void); + //remove speed dial mapping for given 'rowId'. + result RemoveSpeedDialMapping(int rowId); + //update speed dial mapping for given 'rowId'. + result UpdateSpeedDialMapping(int rowId, const Tizen::Base::String& contactId, int numberToMap); + // Set the call line identity + result SetCallLineIdentity(CallLineIdentity identity); + // Get the call line identity + result GetCallLineIdentity(CallLineIdentity& identity); + // Set the call alert status + result SetCallAlertStatus(CallAlertStatus callAlertStatus); + // Get the call alert status + result GetCallAlertStatus(CallAlertStatus& callAlertStatus); + // Set the reject "unknown" status + result SetUnknownRejectStatus(bool activate); + // Get the reject "unknown" status + bool GetUnknownRejectStatus(void); + //Fetch Contacts details by contact id + Tizen::Social::Contact* FetchContactDetailsN(const Tizen::Base::String& contactId); + //Sets the call state + result SetCallState(CallState callState); + +protected: + //From ISettingsEventListener + virtual void HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated); + virtual void HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled); + virtual void HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime); + virtual void HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime); + virtual void HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated); + virtual void HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated); + +private: + static SettingsPresentationModel* __pInstance; + //Owned. Is responsible for destroying the instance + SettingsManager* __pSettingsMgr; + ISettingsEventListener* __pSettingsEventListener; +}; + +#endif // _PHN_SETTINGS_PRESENTATION_MODEL_H_ diff --git a/inc/PhnSettingsRejectListForm.h b/inc/PhnSettingsRejectListForm.h new file mode 100644 index 0000000..ee2f300 --- /dev/null +++ b/inc/PhnSettingsRejectListForm.h @@ -0,0 +1,108 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsRejectListForm.h + * @brief This is the header file for the %SettingsRejectListForm class. + * + * This header file contains the declarations for %SettingsRejectListForm class. + */ +#ifndef _PHN_SETTINGS_REJECT_LIST_FORM_H_ +#define _PHN_SETTINGS_REJECT_LIST_FORM_H_ + +#include +#include +#include "PhnCallRejectInfo.h" + +class SettingsPresentationModel; + +/** + * @class SettingsRejectListForm + * @brief This class presents a form based UI for call settings. + * + */ +class SettingsRejectListForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + SettingsRejectListForm(void); + virtual ~SettingsRejectListForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + +private: + // Function is used to initialize group list view. + result InitializeGroupedTableView(void); + // Function is used to fetch list of "rejected call numbers". + void FetchNumbersRejectList(void); + // Function is used to initialize footer and footer items. + void InitializeFooter(void); + +private: + //list of rejected call numbers fetched from Db. + Tizen::Base::Collection::ArrayListT* __pNumbersList; + //matching criteria + enum MatchingCriteriaId + { + CRITERIAID_EXACT, + CRITERIAID_STARTSWITH, + CRITERIAID_ENDSWITH, + CRITERIAID_INCLUDE, + }; + SettingsPresentationModel* __pSettingsPresentor; +}; + +#endif //_PHN_SETTINGS_REJECT_LIST_FORM_H_ diff --git a/inc/PhnSettingsRejectMsgsForm.h b/inc/PhnSettingsRejectMsgsForm.h new file mode 100644 index 0000000..0be103c --- /dev/null +++ b/inc/PhnSettingsRejectMsgsForm.h @@ -0,0 +1,115 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsRejectListForm.h + * @brief This is the header file for the %SettingsRejectMsgsForm class. + * + * This header file contains the declarations for %SettingsRejectMsgsForm class. + */ +#ifndef _PHN_SETTINGS_REJECT_MSGS_FORM_H_ +#define _PHN_SETTINGS_REJECT_MSGS_FORM_H_ + +#include +#include + +class SettingsPresentationModel; + +/** + * @class SettingsRejectMsgsForm + * @brief This class presents a additional settings form for storing reject messages. + * + */ +class SettingsRejectMsgsForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + SettingsRejectMsgsForm(void); + virtual ~SettingsRejectMsgsForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewGroupItem is changed. + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status){}; + //From IGroupedTableViewItemEventListener - Called when the state of a TableViewItem in the GroupedTableView is changed. + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + //From IGroupedTableViewItemEventListener - Called when the TableViewContextItem is opened or closed. + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated){}; + + //From IGroupedTableViewItemProvider - Gets the total number of groups. + virtual int GetGroupCount(void); + //From IGroupedTableViewItemProvider - Gets the total number of items in the specified group. + virtual int GetItemCount(int groupIndex); + //From IGroupedTableViewItemProvider - Gets the group item for the specified index from the item provider. + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified group item. + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified group item. + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + //From IGroupedTableViewItemProvider - Creates the specified item. + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + //From IGroupedTableViewItemProvider - Deletes the specified item. + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Updates the specified item. + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + //From IGroupedTableViewItemProvider - Gets the default height of an group item. + virtual int GetDefaultGroupItemHeight(void); + //From IGroupedTableViewItemProvider - Gets the default height of an item. + virtual int GetDefaultItemHeight(void); + +private: + // Function is used to initialise group list view. + result InitializeGroupedTableView(void); + // Function is used to fetch list of "rejected with messages". + void FetchRejectMsgs(void); + // Function is used to initialise footer and footer items. + void InitializeFooter(void); + +private: + //list of reject messages fetched from Db. + Tizen::Base::Collection::IMapT* __pMsgsMap; + //settings presentation model + SettingsPresentationModel* __pSettingsPresentor; + //footer action id + enum FooterActionId + { + IDA_ADD_FOOTER_ITEMID, + IDA_DELETE_FOOTER_ITEMID, + IDA_CANCEL_FOOTER_ITEMID, + }; + //matching criteria + enum MatchingCriteriaId + { + CRITERIAID_EXACT, + CRITERIAID_STARTSWITH, + CRITERIAID_ENDSWITH, + CRITERIAID_INCLUDE, + }; +}; + +#endif //_PHN_SETTINGS_REJECT_MSGS_FORM_H_ diff --git a/inc/PhnSettingsSpeedDialForm.h b/inc/PhnSettingsSpeedDialForm.h new file mode 100644 index 0000000..b812f6f --- /dev/null +++ b/inc/PhnSettingsSpeedDialForm.h @@ -0,0 +1,102 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsSpeedDialForm.h + * @brief This is the header file for the %SettingsSpeedDialForm class. + * + * This header file contains the declarations for %SettingsSpeedDialForm class. + */ +#ifndef _PHN_SETTINGS_SPEED_DIAL_FORM_H_ +#define _PHN_SETTINGS_SPEED_DIAL_FORM_H_ + +#include +#include +#include "PhnSettingsConstants.h" +#include "PhnSpeedDialPopup.h" +#include "PhnIPopupItemSelectListener.h" + +class SettingsPresentationModel; +class SpeedDialInfo; + +/** + * @class SettingsSpeedDialForm + * @brief This class presents a additional settings form for setting and updating speed dial settings. + * + */ +class SettingsSpeedDialForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::App::IAppControlResponseListener + , public Tizen::Social::IAddressbookEventListener + , public IPopupItemSelectListener +{ +public: + SettingsSpeedDialForm(void); + virtual ~SettingsSpeedDialForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + //From IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //From IFormBackEventListener + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + + //From ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + //From IAppControlResponseListener + virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData); + //From IPopupEventListener + void OnItemSelected(int itemIndex); + //From IAddressbookEventListener + virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList); + virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList){}; + + +private: + // Function is used to initialise footer and footer items. + void InitializeFooter(void); + // Function is used to initialise buttons and add listener. + void InitializePhotoButtons(const Tizen::Base::String& btnName, const Tizen::Base::String& lblName, ActionId actionId); + // Function is used to initialise voice mail button and add listener. + void InitializeVoiceMail(void); + //Launches contacts app control for pick operation + void LaunchAppControl(void); + // updates the button according to the button clicked + void UpdateButton(void); + // updates all buttons + void UpdateAllButtons(void); + +private: + Tizen::Base::Collection::HashMapT* __pSpeedDialMappingList; + //Singleton do not delete + SettingsPresentationModel* __pSettingsPresentor; + int __keyToMap; + bool __isUpdate; + bool __isDeleteMode; + Tizen::Social::Addressbook* __pAddressbook; + SpeedDialPopup* __pSpeedDialPopup; + Tizen::Base::Collection::ArrayListT* __pDeleteList; + Tizen::Ui::Scenes::SceneId* __pPreviousSceneId; + bool __isContactAppControlLaunched; +}; + +#endif //_PHN_SETTINGS_SPEED_DIAL_FORM_H_ diff --git a/inc/PhnSoundManager.h b/inc/PhnSoundManager.h new file mode 100644 index 0000000..763ef50 --- /dev/null +++ b/inc/PhnSoundManager.h @@ -0,0 +1,78 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSoundManager.h + * @brief This is the header file for the %SoundManager class. + * + * This header file contains the declarations for %SoundManager class. + */ +#ifndef _PHN_SOUND_MANAGER_H_ +#define _PHN_SOUND_MANAGER_H_ + +#include +#include +#include +#include "sound_manager.h" +#include "vconf.h" +#include "vconf-keys.h" +#include "PhnTypes.h" + +/** + * @class SoundManager + * @brief This class presents sound related functionality required in call module. + * + */ +class SoundManager + : public Tizen::Media::IPlayerEventListener +{ +public: + SoundManager(void); + virtual ~SoundManager(void); + //start the sound manager session + result StartSession(void); + //Change the speaker status + result SetSpeakerStatus(bool setSpeaker); + //Set the sound mode for the call + result SetSoundMode(SoundMode soundMode); + void StartAlert(Tizen::Base::String& contactRingTone); + void StopAlert(void); + result StopSession(void); + +protected: + virtual void OnPlayerOpened(result r); + virtual void OnPlayerEndOfClip(void); + virtual void OnPlayerSeekCompleted(result r); + virtual void OnPlayerBuffering(int percent); + virtual void OnPlayerErrorOccurred(Tizen::Media::PlayerErrorReason r); + virtual void OnPlayerInterrupted(void); + virtual void OnPlayerReleased(void); + +private: + bool IsEarJackConnected(void); + +private: + //Sound manager handle + sound_call_session_h __pSoundCallSession; + //For notifying via vibrate during incoming call + Tizen::System::Vibrator* __pVibrator; + // Audio player + Tizen::Media::Player* __pPlayer; + bool __isSoundStatusOn; + bool __isVibrateStatusOn; +}; + +#endif /* _PHN_SOUND_MANAGER_H_ */ diff --git a/inc/PhnSpeedDialInfo.h b/inc/PhnSpeedDialInfo.h new file mode 100644 index 0000000..c9be815 --- /dev/null +++ b/inc/PhnSpeedDialInfo.h @@ -0,0 +1,70 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSpeedDialInfo.h + * @brief This is the header file for the %SpeedDialInfo class. + * + * This header file contains the declarations for %SpeedDialInfo class. + */ +#ifndef _PHN_SPEED_DIAL_INFO_H_ +#define _PHN_SPEED_DIAL_INFO_H_ + +#include +#include "PhnSettingsConstants.h" + +/** + * @class SpeedDialInfo + * @brief This class holds information about speed dial mappings fetched/stored from database. + * + */ +class SpeedDialInfo + : public Tizen::Base::Object +{ + +public: + // Default Constructor + SpeedDialInfo(void); + virtual ~SpeedDialInfo(void); + /** + * This is the equality operator for this SpeedDialInfo. + * returns true, if both have same value for call handle. + * + * @param[in] rhs A reference to the %SpeedDialInfo instance + */ + bool operator ==(const SpeedDialInfo& rhs) const; + + /** + * This is the InEquality operator for this SpeedDialInfo. + * returns true, if value for call handle is different. + * + * @param[in] rhs A reference to the %SpeedDialInfo instance + */ + bool operator !=(const SpeedDialInfo& rhs) const; + + /** + * This is the assignment operator for this class. + * @param[in] rhs A reference to the %SpeedDialInfo instance + */ + SpeedDialInfo& operator =(const SpeedDialInfo& rhs); + +public: + int rowId; + int keyMapping; + Tizen::Base::String contactId; +}; + +#endif // _PHN_SPEED_DIAL_INFO_H_ diff --git a/inc/PhnSpeedDialPopup.h b/inc/PhnSpeedDialPopup.h new file mode 100644 index 0000000..e800cb2 --- /dev/null +++ b/inc/PhnSpeedDialPopup.h @@ -0,0 +1,71 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSpeedDialPopup.h + * @brief This is the header file for the %SpeedDialPopup class. + * + * This header file contains the declarations for %SpeedDialPopup class. + */ +#ifndef _PHN_SPEED_DIAL_POPUP_H_ +#define _PHN_SPEED_DIAL_POPUP_H_ + +#include +#include + +#include "PhnIPopupItemSelectListener.h" + +/** + * @class SpeedDialPopup + * @brief This class provides popup messages in Speed dial settings form. + * + */ +class SpeedDialPopup + : public Tizen::Ui::Controls::Popup + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::IActionEventListener +{ + +public: + SpeedDialPopup(IPopupItemSelectListener& listener); + virtual ~SpeedDialPopup(void); + int Initialize(void); + + // IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + + //IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + + // From IActionEventListener + void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + void ConstructListData(void); + +private: + Tizen::Ui::Controls::Button* __pCancelButton; + IPopupItemSelectListener& __popupListener; + Tizen::Base::Collection::ArrayList* __pListItemArray; +}; + +#endif // _PHN_SPEED_DIAL_POPUP_H_ diff --git a/inc/PhnSuggestionItemProvider.h b/inc/PhnSuggestionItemProvider.h new file mode 100644 index 0000000..bd59bea --- /dev/null +++ b/inc/PhnSuggestionItemProvider.h @@ -0,0 +1,59 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSuggestionItemProvider.h + * @brief This is the header file for the %SuggestionItemProvider class. + * + * This header file contains the declarations for %SuggestionItemProvider class. + */ +#include +#include + +#ifndef _PHN_SUGGESTION_ITEM_PROVIDER_H_ +#define _PHN_SUGGESTION_ITEM_PROVIDER_H_ + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +class DialPresentationModel; + +/** + * @class SuggestionItemProvider + * @brief This class provides Item provider for search contact list. + * + */ +class SuggestionItemProvider + : public IListViewItemProvider +{ +public: + SuggestionItemProvider(DialPresentationModel& pDialPresentationModel); + ~SuggestionItemProvider(void); + ///IListViewItemProvider method + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + ///IListViewItemProvider method + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + ///IListViewItemProvider method + virtual int GetItemCount(void); + +private: + //Internal function to return EnrichedText with Text + Highlighted keyword, if any. + Tizen::Graphics::EnrichedText* ConstructEnrichedTextN(Tizen::Base::String& text,Tizen::Base::String& keyword, int textFontStyle, int buttonStatus); + +private: + DialPresentationModel& __dialPresentationModel; +}; +#endif // _PHN_SUGGESTION_ITEM_PROVIDER_H_ diff --git a/inc/PhnTabContacts.h b/inc/PhnTabContacts.h new file mode 100644 index 0000000..6f16fbf --- /dev/null +++ b/inc/PhnTabContacts.h @@ -0,0 +1,51 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabContacts.h + * @brief This is the header file for the %DialTabContacts class. + * + * This header file contains the declarations for %DialTabContacts class. + */ +#ifndef _PHN_TAB_CONTACTS_H_ +#define _PHN_TAB_CONTACTS_H_ + +#include +#include + +/** + * @class DialTabContacts + * @brief This class provides tab based UI for Contacts. + * + */ +class DialTabContacts + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + DialTabContacts(void); + virtual ~DialTabContacts(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + +}; + +#endif // _PHN_TAB_CONTACTS_H_ diff --git a/inc/PhnTabDialer.h b/inc/PhnTabDialer.h new file mode 100644 index 0000000..5dfe9d3 --- /dev/null +++ b/inc/PhnTabDialer.h @@ -0,0 +1,179 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabDialer.h + * @brief This is the header file for the %DialTabDialer class. + * + * This header file contains the declarations for %DialTabDialer class. + */ +#ifndef _PHN_TAB_DIALER_H_ +#define _PHN_TAB_DIALER_H_ + +#include +#include +#include +#include "PhnSuggestionItemProvider.h" +#include "PhnDialPresentationModel.h" +#include "PhnErrorMsgPopup.h" +#include "PhnIAppStateChangeListner.h" + +class CallPresentationModel; +class DialerKeypad; + +/** + * @class DialTabDialer + * @brief This class provides tab based UI for Dialer. + * + */ +class DialTabDialer + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public IPopupClosedEventListener + , public Tizen::Ui::IOrientationEventListener + , public Tizen::Ui::ITouchLongPressGestureEventListener + , public Tizen::Social::IAddressbookEventListener + , public IAppStateChangeListener +{ +public: + DialTabDialer(void); + virtual ~DialTabDialer(void); + bool Initialize(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + //Used to show suggestions + void ShowSuggestionBox(Tizen::Base::String& name, Tizen::Base::String& mobileNo, Tizen::Base::String& resultCount); + //Used to hide search results. + void HideSearchBox(void); + //Used to check if dialer is opened from other screen or as first screen. + bool IsOpenedFromOtherView(void); + //Used to show "Add to Contacts" button + void ShowAddToContactsButton(void); + //Used to update search results. + void UpdateSearchResults(void); + //Called when App comes to foreground + virtual void OnForeground(void); + //Called when App goes to background + virtual void OnBackground(void); + +protected: + void ShowFormattedText(Tizen::Ui::Controls::EditField* pEditField, int actionId); + //search box create, update and hide + void InitializeSearchBox(void); + //Used to initialize search list view + void InitializeSearchListView(void); + //Used to show search results in list view. + void ShowSearchListView(void); + //Used to hide search results list view. + void HideSearchListView(void); + //Used to initialize EditField for contacts. + void InitializeContactsTextBox(void); + //Used to contruct drop-down menu for search results. + void ConstructMenu(void); + //Used to construct dial keypad. + void ConstructKeypad(int dialerState); + + //Used to prepare for MOCall and switch to outgoing call screen. + void SwitchToOutgoingCallScreen(const Tizen::Base::String& contactNumber); + //Used to switch back to previous active call screen. + void SwitchToPreviousActiveCallScreen(void); + //Used to add pause + void AddPause(void); + //Used to add pause + void AddWait(void); + //Used to add + + void AddPlus(void); + //Switch to Speed dial settings form. + void SwitchToSpeedDialForm(void); + //Used to get confirmation for assigning speed dial. + void ShowSpeedDialConfirmationPopup(void); + //Used to show context menu + void ShowContextMenu(Tizen::Base::String& contactNumber); + //Used to check if App is in foreground. + bool IsForeground(); + + void SetAppControlLaunched(bool launched); + bool GetAppControlLaunched(void); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + //IListViewItemEventListener method + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status){} + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){} + virtual void OnListViewItemReordered(Tizen::Ui::Controls::ListView& listView, int indexFrom, int indexTo){} + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction){} + virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + + ///IOrientationEventListener + virtual void OnOrientationChanged(const Control& source, OrientationStatus orientationStatus); + //Event Listener method from IPopupClosedEventListener + virtual void HandlePopupClosed(void); + // Called from TouchLongPressGestureDetector when a long press gesture is detected. + virtual void OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector); + //Called from TouchLongPressGestureDetector when a long press detection is canceled. + virtual void OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector){} + // Called by AddressBook to notify when contacts are changed. + virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList); + // Called by AddressBook to notify when categories are changed. + virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList) {}; + + enum ActionIds + { + IDA_BTN_SHOW_CONTEXTMENU = 100, + IDA_BTN_USE_CONTACT_DATA, + IDA_BTN_DISPLAY_CONTACTS, + IDA_BTN_ADD_TO_CONTACTS, + IDA_MENU_SEND_MESSAGE, + IDA_MENU_ADD_CONTACT, + IDA_MENU_SPEED_DIAL, + IDA_MENU_ADD_PAUSE, + IDA_MENU_ADD_WAIT, + IDA_MENU_EXIT, + IDA_SPEEDDIAL_POPUP_YES, + IDA_SPEEDDIAL_POPUP_NO, + }; + + //Button Dimensions + static const int IDI_BGBITMAP_WIDTH ; + static const int IDI_BGBITMAP_HEIGHT; + static const int IDI_BGBITMAP_POS_X; + static const int IDI_BGBITMAP_POS_Y; + static const int IDI_TEXT1_SIZE; + static const int IDI_TEXT2_SIZE; + +private: + //Panel* __pSearchBox; + Tizen::Ui::Controls::ListView* __pSearchListView; + Tizen::Ui::Controls::ContextMenu* __pContextMenu; + SuggestionItemProvider* __pSuggestionListProvider; + //Ownership + ErrorMsgPopup* __pErrorMsgPopup; + bool __isSearchListOpened; + DialPresentationModel* __pDialPresentationModel; + CallPresentationModel* __pCallPresentor; + Tizen::Ui::Scenes::SceneId* __pPreviousSceneId; + DialerKeypad* __pDialKeypad; + Tizen::Ui::Controls::Popup* __pConfirmationPopup; + bool __isAppForeground; + Tizen::Social::Addressbook* __pAddressBook; + bool __isAppControlLaunched; +}; + +#endif // _PHN_TAB_DIALER_H_ diff --git a/inc/PhnTabFavorites.h b/inc/PhnTabFavorites.h new file mode 100644 index 0000000..20b4e95 --- /dev/null +++ b/inc/PhnTabFavorites.h @@ -0,0 +1,51 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabFavorites.h + * @brief This is the header file for the %DialTabFavorites class. + * + * This header file contains the declarations for %DialTabFavorites class. + */ +#ifndef _PHN_TAB_FAVORITES_H_ +#define _PHN_TAB_FAVORITES_H_ + +#include +#include + +/** + * @class DialTabFavorites + * @brief This class provides tab based UI for Favorites. + * + */ +class DialTabFavorites + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + DialTabFavorites(void); + virtual ~DialTabFavorites(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + +}; + +#endif // _PHN_TAB_FAVORITES_H_ diff --git a/inc/PhnTabLogs.h b/inc/PhnTabLogs.h new file mode 100644 index 0000000..756e6aa --- /dev/null +++ b/inc/PhnTabLogs.h @@ -0,0 +1,139 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabLogs.h + * @brief This is the header file for the %DialTabLogs class. + * + * This header file contains the declarations for %DialTabLogs class. + */ +#ifndef _PHN_TAB_LOGS_H_ +#define _PHN_TAB_LOGS_H_ + +#include +#include +#include "PhnTabLogsItemProvider.h" +#include "PhnICalllogChangeListener.h" +//#include "calllog.h" + +class CallLogDetails; +class CallLogManager; + +/** + * @class DialTabLogs + * @brief This class provides tab based UI for Call Log. + * + */ +class DialTabLogs + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::Controls::IGroupedListViewItemEventListener + , public Tizen::Ui::IActionEventListener + , public ICalllogChangeListener +{ +public: + ///DialTabLogs constructor + DialTabLogs(void); + + ///DialTabLogs destructor + virtual ~DialTabLogs(void); + + ///Initializes the DialTabLogs form + /* + * @param: Whether Initialize is success or not + */ + bool Initialize(void); + + ///This functions gets called during form OnInitializing + /* + * @param: result + */ + virtual result OnInitializing(void); + + ///This functions gets called during form terminating + /* + * @param: result + */ + virtual result OnTerminating(void); + + void SetCallLogDisplayMode(bool isEdit); + + void UnCheckAllItems(void); + + ///IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + ///ISceneEventListener + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + + ///ISceneEventListener + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + + /// IGroupedListViewItemEventListener + virtual void OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + /// IGroupedListViewItemEventListener + virtual void OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state); + /// IGroupedListViewItemEventListener + virtual void OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction); + /// ICalllogChangeListener + virtual void OnCalllogChanged(void); + + void SetListItemSelectStatus(bool status); + + void DeleteSelectedCalllog(void); + +private: + //used to handle 'IDA_CHECKBUTTON_SELECT_ALL' + void HandleAllItemSelection(void); + +protected: + static const int IDA_FOOTER_LOG_DELETE = 105; + static const int IDA_FOOTER_LOG_CANCEL = 106; + static const int IDA_CHECKBUTTON_SELECT_ALL = 108; + static const int IDA_CHECKBUTTON_UNSELECT_ALL = 109; + +private: + ///Form Footer + Tizen::Ui::Controls::Footer* __pFormFooter; + + ///Delete footer item + Tizen::Ui::Controls::FooterItem __footerItemDelete; + + ///Cancel footer item + Tizen::Ui::Controls::FooterItem __footerItemCancel; + + ///Grouped list view + Tizen::Ui::Controls::GroupedListView* __plogsListView; + + ///Grouped list view + Tizen::Ui::Controls::CheckButton* __pButtonSelectAll; + + //Selected pop up label + Tizen::Ui::Controls::Label* __pSelectedLabel; + + ///Grouped list view item provider + CustomDataProvider* __pDataProvider; + + CallLogManager* __pCallMgr; + int __groupCount; + int __itemCount; + bool __isSelectAll; + int __selectedItemCount; + bool __isEditMode; + int calllogCount; + Tizen::Base::Collection::ArrayList* __pArgs; +}; + +#endif // _PHN_TAB_LOGS_H_ diff --git a/inc/PhnTabLogsItemProvider.h b/inc/PhnTabLogsItemProvider.h new file mode 100644 index 0000000..9592fa7 --- /dev/null +++ b/inc/PhnTabLogsItemProvider.h @@ -0,0 +1,123 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabLogsItemProvider.h + * @brief This is the header file for the %CustomDataProvider class. + * + * This header file contains the declarations for %CustomDataProvider class. + */ +#include +#include +#include +#include "PhnCalllogManager.h" + +#ifndef _PHN_TAB_LOGS_ITEM_PROVIDER_H_ +#define _PHN_TAB_LOGS_ITEM_PROVIDER_H_ + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +class GroupItemClass; + +/** + * @class CustomDataProvider + * @brief This class provides base class for item providers of calllog application + * + */ +class CustomDataProvider + : public Tizen::Ui::Controls::IGroupedListViewItemProvider +{ +public: + CustomDataProvider(void); + virtual ~CustomDataProvider(void); + + void SetListItemStyle(bool mode); + + // IGroupedListViewItemProvider + virtual int GetGroupCount(void); + virtual int GetItemCount(int groupIndex); + virtual Tizen::Ui::Controls::GroupItem* CreateGroupItem(int groupIndex, int itemWidth); + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth); + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int groupIndex, int itemIndex, int itemWidth); + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + + bool GetCurrentDateTime(Tizen::Base::DateTime& dt); + void CreateGroupItems(void); + bool IsGroupPresent(GroupItemClass* group); + GroupItemClass* GetGroupWithTitle(Tizen::Base::String title); + int GetDaysDifferenceBetweenDates(Tizen::Base::DateTime date1, Tizen::Base::DateTime date2); + void GetItemAtGroupIndex(int groupIndex, int itemIndex, CallLogDetails** pCalllogDetails); + void DeleteItemAtGroupIndex(int groupIndex, int itemIndex); + void DeleteAllItems(void); + +private: + bool __isEditStyle; + Tizen::Base::Collection::ArrayList* __pGroupData; + Tizen::Social::Addressbook* __pAddressBook; + Tizen::Ui::Controls::ListContextItem* __pItemContext; + +}; + +/** + * @class GroupItemClass + * @brief This class helps in storing group item data + * + */ +class GroupItemClass + :public Tizen::Base::Object +{ +private: + Tizen::Base::String __titleText; + Tizen::Base::Collection::ArrayList* __pData; + +public: + GroupItemClass(void); + virtual ~GroupItemClass(void); + + /** + * This function sets the titleText for the History object + * + * @return No return type + * @param titleText The titleText for the History + */ + void SetTitleText(Tizen::Base::String titleText); + + /** + * This function sets the data for the History object + * + * @return No return type + * @param pData The data for the History + */ + void SetLogData(Tizen::Base::Collection::ArrayList* pData); + + /** + * This function gets the GetTitleText of History + * + * @return A String + * @param No parameter + */ + Tizen::Base::String GetTitleText(void); + + /** + * This function gets the GetHistoryData of History + * + * @return A Pointer to ArrayList + * @param No parameter + */ + Tizen::Base::Collection::ArrayList* GetLogData(void); +}; +#endif /* _PHN_TAB_LOGS_ITEM_PROVIDER_H_ */ diff --git a/inc/PhnTelephonyManager.h b/inc/PhnTelephonyManager.h new file mode 100644 index 0000000..d37e210 --- /dev/null +++ b/inc/PhnTelephonyManager.h @@ -0,0 +1,203 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTelephonyManager.h + * @brief This is the header file for the %TelephonyManager class. + * + * This header file contains the declarations for %TelephonyManager class. + */ +#ifndef _PHN_TELEPHONY_MANAGER_H_ +#define _PHN_TELEPHONY_MANAGER_H_ + +#include +#include +#include "ITapiCall.h" +#include "TapiUtility.h" +#include "PhnITelephonyEventListener.h" +#include "PhnSoundManager.h" +#include "PhnCalllogManager.h" + +class CallInfo; +class SettingsManager; + +/** + * @class TelephonyManager + * @brief TelephonyManager is a singleton class used to intialize TAPI library. + * And register to telephony events, interact with TAPI library. + */ +class TelephonyManager +{ +public: + //Get singleton instance + static TelephonyManager* GetInstance(ITelephonyEventListener* pEventListener); + //Function to initiate (dial) an outgoing call. + ErrorCodes SetupMoCall(Tizen::Base::String& contactNumber, bool isEmergency); + //Function to end a call + result EndCall(Tizen::Base::Long callHandle); + result EndCall(Tizen::Base::String& contactNumber); + //Function to accept/reject an incoming call + result AnswerCall(int callHandle, bool acceptCall); + //Function to accept call with the given options + result AcceptCall(CallAnswerOptions answerOptions,int callHandle); + //Function to end a conference call + result EndConferenceCall(void); + //Function to hold/retrieve a conference call + result HoldConferenceCall(bool holdCall); + //Function to join active and held call to conference + result JoinCall(void); + //Function to hold/unhold the call + result HoldCall(Tizen::Base::Long callHandle, bool holdCall); + //Function to swap the active and held call + result SwapCalls(void); + //Function to send DTMF strings + result SendCallDTMF(Tizen::Base::String& textToBeSent); + //Function to end a single call from the conference + result EndFromConference(int callHandle); + //Function to split a single call from the conference + result SplitFromConference(int callHandle); + //Function to set the mute status + result SetMuteStatus(bool setMute); + //Function to get the mute Status + bool IsCallMuted(void); + //Function to set the speaker status + result SetSpeakerStatus(bool setSpeaker); + //Function to get the speaker status + bool IsSpeakerOn(void); + //Function to check if split operation is allowed from the conference + bool IsSplitAllowed(void); + //Function to get the conference call info + CallInfo* GetConferenceCallInfoN(void); + //Get the current call list + Tizen::Base::Collection::IListT* GetCallListN(void); + //Get the current call count + int GetCurrentCallCount(void); + //Start the alert in case of incoming call + void StartAlert(CallInfo& incomingCallInfo); + //Stop the alert in case of incoming call + void StopAlert(void); + //Main Callback function used while registering to TAPI + static void HandleCallback(TapiHandle* pHandle, const char* pNotiId, void* pData, void* pUserData); + //Dummy callback function used when nothing is to be done on response + static void HandleCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function used when dialed call is ended + static void HandleEndDialedCallResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for dial operation + static void HandleDialCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for the join operation + static void HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for the reject call operation + static void HandleRejectCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for the swap calls operation + static void HandleSwapCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for the End from conference operation + static void HandleEndFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function for the split from conference operation + static void HandleSplitFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData); + //callback function to handle the idle callback(received when call is ended) + static void HandleIdleCallBack(void* pData, TelephonyManager* pTelManager); + //callback function to handle the active callback(received when call is connected) + static void HandleActiveCallBack(void* pData, TelephonyManager* pTelManager); + //callback function to handle the incoming call callback + static void HandleIncomingCallBack(void* pData, TelephonyManager* pTelManager); + //callback function to handle the dial call callback + static void HandleDialingCallBack(void* pData, TelephonyManager* pTelManager); + //Check if MOCall is emergency number and returns true. Otherwise, false. + bool CheckIfMOCallIsEmergency(const Tizen::Base::String& contactNumber, bool isSimInitialized); + //Check is modem and sim are initialised successfully and MO call can be made. + result CheckIfMOCallIsPossible(); + //Gets the contact for the given phonenumber.returns null if not present. + Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber); + //This function make a synchronus API call to TAPI to fetch active/waiting incoming calls. + CallInfo* FetchIncomingCallHandleN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber); + //This callback function is called by TAPI each time for every single call. + static void HandleIncomingCallStatusCallBack(TelCallStatus_t* pCallStatus, void* pUserData); + //function used to process incoming call and decide whether to reject call based on call settings. + //Rejects the call and returns true, Else returns false. + bool CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo); + +private: + //create a singleton instance + static void CreateInstance(ITelephonyEventListener* pEventListener); + //used to destroy 'TelephonyManager' instance at application exit. + static void DestroyInstance(void); + //private destructor + virtual ~TelephonyManager(void); + TelephonyManager(ITelephonyEventListener* pEventListener); + TelephonyManager(TelephonyManager& manager); + TelephonyManager& operator =(TelephonyManager& manager); + //perform 2nd phase initialisation + result Initialize(void); + //initialise the TAPI library + result InitializeTelephonyLibrary(void); + //register for the TAPI events + int RegisterEvents(void); + //unregister from the TAPI events + void UnregisterEvents(void); + //internal function to hold an active call + result HoldActiveCall(CallInfo* pActiveCallInfo, bool holdCall); + //internal function to make a call + result DialOutgoingCall(Tizen::Base::String& contactNumber, bool isEmergency); + //internal function to handle waiting call options when single call is present + result AcceptSecondCall(CallAnswerOptions answerOptions,int callHandle); + //internal function to handle waiting call options when multiple calls are present + result AcceptMultipleCall(CallAnswerOptions answerOptions,int callHandle); + /** + * This function is internally used to fetch contact person details - + * display name & photo id from AddressBook for the given phone number. + * + * @param[in] phoneNumber - The substring of the phoneNumber to search + * @return E_SUCCESS, if found else E_FAILURE. + */ + result FetchContactInfoForNumber(const Tizen::Base::String& phoneNumberStr); + //check if given contact number is valid and returns 'E_SUCCESS', else 'E_FAILURE'. + result CheckValidTelePhoneNumber(const Tizen::Base::String& contactNumber); + //End all active + void EndAllCalls(void); + +private: + static TelephonyManager* __pManager; + + //Outgoing call Info + CallInfo* __pDialedCall; + //Incoming call Info + CallInfo* __pIncomingCall; + //Active Calls - only 2 active calls at any time + //can hold both Single or Conf. Calls + //mapping of "Call handle" to "CallInfo" + Tizen::Base::Collection::HashMapT* __pActiveCallList; + + //Listener for telephony events + ITelephonyEventListener* __pEventListener; + + SettingsManager* __pSettingsManager; + + //handle to Telephony API + TapiHandle* __pTapiHandle; + bool __isIncomingCallPresent; + //used to connect to Address Book APIs. + Tizen::Social::Addressbook* __pAddressBook; + //used to store previously fetched contact. + Tizen::Social::Contact* __pCachedContact; + //mute status + bool __isMuted; + //Speaker Status + bool __isSpeakerOn; + SoundManager* __pSoundManager; + CallLogManager* __pCalllogMgr; +}; + +#endif // _PHN_TELEPHONY_MANAGER_H_ diff --git a/inc/PhnTypes.h b/inc/PhnTypes.h new file mode 100644 index 0000000..03e86b0 --- /dev/null +++ b/inc/PhnTypes.h @@ -0,0 +1,448 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTypes.h + * @brief This is the header file provides common constants and enums used across application. + * + */ +#ifndef PHNTYPES_H_ +#define PHNTYPES_H_ + +#include "PhnCommonUtils.h" + +//bitmap +extern const wchar_t* IDB_BTN_OPTION_BG_ICON ; +extern const wchar_t* IDB_BTN_OPTION_PRESS_BG_ICON; +extern const wchar_t* IDB_BTN_MORE_ICON ; +extern const wchar_t* IDB_BTN_MORE_PRESS_ICON ; +extern const wchar_t* IDB_POPUP_BUBBLE_ICON ; +extern const wchar_t* IDB_DIALER_BTN_LINE_ICON; +extern const wchar_t* IDB_DIALER_BTN_PRESS_ICON; +extern const wchar_t* IDB_VOICEMAIL_BTN_ICON; +extern const wchar_t* IDB_VOICEMAIL_BTN_PRESS_ICON; +extern const wchar_t* IDB_DIALER_BTN_LINE2_ICON; +extern const wchar_t* IDB_DIALER_BTN_LINE3_ICON; +extern const wchar_t* IDB_DIALER_BTN_LINE4_ICON; +extern const wchar_t* IDB_DIALER_BTN_LINE5_ICON; +extern const wchar_t* IDB_DIALER_STAR_ICON ; +extern const wchar_t* IDB_DIALER_MUTE_ICON ; +extern const wchar_t* IDB_DIALER_VIDEOCALL_ICON ; +extern const wchar_t* IDB_DIALER_CALL_ICON ; +extern const wchar_t* IDB_DIALER_CLEAR_ICON ; +extern const wchar_t* IDB_DIALER_CALL_BG_ICON ; +extern const wchar_t* IDB_HIDE_KEYPAD_ICON; +extern const wchar_t* IDB_HIDE_KEYPAD_PRESS_ICON; +extern const wchar_t* IDB_HIDE_KEYPAD_DIM_ICON; +extern const wchar_t* IDB_CLOSE_KEYPAD_ICON; +extern const wchar_t* IDB_CLOSE_KEYPAD_PRESS_ICON; +extern const wchar_t* IDB_CLOSE_KEYPAD_DIM_ICON; +extern const wchar_t* IDB_SPEAKER_ON_ICON; +extern const wchar_t* IDB_SPEAKER_ON_PRESS_ICON; +extern const wchar_t* IDB_SPEAKER_ON_DIM_ICON; +extern const wchar_t* IDB_SPEAKER_OFF_ICON; +extern const wchar_t* IDB_SPEAKER_OFF_PRESS_ICON; +extern const wchar_t* IDB_SPEAKER_OFF_DIM_ICON; +extern const wchar_t* IDB_MUTE_ON_ICON; +extern const wchar_t* IDB_MUTE_ON_PRESS_ICON; +extern const wchar_t* IDB_MUTE_ON_DIM_ICON; +extern const wchar_t* IDB_MUTE_OFF_ICON; +extern const wchar_t* IDB_MUTE_OFF_PRESS_ICON; +extern const wchar_t* IDB_MUTE_OFF_DIM_ICON; +extern const wchar_t* IDB_BACKGROUND_BITMAP; +extern const wchar_t* IDB_VOICE_CALL_ICON; +extern const wchar_t* IDB_VOICE_CALL_PRESS_ICON; +extern const wchar_t* IDB_VOICE_CALL_DIM_ICON; +extern const wchar_t* IDB_VIDEO_CALL_ICON; +extern const wchar_t* IDB_VIDEO_CALL_PRESS_ICON; +extern const wchar_t* IDB_VIDEO_CALL_DIM_ICON; +extern const wchar_t* IDB_MESSAGE_ICON; +extern const wchar_t* IDB_MESSAGE_PRESS_ICON; +extern const wchar_t* IDB_MESSAGE_DIM_ICON; +extern const wchar_t* IDB_END_CALL_ICON; +extern const wchar_t* IDB_END_CALL_PRESS_ICON; +extern const wchar_t* IDB_END_CALL_DIM_ICON; +extern const wchar_t* IDB_ADD_CALL_ICON; +extern const wchar_t* IDB_ADD_CALL_PRESS_ICON; +extern const wchar_t* IDB_ADD_CALL_DIM_ICON; +extern const wchar_t* IDB_JOIN_CALL_ICON; +extern const wchar_t* IDB_JOIN_CALL_PRESS_ICON; +extern const wchar_t* IDB_JOIN_CALL_DIM_ICON; +extern const wchar_t* IDB_CONTACT_ICON; +extern const wchar_t* IDB_CONTACT_PRESS_ICON; +extern const wchar_t* IDB_CONTACT_DIM_ICON; +extern const wchar_t* IDB_SWAP_ICON_NORMAL; +extern const wchar_t* IDB_SWAP_ICON_PRESS; +extern const wchar_t* IDB_POPUP_ARROW_ICON; +extern const wchar_t* IDB_POPUP_BG_ICON; +extern const wchar_t* IDB_MORE_MANAGE_CONFERENCE_ICON; +extern const wchar_t* IDB_CONFERENCE_BG_ICON; +extern const wchar_t* IDB_CONFERENCE_BIG_BG_ICON; +extern const wchar_t* IDB_ACTIVE_CALL_DEFAULT_ICON; +extern const wchar_t* IDB_MULTIPLE_CALL_DEFAULT_ICON; +extern const wchar_t* IDB_KEYPAD_BUTTON_NORMAL; +extern const wchar_t* IDB_KEYPAD_BUTTON_PRESS; +extern const wchar_t* IDB_KEYPAD_NUM1_ICON; +extern const wchar_t* IDB_HOLD_NORMAL_BUTTON_ICON; +extern const wchar_t* IDB_HOLD_PRESS_BUTTON_ICON; +extern const wchar_t* IDB_UNHOLD_NORMAL_BUTTON_ICON; +extern const wchar_t* IDB_UNHOLD_PRESS_BUTTON_ICON; +extern const wchar_t* IDB_CALLOG_LIST_BG; +extern const wchar_t* IDB_LOG_RECEIVEDCALL_ICON; +extern const wchar_t* IDB_LOG_DIALEDCALL_ICON; +extern const wchar_t* IDB_LOG_MISSEDCALL_ICON; +extern const wchar_t* IDB_LOG_BLOCKEDCALL_ICON; +extern const wchar_t* IDB_LOG_DETAIL_CALL_ICON; +extern const wchar_t* IDB_LOG_DETAIL_MSG_ICON; +extern const wchar_t* IDB_LOG_NO_CONTENT; + +//String messages +extern const wchar_t* IDS_DIALER_MOBILE_STR; +extern const wchar_t* IDS_DIALER_SPEEDDIAL_POPUP_MSG; +extern const wchar_t* IDS_SPEEDDIAL_POP_YES_BTN_STRING; +extern const wchar_t* IDS_SPEEDDIAL_POP_NO_BTN_STRING; +extern const wchar_t* IDS_DIALER_MENU_ITEM_SEND_MSG; +extern const wchar_t* IDS_DIALER_MENU_ITEM_ADD_CONTACT; +extern const wchar_t* IDS_DIALER_MENU_ITEM_SPEED_DIAL; +extern const wchar_t* IDS_DIALER_MENU_ITEM_ADD_PAUSE; +extern const wchar_t* IDS_DIALER_MENU_ITEM_ADD_WAIT; +extern const wchar_t* IDS_DIALER_MENU_ITEM_EXIT; +extern const wchar_t* IDS_SPEED_DIAL_SEARCH_KEY; +extern const wchar_t* IDS_KEYPAD_BTN_NAME; +extern const wchar_t* IDS_SPEAKER_BTN_NAME; +extern const wchar_t* IDS_MUTE_BTN_NAME; +extern const wchar_t* IDS_VOICE_CALL_BTN_NAME; +extern const wchar_t* IDS_VIDEO_CALL_BTN_NAME; +extern const wchar_t* IDS_MSG_BTN_NAME; +extern const wchar_t* IDS_ENDCALL_BTN_NAME; +extern const wchar_t* IDS_ADDCALL_BTN_NAME; +extern const wchar_t* IDS_JOINCALL_BTN_NAME; +extern const wchar_t* IDS_CONTACT_BTN_NAME; +extern const wchar_t* IDS_HOLD_BTN_NAME; +extern const wchar_t* IDS_UNHOLD_BTN_NAME; +extern const wchar_t* IDS_PEOPLE_STR; +extern const wchar_t* IDS_MGR_CONF_CALL_LIST_STR; +extern const wchar_t* IDS_LOG_CONTEXT_CALL; +extern const wchar_t* IDS_LOG_CONTEXT_MESSAGE; +extern const wchar_t* IDS_LOG_CONTEXT_VIDEOCALL; +extern const wchar_t* IDS_LOG_CONTEXT_DELETE; +extern const wchar_t* IDS_AM_TIME; +extern const wchar_t* IDS_PM_TIME; +extern const wchar_t* IDS_CALLLOG_NO_NAME; +extern const wchar_t* IDS_CALLLOG_NO_NUMBER; +extern const wchar_t* IDS_CALLLOG_RECEIVED; +extern const wchar_t* IDS_CALLLOG_MISSED; +extern const wchar_t* IDS_CALLLOG_OUTGOING; +extern const wchar_t* IDS_CALLLOG_RECEIVED_MSG; +extern const wchar_t* IDS_CALLLOG_SENT_MSG; +extern const wchar_t* IDS_CALLLOG_REJECTED; +extern const wchar_t* IDS_CALLLOG_DELETE_FOOTER; +extern const wchar_t* IDS_CALLLOG_CANCEL_FOOTER; +extern const wchar_t* IDS_EMERGENCY_CALL; +extern const wchar_t* IDS_SELECT_CALL_LOG ; +extern const wchar_t* IDS_SELECTED_ITEM_STRING; +extern const wchar_t* IDS_SELECTED_ITEMS_STRING; +extern const wchar_t* IDS_SELECT_NUMBER; +extern const wchar_t* IDS_NUMBER_SELECTED; +extern const wchar_t* IDS_NUMBERS_SELECTED; +extern const wchar_t* IDS_SELECT_MESSAGE; +extern const wchar_t* IDS_MESSAGE_SELECTED; +extern const wchar_t* IDS_MESSAGES_SELECTED; +extern const wchar_t* IDS_NO_LOGS; + +//Panel +extern const wchar_t* PANEL_DIALER; +extern const wchar_t* PANEL_LOGS; + +//Corresponding Call form name +extern const wchar_t* IDL_FORM_OUTCALL; +extern const wchar_t* IDL_FORM_OUT_EMERGENCYCALL; +extern const wchar_t* IDL_FORM_INCOMINGCALL; +extern const wchar_t* IDL_FORM_ACTIVECALL; +extern const wchar_t* IDL_FORM_ACTIVE_EMERGENCYCALL; +extern const wchar_t* IDL_FORM_CONFCALL; +extern const wchar_t* IDL_FORM_CONFCALLLIST; +extern const wchar_t* IDL_FORM_ENDCALL; +extern const wchar_t* IDL_FORM_MULTIPLEACTIVECALL; +//Corresponding Settings form name +extern const wchar_t* IDL_FORM_SETTINGS_PREFIX; +extern const wchar_t* IDL_FORM_MAIN_SETTING_MENU; +extern const wchar_t* IDL_FORM_CALL_REJECTLIST_MENU; +extern const wchar_t* IDL_FORM_CALL_REJECTMSGS_MENU; +extern const wchar_t* IDL_FORM_SPEED_DIAL; +extern const wchar_t* IDL_FORM_MORE_OPTIONS; +extern const wchar_t* IDL_FORM_CALL_STATUSTONES; +extern const wchar_t* IDL_FORM_CALLTYPE_FORWARD; +extern const wchar_t* IDL_FORM_CALL_FORWARD_OPTIONS; +extern const wchar_t* IDL_FORM_CALLTYPE_BARRING; +extern const wchar_t* IDL_FORM_CALL_BARRING_OPTIONS; +extern const wchar_t* IDL_FORM_CALL_WAITING_OPTIONS; +extern const wchar_t* IDL_FORM_ADD_REJECT_NUMBER; +extern const wchar_t* IDL_FORM_AUTO_AREA_CODE; +extern const wchar_t* IDL_FORM_ADD_REJECT_MSG; +extern const wchar_t* IDL_FORM_EDIT_REJECT_MSG; +extern const wchar_t* IDL_FORM_FORWARD_TO_NUMBER; +extern const wchar_t* IDL_FORM_NOREPLY_FORWARD_TO_NUMBER; +extern const wchar_t* IDL_FORM_SCENE_SET_BARRING_PWD; +extern const wchar_t* IDL_FORM_DEL_NUMBER; +extern const wchar_t* IDL_FORM_DEL_MESSAGE; +//Dialer & Call Log Form names +extern const wchar_t* IDL_FORM_DIAL_APP; +extern const wchar_t* IDL_FORM_CALL_LOG_DETAIL; +extern const wchar_t* IDL_CALL_PANEL; +extern const wchar_t* IDL_END_CALL_PANEL; +extern const wchar_t* IDL_OUTCALL_FORM; +extern const wchar_t* IDL_OUT_EMERGENCYCALL_FORM; +extern const wchar_t* IDL_CALL_FORM; +extern const wchar_t* IDL_EMERGENCY_CALL_FORM; +extern const wchar_t* IDL_MULTIPLE_CALL_FORM; +extern const wchar_t* IDL_CONFCALL_FORM; +extern const wchar_t* IDL_DTMF_PANEL; +extern const wchar_t* IDL_DIALER_KEYPAD_PANEL; +extern const wchar_t* IDL_FORM_EMERGENCY_DIAL; + +//Constants - Call Scene name +extern const wchar_t* IDSCN_SCENE_OUTCALL; +extern const wchar_t* IDSCN_SCENE_OUT_EMERGENCYCALL; +extern const wchar_t* IDSCN_SCENE_INCOMINGCALL; +extern const wchar_t* IDSCN_SCENE_ACTIVECALL; +extern const wchar_t* IDSCN_SCENE_ACTIVE_EMERGENCYCALL; +extern const wchar_t* IDSCN_SCENE_CONFCALL; +extern const wchar_t* IDSCN_SCENE_CONFCALLLIST; +extern const wchar_t* IDSCN_SCENE_ENDCALL; +extern const wchar_t* IDSCN_SCENE_MULTIPLEACTIVECALL; +//Constants - Settings Scene name +extern const wchar_t* IDSCN_SCENE_MAIN_SETTING_MENU; +extern const wchar_t* IDSCN_SCENE_CALL_REJECTLIST_MENU; +extern const wchar_t* IDSCN_SCENE_CALL_REJECTMSGS_MENU; +extern const wchar_t* IDSCN_SCENE_SPEED_DIAL; +extern const wchar_t* IDSCN_SCENE_MORE_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALL_STATUSTONES; +extern const wchar_t* IDSCN_SCENE_CALLTYPE_FORWARD; +extern const wchar_t* IDSCN_SCENE_CALL_FORWARD_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALLTYPE_BARRING; +extern const wchar_t* IDSCN_SCENE_CALL_BARRING_OPTIONS; +extern const wchar_t* IDSCN_SCENE_CALL_WAITING_OPTIONS; +extern const wchar_t* IDSCN_SCENE_ADD_REJECT_NUMBER; +extern const wchar_t* IDSCN_SCENE_AUTO_AREA_CODE; +extern const wchar_t* IDSCN_SCENE_ADD_REJECT_MSG; +extern const wchar_t* IDSCN_SCENE_EDIT_REJECT_MSG; +extern const wchar_t* IDSCN_SCENE_FORWARD_TO_NUMBER; +extern const wchar_t* IDSCN_SCENE_NOREPLY_FORWARD_TO_NUMBER; +extern const wchar_t* IDSCN_SCENE_SET_BARRING_PWD; +extern const wchar_t* IDSCN_SCENE_DEL_NUMBER; +extern const wchar_t* IDSCN_SCENE_DEL_MESSAGE; +//Dialer & Call Log Scene names +extern const wchar_t* IDSCN_DIALER; +extern const wchar_t* IDSCN_CALL_LOG; +extern const wchar_t* IDSCN_CALL_LOG_DETAILS; +extern const wchar_t* IDSCN_EMERGENCY_DIAL; + +extern const wchar_t* TYPE_VIDEO; +extern const wchar_t* TYPE_VOICE; +extern const wchar_t* TYPE_SMS; +extern const wchar_t* TEL; +extern const wchar_t* TO; + +extern const wchar_t* OPERATION_ID_PICK; +extern const wchar_t* OPERATION_ID_VIEW; +extern const wchar_t* OPERATION_ID_ADD; +extern const wchar_t* OPERATION_ID_EDIT; +extern const wchar_t* OPERATION_ID_CONFIGURE; +extern const wchar_t* OPERATION_ID_CAPTURE; +extern const wchar_t* OPERATION_ID_CALL; +extern const wchar_t* OPERATION_ID_COMPOSE; +extern const wchar_t* OPERATION_ID_DIAL; + +extern const wchar_t* PROVIDER_ID_CAMERA; +extern const wchar_t* PROVIDER_ID_GALLERY; +extern const wchar_t* PROVIDER_ID_CALL; +extern const wchar_t* PROVIDER_ID_MESSAGE; +extern const wchar_t* PROVIDER_ID_EMAIL; +extern const wchar_t* PROVIDER_ID_MEDIA; +extern const wchar_t* PROVIDER_ID_CONTACTS; + +extern const wchar_t* RETURN_TYPE_PHONE; +extern const wchar_t* RETURN_TYPE_EMAIL; +extern const wchar_t* RETURN_TYPE_CONTACT_ID; + +extern const wchar_t* DELIMITER; +extern const wchar_t* LAUNCHTYPE; +extern const wchar_t* PARAM_ORIGIN_MT; +extern const wchar_t* CALL_HANDLE; +extern const wchar_t* CONTACT_NUMBER; +extern const wchar_t* PARAM_CALL_TYPE; +extern const wchar_t* PARAM_CALL_VALUE_VOICE; +extern const wchar_t* PARAM_PHONE_NUMBER; +extern const wchar_t* INPUT_TYPE_PHONE; +extern const wchar_t* MESSAGE_TYPE; +extern const wchar_t* MESSAGE_SMS_TYPE; +extern const wchar_t* MESSAGE_TEXT; +extern const wchar_t* MESSAGE_TO; + +extern const wchar_t* SELECTION_MODE; +extern const wchar_t* RETURN_TYPE; +extern const wchar_t* SELECTION_MODE_SINGLE; +extern const wchar_t* RETURN_KEY_VALUE; + +//Voice Call- Common Command Ids +enum CommandIds +{ + IDA_ADD_CALL = DIAL_CMD_TOTAL_COUNT+1, + IDA_JOIN_CALL, + IDA_OPEN_CONTACTS, + IDA_HOLD_CALL, + IDA_UNHOLD_CALL, + IDA_MUTE, + IDA_UNMUTE, + IDA_SPEAKER, + IDA_SPEAKER_OFF, + IDA_OPEN_NUMKEYPAD, + IDA_CLOSE_NUMKEYPAD, + IDA_END_CALL, + IDA_SHOW_REJECT_CALL_MESSAGE_PANEL, //Show the reject with message panel + IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL,//Cancel the reject with message panel + IDA_CREATE_REJECT_CALL_MESSAGE,//Reject the call with new message + IDA_VOICE_CALL, + IDA_VIDEO_CALL, + IDA_MESSAGE, + IDA_END_CONF_CALL, + IDA_HOLD_CONF_CALL, + IDA_UNHOLD_CONF_CALL, + IDA_ADD_TO_CONTACTS, //add current contact to AddressBook + IDA_BACK_EVENT, + IDA_SWAP_CALLS, + IDA_MORE_OPTIONS_MENU, + IDA_MORE_CONF_CALLLIST_OPTION, + IDA_SEND_REJECT_MSG1, + IDA_SEND_REJECT_MSG2, + IDA_SEND_REJECT_MSG3, + IDA_SEND_REJECT_MSG4, + IDA_SEND_REJECT_MSG5, + IDA_SEND_REJECT_MSG6, + IDA_CALL_WAITING_OPTION_CHECKED, + IDA_CALL_WAITING_OPTION_UNCHECKED, + IDA_TOTAL_CMD_IDS, +}; + +//Command Ids for Ending Caller in Conference list. +enum EndConfCallerCmdIds +{ + IDA_END_CALLER1 = IDA_TOTAL_CMD_IDS + 1, + IDA_END_CALLER2, + IDA_END_CALLER3, + IDA_END_CALLER4, + IDA_END_CALLER5, + IDA_TOTAL_ENDCONFCALLER_CMD_IDS, +}; + +enum SplitConfCallerCmdIds +{ + IDA_SPLIT_CALLER1 = IDA_TOTAL_ENDCONFCALLER_CMD_IDS + 1, + IDA_SPLIT_CALLER2, + IDA_SPLIT_CALLER3, + IDA_SPLIT_CALLER4, + IDA_SPLIT_CALLER5, + IDA_TOTAL_SPLITCONFCALLER_CMD_IDS, +}; + +enum CallAnswerOptions +{ + CALL_ANSWER_HOLD_ACCEPT, + CALL_ANSWER_END_ACTIVE_ACCEPT, + CALL_ANSWER_END_HELD_ACCEPT, + CALL_ANSWER_END_ALL_ACCEPT, + CALL_ANSWER_CALL +}; + +enum SoundMode +{ + SOUND_MODE_VOICE = 0, + SOUND_MODE_RINGTONE, + SOUND_MODE_MEDIA +}; + +//Type of the call (incoming, outgoing etc for call log database +enum CallLogType +{ + CALL_LOG_TYPE_VOICE_INCOMING, + CALL_LOG_TYPE_VOICE_OUTGOING, + CALL_LOG_TYPE_VOICE_MISSED, + CALL_LOG_TYPE_VOICE_REJECTED, + CALL_LOG_TYPE_VOICE_BLOCKED, + CALL_LOG_TYPE_SMS_INCOMING, + CALL_LOG_TYPE_SMS_OUTGOING, +}; + +//Error code to handle error scenarios +enum ErrorCodes +{ + ERROR_NONE, + ERROR_INVALID_INPUT, + ERROR_DIAL_FAILED, + ERROR_INVALID_NUMBER, + ERROR_REJECT_FAILED, + ERROR_JOIN_FAILED, + ERROR_SWAP_FAILED, + ERROR_END_CALL_FAILED, + ERROR_END_FROM_CONFERENCE_FAILED, + ERROR_SPLIT_FROM_CONFERENCE_FAILED, + ERROR_CODE_SIM_INITIALIZATION_FAILED, + ERROR_NOT_EMERGENCY_NUM, + ERROR_TAPI_INIT_FAILED, + ERROR_TAPI_ERROR, + ERROR_BARRING_PWD_TOO_LONG, + ERROR_GENERAL, +}; + +enum DialerRequestType +{ + REQUEST_SHOW_SUGGESTION, + REQUEST_SHOW_ADD_TO_CONTACTS, + REQUEST_SHOW_SPEED_DIAL_POPUP, + REQUEST_CALL_SPEED_DIAL_NUM, +}; + +enum IncomingCallFormRequestType +{ + REQUEST_ITEM_SELECTED, +}; + + +//Dimensions for Small photo of caller/callee. +extern const int W_SMALL_PHOTO; +extern const int H_SMALL_PHOTO; +extern const int W_CONFERENCE_PHOTO; +extern const int H_CONFERENCE_PHOTO; +//Maximum number of calls +extern const int IDI_MAX_ACTIVE_CALLS; +extern const int IDI_MAX_CONF_CALL_PARTICIPANTS; +//Constants used for custom list item in message panel in Incoming call screen +extern const int IDA_FORMAT_SENDTEXT; +extern const int IDA_BUTTON_CANCEL_OPTIONS_POPUP; +extern const int ID_MULTI_PARTY_CALL; +extern const int ID_SECOND_INCOMING_CALL; +//Constants +extern const wchar_t* IDI_KEY2_TXT; +extern const wchar_t* IDI_KEY3_TXT; +extern const wchar_t* IDI_KEY4_TXT; +extern const wchar_t* IDI_KEY5_TXT; +extern const wchar_t* IDI_KEY6_TXT; +extern const wchar_t* IDI_KEY7_TXT; +extern const wchar_t* IDI_KEY8_TXT; +extern const wchar_t* IDI_KEY9_TXT; + +#endif /* PHNTYPES_H_ */ diff --git a/lib/nofile.dummy b/lib/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 0000000..cfcb9d5 --- /dev/null +++ b/manifest.xml @@ -0,0 +1,50 @@ + + + zktdpemtmw + 1.0.0 + C++App + + + + + + + true + true + + + 2.0 + + http://tizen.org/privilege/application.launch + http://tizen.org/privilege/setting + http://tizen.org/privilege/messaging.sms + http://tizen.org/privilege/contact.read + + + + + + Phone-Ref + Phone-Ref + + + mainmenu.png + + + + http://tizen.org/appcontrol/operation/call + http://tizen.org/appcontrol/operation/configure + http://tizen.org/appcontrol/operation/dial + tel + + + + + On + On + Off + On + + + + diff --git a/packaging/apps.Phone.spec b/packaging/apps.Phone.spec new file mode 100644 index 0000000..be2520c --- /dev/null +++ b/packaging/apps.Phone.spec @@ -0,0 +1,67 @@ +Name: apps.Phone +Summary: Phone application +Version: 1.0.0.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: pkgconfig(osp-social) +BuildRequires: pkgconfig(osp-messaging) +BuildRequires: pkgconfig(osp-media) +BuildRequires: pkgconfig(osp-image) +BuildRequires: pkgconfig(osp-image-core) +BuildRequires: pkgconfig(osp-shell) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(capi-media-sound-manager) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(tapi) +BuildRequires: pkgconfig(mm-sound) +BuildRequires: pkgconfig(contacts-service2) +BuildRequires: osp-appfw-internal-devel +BuildRequires: osp-uifw-internal-devel +BuildRequires: osp-media-internal-devel + + # runtime requires +Requires: osp-installer + +%description +Verification application: Phone + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post +/sbin/ldconfig +PKG_ID=zktdpemtmw +echo "/usr/etc/package-manager/backend/tpk -i /usr/apps/"${PKG_ID} +/usr/etc/package-manager/backend/tpk -i /usr/apps/${PKG_ID} +cp -f /usr/lib/osp/osp-ui-app-loader /usr/apps/${PKG_ID}/bin/Phone +/usr/bin/vconftool set -t int memory/call/state "0" -g 6521 -i -f + +%postun +/sbin/ldconfig +PKG_ID=zktdpemtmw +echo "/usr/etc/package-manager/backend/tpk -u "${PKG_ID} +/usr/etc/package-manager/backend/tpk -u ${PKG_ID} + +%files +%defattr(-,root,root,-) +/usr/apps/* diff --git a/res/eng-GB.xml b/res/eng-GB.xml new file mode 100644 index 0000000..984903a --- /dev/null +++ b/res/eng-GB.xml @@ -0,0 +1,168 @@ + + + + If no reply + Show + Call connect tone + Delete + Exit + There will be a signal sound when the line is connected + Call waiting, Call barring, Prefix... + Keypad + Match criteria + Sep + Mute + Manage auto reject mode + Int'l calls + Done + No Messages + seconds + Hide + No Logs + Add call + Add Wait + Yes + %d Messages Selected + Voice call + Minute reminders + Set reject messages + already in use + .Name + There will be a signal sound when the line is disconnected + During call, notify me of incoming calls + Set reject messages + End call + If busy + Remove + Cancel + Includes + Call forwarding + Auto area code + Invalid Number. + Rejected Call + people + Add Contact + Off + Speed Dial + Contact + Oct + AM + Ends with + SPEED DIAL + Cancel + Change contact + %d call logs selected + No Number + Save + Call rejection + %d Number Selected + Add the area code on the dialer by default + No Name + Barring Password length should be less than or equal to 4. + Apr + Speed dial + Join call + Jun + Jul + Mobile + Waiting time + Call waiting + If out of reach + Incoming when roaming + TAPI Server initialization failed. + Add + Message + Voice Call forwarding + May + Edit + Show my caller ID + Mar + Received Message + Alerts on call + SELECT SPEED DIAL + Send Message + Exactly the same as + Hold + Accept call after + Outgoing Call + Call waiting + TAPI Error occurred. + Call status tones + Emergency Calls Only. + Putting held calls(%d) on hold + Putting active calls(%d) on hold + Ending all calls + Unknown + Ending call + Ending active calls(%d) + Split From Conference Failed. + Ending held calls(%d) + Ending call with + Putting %ls on hold + Call forwarding + %d Numbers Selected + Unhold + Add Pause + Call waiting + Select all + Call end tone + Sound + Call barring + All incoming calls + Select number + %d Message Selected + Not assigned + Start with + Voice call + Invalid Parameters Passed. + Edit alerts that sound during calls + Int'l calls except home + Conference call + Speaker + Delete + No + Select Call log + Missed Call + Received Call + Feb + Dec + Select Number + Sim initialization is failed or not completed. + Select Message + Call barring + Nov + Sound + Vibration + Reject With Message + Cancel + All outgoing calls + Video call + Manage conference call + Sent Message + Enter number + No Speed dial assigned.\n Assign now? + By network + Close + Send + EMERGENCY CALL + PM + Show + Call not allowed. + Edit reject messages + General Error. + More call settings + Voice call barring + Reject Failed. + Always + There will be signal sounds every minute + Video call + Swap Failed. + Deactivated + End From Conference failed. + Join Failed. + Aug + Jan + %d call log selected + diff --git a/res/screen-density-xhigh/00_Nocontents_text.png b/res/screen-density-xhigh/00_Nocontents_text.png new file mode 100644 index 0000000..55b7329 Binary files /dev/null and b/res/screen-density-xhigh/00_Nocontents_text.png differ diff --git a/res/screen-density-xhigh/00_button_01_normal.png b/res/screen-density-xhigh/00_button_01_normal.png new file mode 100644 index 0000000..76865ec Binary files /dev/null and b/res/screen-density-xhigh/00_button_01_normal.png differ diff --git a/res/screen-density-xhigh/00_button_04_dim.png b/res/screen-density-xhigh/00_button_04_dim.png new file mode 100644 index 0000000..76865ec Binary files /dev/null and b/res/screen-density-xhigh/00_button_04_dim.png differ diff --git a/res/screen-density-xhigh/00_button_04_normal.png b/res/screen-density-xhigh/00_button_04_normal.png new file mode 100644 index 0000000..76865ec Binary files /dev/null and b/res/screen-density-xhigh/00_button_04_normal.png differ diff --git a/res/screen-density-xhigh/00_button_04_normal_focus.png b/res/screen-density-xhigh/00_button_04_normal_focus.png new file mode 100644 index 0000000..06c39d8 Binary files /dev/null and b/res/screen-density-xhigh/00_button_04_normal_focus.png differ diff --git a/res/screen-density-xhigh/00_button_06_normal.9.png b/res/screen-density-xhigh/00_button_06_normal.9.png new file mode 100644 index 0000000..355f50d Binary files /dev/null and b/res/screen-density-xhigh/00_button_06_normal.9.png differ diff --git a/res/screen-density-xhigh/00_button_06_press.9.png b/res/screen-density-xhigh/00_button_06_press.9.png new file mode 100644 index 0000000..2bae489 Binary files /dev/null and b/res/screen-density-xhigh/00_button_06_press.9.png differ diff --git a/res/screen-density-xhigh/00_button_cancel_normal.png b/res/screen-density-xhigh/00_button_cancel_normal.png new file mode 100644 index 0000000..f8eaf80 Binary files /dev/null and b/res/screen-density-xhigh/00_button_cancel_normal.png differ diff --git a/res/screen-density-xhigh/00_button_cancel_press.png b/res/screen-density-xhigh/00_button_cancel_press.png new file mode 100644 index 0000000..f8eaf80 Binary files /dev/null and b/res/screen-density-xhigh/00_button_cancel_press.png differ diff --git a/res/screen-density-xhigh/00_button_normal_bg.9.png b/res/screen-density-xhigh/00_button_normal_bg.9.png new file mode 100644 index 0000000..325b542 Binary files /dev/null and b/res/screen-density-xhigh/00_button_normal_bg.9.png differ diff --git a/res/screen-density-xhigh/00_icon_Back.png b/res/screen-density-xhigh/00_icon_Back.png new file mode 100644 index 0000000..e217a0a Binary files /dev/null and b/res/screen-density-xhigh/00_icon_Back.png differ diff --git a/res/screen-density-xhigh/00_icon_Back_press.png b/res/screen-density-xhigh/00_icon_Back_press.png new file mode 100644 index 0000000..344e209 Binary files /dev/null and b/res/screen-density-xhigh/00_icon_Back_press.png differ diff --git a/res/screen-density-xhigh/00_index list_bg.png b/res/screen-density-xhigh/00_index list_bg.png new file mode 100644 index 0000000..f41ec7c Binary files /dev/null and b/res/screen-density-xhigh/00_index list_bg.png differ diff --git a/res/screen-density-xhigh/00_indexlist_icon_opened.png b/res/screen-density-xhigh/00_indexlist_icon_opened.png new file mode 100644 index 0000000..4a07f55 Binary files /dev/null and b/res/screen-density-xhigh/00_indexlist_icon_opened.png differ diff --git a/res/screen-density-xhigh/00_list_expand_closed.png b/res/screen-density-xhigh/00_list_expand_closed.png new file mode 100644 index 0000000..a3f639e Binary files /dev/null and b/res/screen-density-xhigh/00_list_expand_closed.png differ diff --git a/res/screen-density-xhigh/00_list_expand_closed_press.png b/res/screen-density-xhigh/00_list_expand_closed_press.png new file mode 100644 index 0000000..b421ad1 Binary files /dev/null and b/res/screen-density-xhigh/00_list_expand_closed_press.png differ diff --git a/res/screen-density-xhigh/00_list_expand_opened.png b/res/screen-density-xhigh/00_list_expand_opened.png new file mode 100644 index 0000000..377dbc9 Binary files /dev/null and b/res/screen-density-xhigh/00_list_expand_opened.png differ diff --git a/res/screen-density-xhigh/00_list_expand_opened_press.png b/res/screen-density-xhigh/00_list_expand_opened_press.png new file mode 100644 index 0000000..1b49c94 Binary files /dev/null and b/res/screen-density-xhigh/00_list_expand_opened_press.png differ diff --git a/res/screen-density-xhigh/00_list_process_01.png b/res/screen-density-xhigh/00_list_process_01.png new file mode 100644 index 0000000..5c8fbb4 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_01.png differ diff --git a/res/screen-density-xhigh/00_list_process_02.png b/res/screen-density-xhigh/00_list_process_02.png new file mode 100644 index 0000000..eeec62e Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_02.png differ diff --git a/res/screen-density-xhigh/00_list_process_03.png b/res/screen-density-xhigh/00_list_process_03.png new file mode 100644 index 0000000..45f82b9 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_03.png differ diff --git a/res/screen-density-xhigh/00_list_process_04.png b/res/screen-density-xhigh/00_list_process_04.png new file mode 100644 index 0000000..251e3ba Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_04.png differ diff --git a/res/screen-density-xhigh/00_list_process_05.png b/res/screen-density-xhigh/00_list_process_05.png new file mode 100644 index 0000000..e278217 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_05.png differ diff --git a/res/screen-density-xhigh/00_list_process_06.png b/res/screen-density-xhigh/00_list_process_06.png new file mode 100644 index 0000000..1e47db8 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_06.png differ diff --git a/res/screen-density-xhigh/00_list_process_07.png b/res/screen-density-xhigh/00_list_process_07.png new file mode 100644 index 0000000..18d5db9 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_07.png differ diff --git a/res/screen-density-xhigh/00_list_process_08.png b/res/screen-density-xhigh/00_list_process_08.png new file mode 100644 index 0000000..0cabf18 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_08.png differ diff --git a/res/screen-density-xhigh/00_list_process_09.png b/res/screen-density-xhigh/00_list_process_09.png new file mode 100644 index 0000000..94bba2b Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_09.png differ diff --git a/res/screen-density-xhigh/00_list_process_10.png b/res/screen-density-xhigh/00_list_process_10.png new file mode 100644 index 0000000..2e5b2b7 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_10.png differ diff --git a/res/screen-density-xhigh/00_list_process_11.png b/res/screen-density-xhigh/00_list_process_11.png new file mode 100644 index 0000000..264e6b5 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_11.png differ diff --git a/res/screen-density-xhigh/00_list_process_12.png b/res/screen-density-xhigh/00_list_process_12.png new file mode 100644 index 0000000..c49841e Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_12.png differ diff --git a/res/screen-density-xhigh/00_list_process_13.png b/res/screen-density-xhigh/00_list_process_13.png new file mode 100644 index 0000000..cdec394 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_13.png differ diff --git a/res/screen-density-xhigh/00_list_process_14.png b/res/screen-density-xhigh/00_list_process_14.png new file mode 100644 index 0000000..aeb2852 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_14.png differ diff --git a/res/screen-density-xhigh/00_list_process_15.png b/res/screen-density-xhigh/00_list_process_15.png new file mode 100644 index 0000000..b37ee4a Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_15.png differ diff --git a/res/screen-density-xhigh/00_list_process_16.png b/res/screen-density-xhigh/00_list_process_16.png new file mode 100644 index 0000000..5bb072b Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_16.png differ diff --git a/res/screen-density-xhigh/00_list_process_17.png b/res/screen-density-xhigh/00_list_process_17.png new file mode 100644 index 0000000..b7e6eb6 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_17.png differ diff --git a/res/screen-density-xhigh/00_list_process_18.png b/res/screen-density-xhigh/00_list_process_18.png new file mode 100644 index 0000000..e5ce36b Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_18.png differ diff --git a/res/screen-density-xhigh/00_list_process_19.png b/res/screen-density-xhigh/00_list_process_19.png new file mode 100644 index 0000000..40b4e7d Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_19.png differ diff --git a/res/screen-density-xhigh/00_list_process_20.png b/res/screen-density-xhigh/00_list_process_20.png new file mode 100644 index 0000000..b50abde Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_20.png differ diff --git a/res/screen-density-xhigh/00_list_process_21.png b/res/screen-density-xhigh/00_list_process_21.png new file mode 100644 index 0000000..e7cc057 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_21.png differ diff --git a/res/screen-density-xhigh/00_list_process_22.png b/res/screen-density-xhigh/00_list_process_22.png new file mode 100644 index 0000000..35e93e3 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_22.png differ diff --git a/res/screen-density-xhigh/00_list_process_23.png b/res/screen-density-xhigh/00_list_process_23.png new file mode 100644 index 0000000..50990db Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_23.png differ diff --git a/res/screen-density-xhigh/00_list_process_24.png b/res/screen-density-xhigh/00_list_process_24.png new file mode 100644 index 0000000..3dfea10 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_24.png differ diff --git a/res/screen-density-xhigh/00_list_process_25.png b/res/screen-density-xhigh/00_list_process_25.png new file mode 100644 index 0000000..4878a78 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_25.png differ diff --git a/res/screen-density-xhigh/00_list_process_26.png b/res/screen-density-xhigh/00_list_process_26.png new file mode 100644 index 0000000..b57750f Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_26.png differ diff --git a/res/screen-density-xhigh/00_list_process_27.png b/res/screen-density-xhigh/00_list_process_27.png new file mode 100644 index 0000000..c8cee33 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_27.png differ diff --git a/res/screen-density-xhigh/00_list_process_28.png b/res/screen-density-xhigh/00_list_process_28.png new file mode 100644 index 0000000..db51809 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_28.png differ diff --git a/res/screen-density-xhigh/00_list_process_29.png b/res/screen-density-xhigh/00_list_process_29.png new file mode 100644 index 0000000..2fb304e Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_29.png differ diff --git a/res/screen-density-xhigh/00_list_process_30.png b/res/screen-density-xhigh/00_list_process_30.png new file mode 100644 index 0000000..9868089 Binary files /dev/null and b/res/screen-density-xhigh/00_list_process_30.png differ diff --git a/res/screen-density-xhigh/00_popup_bg_ef.9.png b/res/screen-density-xhigh/00_popup_bg_ef.9.png new file mode 100644 index 0000000..f19a0ab Binary files /dev/null and b/res/screen-density-xhigh/00_popup_bg_ef.9.png differ diff --git a/res/screen-density-xhigh/00_popup_bubble_tail_bottom.png b/res/screen-density-xhigh/00_popup_bubble_tail_bottom.png new file mode 100644 index 0000000..85ad926 Binary files /dev/null and b/res/screen-density-xhigh/00_popup_bubble_tail_bottom.png differ diff --git a/res/screen-density-xhigh/00_popup_bubble_tail_top.png b/res/screen-density-xhigh/00_popup_bubble_tail_top.png new file mode 100644 index 0000000..f7db3a2 Binary files /dev/null and b/res/screen-density-xhigh/00_popup_bubble_tail_top.png differ diff --git a/res/screen-density-xhigh/00_reorder_group_list_bg.png b/res/screen-density-xhigh/00_reorder_group_list_bg.png new file mode 100644 index 0000000..9e57e51 Binary files /dev/null and b/res/screen-density-xhigh/00_reorder_group_list_bg.png differ diff --git a/res/screen-density-xhigh/00_volume_icon_Mute.png b/res/screen-density-xhigh/00_volume_icon_Mute.png new file mode 100644 index 0000000..bb970b9 Binary files /dev/null and b/res/screen-density-xhigh/00_volume_icon_Mute.png differ diff --git a/res/screen-density-xhigh/00_winset_Back.png b/res/screen-density-xhigh/00_winset_Back.png new file mode 100644 index 0000000..6db2192 Binary files /dev/null and b/res/screen-density-xhigh/00_winset_Back.png differ diff --git a/res/screen-density-xhigh/00_winset_more.png b/res/screen-density-xhigh/00_winset_more.png new file mode 100644 index 0000000..473d5aa Binary files /dev/null and b/res/screen-density-xhigh/00_winset_more.png differ diff --git a/res/screen-density-xhigh/00_winset_more_press.png b/res/screen-density-xhigh/00_winset_more_press.png new file mode 100644 index 0000000..cc82721 Binary files /dev/null and b/res/screen-density-xhigh/00_winset_more_press.png differ diff --git a/res/screen-density-xhigh/C01-1_Back_btn_normal.png b/res/screen-density-xhigh/C01-1_Back_btn_normal.png new file mode 100644 index 0000000..a744418 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Back_btn_normal.png differ diff --git a/res/screen-density-xhigh/C01-1_Back_btn_press.png b/res/screen-density-xhigh/C01-1_Back_btn_press.png new file mode 100644 index 0000000..1f4867e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Back_btn_press.png differ diff --git a/res/screen-density-xhigh/C01-1_Not saved contact BG.png b/res/screen-density-xhigh/C01-1_Not saved contact BG.png new file mode 100644 index 0000000..b37b3ab Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Not saved contact BG.png differ diff --git a/res/screen-density-xhigh/C01-1_Reject_message_arrow_01.png b/res/screen-density-xhigh/C01-1_Reject_message_arrow_01.png new file mode 100644 index 0000000..cc15502 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Reject_message_arrow_01.png differ diff --git a/res/screen-density-xhigh/C01-1_Reject_message_arrow_02.png b/res/screen-density-xhigh/C01-1_Reject_message_arrow_02.png new file mode 100644 index 0000000..420b608 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Reject_message_arrow_02.png differ diff --git a/res/screen-density-xhigh/C01-1_Reject_message_bg.png b/res/screen-density-xhigh/C01-1_Reject_message_bg.png new file mode 100644 index 0000000..4142cbc Binary files /dev/null and b/res/screen-density-xhigh/C01-1_Reject_message_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_accept_left.png b/res/screen-density-xhigh/C01-1_accept_left.png new file mode 100644 index 0000000..120cd0e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_accept_left.png differ diff --git a/res/screen-density-xhigh/C01-1_accept_left_dial_answer.png b/res/screen-density-xhigh/C01-1_accept_left_dial_answer.png new file mode 100644 index 0000000..d170fb5 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_accept_left_dial_answer.png differ diff --git a/res/screen-density-xhigh/C01-1_accept_left_dial_answer_dim.png b/res/screen-density-xhigh/C01-1_accept_left_dial_answer_dim.png new file mode 100644 index 0000000..dc6ace3 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_accept_left_dial_answer_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_accept_left_dim.png b/res/screen-density-xhigh/C01-1_accept_left_dim.png new file mode 100644 index 0000000..cbd4a6a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_accept_left_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_animation_bg.png b/res/screen-density-xhigh/C01-1_animation_bg.png new file mode 100644 index 0000000..17df09a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_animation_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_arrow_g.png b/res/screen-density-xhigh/C01-1_arrow_g.png new file mode 100644 index 0000000..dc63e48 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_arrow_g.png differ diff --git a/res/screen-density-xhigh/C01-1_arrow_r.png b/res/screen-density-xhigh/C01-1_arrow_r.png new file mode 100644 index 0000000..bbda829 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_arrow_r.png differ diff --git a/res/screen-density-xhigh/C01-1_bg.png b/res/screen-density-xhigh/C01-1_bg.png new file mode 100644 index 0000000..0f9b480 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_btn_back.png b/res/screen-density-xhigh/C01-1_btn_back.png new file mode 100644 index 0000000..d708747 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_btn_back.png differ diff --git a/res/screen-density-xhigh/C01-1_btn_create.png b/res/screen-density-xhigh/C01-1_btn_create.png new file mode 100644 index 0000000..aa8e122 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_btn_create.png differ diff --git a/res/screen-density-xhigh/C01-1_button_01_press.png b/res/screen-density-xhigh/C01-1_button_01_press.png new file mode 100644 index 0000000..af09cf1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_01_press.png differ diff --git a/res/screen-density-xhigh/C01-1_button_02_normal.png b/res/screen-density-xhigh/C01-1_button_02_normal.png new file mode 100644 index 0000000..7ad4694 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_02_normal.png differ diff --git a/res/screen-density-xhigh/C01-1_button_03_normal.png b/res/screen-density-xhigh/C01-1_button_03_normal.png new file mode 100644 index 0000000..2e6324e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_03_normal.png differ diff --git a/res/screen-density-xhigh/C01-1_button_05_press.png b/res/screen-density-xhigh/C01-1_button_05_press.png new file mode 100644 index 0000000..b68bd66 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_05_press.png differ diff --git a/res/screen-density-xhigh/C01-1_button_bg.png b/res/screen-density-xhigh/C01-1_button_bg.png new file mode 100644 index 0000000..7fda33e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_button_call.png b/res/screen-density-xhigh/C01-1_button_call.png new file mode 100644 index 0000000..f7a914b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_call.png differ diff --git a/res/screen-density-xhigh/C01-1_button_call_press.png b/res/screen-density-xhigh/C01-1_button_call_press.png new file mode 100644 index 0000000..d580d24 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_call_press.png differ diff --git a/res/screen-density-xhigh/C01-1_button_end_call.png b/res/screen-density-xhigh/C01-1_button_end_call.png new file mode 100644 index 0000000..dbc2d30 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_end_call.png differ diff --git a/res/screen-density-xhigh/C01-1_button_hold_normal.png b/res/screen-density-xhigh/C01-1_button_hold_normal.png new file mode 100644 index 0000000..99641b9 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_hold_normal.png differ diff --git a/res/screen-density-xhigh/C01-1_button_hold_normal_01.png b/res/screen-density-xhigh/C01-1_button_hold_normal_01.png new file mode 100644 index 0000000..c95ea48 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_hold_normal_01.png differ diff --git a/res/screen-density-xhigh/C01-1_button_hold_normal_01_press.png b/res/screen-density-xhigh/C01-1_button_hold_normal_01_press.png new file mode 100644 index 0000000..c0250f6 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_hold_normal_01_press.png differ diff --git a/res/screen-density-xhigh/C01-1_button_hold_press.png b/res/screen-density-xhigh/C01-1_button_hold_press.png new file mode 100644 index 0000000..5a7c9c2 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_hold_press.png differ diff --git a/res/screen-density-xhigh/C01-1_button_press.png b/res/screen-density-xhigh/C01-1_button_press.png new file mode 100644 index 0000000..de4c3f9 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_button_press.png differ diff --git a/res/screen-density-xhigh/C01-1_call_ID_thumbnail_366x366.png b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_366x366.png new file mode 100644 index 0000000..a85028b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_366x366.png differ diff --git a/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_224x224.png b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_224x224.png new file mode 100644 index 0000000..905d9ef Binary files /dev/null and b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_224x224.png differ diff --git a/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_388x388.png b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_388x388.png new file mode 100644 index 0000000..cb114f0 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_call_ID_thumbnail_shadow_388x388.png differ diff --git a/res/screen-density-xhigh/C01-1_call_bg.png b/res/screen-density-xhigh/C01-1_call_bg.png new file mode 100644 index 0000000..03d161d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_call_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_call_bg02.png b/res/screen-density-xhigh/C01-1_call_bg02.png new file mode 100644 index 0000000..c09bc54 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_call_bg02.png differ diff --git a/res/screen-density-xhigh/C01-1_caller_bg.png b/res/screen-density-xhigh/C01-1_caller_bg.png new file mode 100644 index 0000000..e3fbee9 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_caller_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_calling_BG_01.png b/res/screen-density-xhigh/C01-1_calling_BG_01.png new file mode 100644 index 0000000..c487a43 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_calling_BG_01.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_call_btn_01.png b/res/screen-density-xhigh/C01-1_conference_call_btn_01.png new file mode 100644 index 0000000..b50ddf0 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_call_btn_01.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_call_btn_01_press.png b/res/screen-density-xhigh/C01-1_conference_call_btn_01_press.png new file mode 100644 index 0000000..10a73a5 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_call_btn_01_press.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_call_btn_02.png b/res/screen-density-xhigh/C01-1_conference_call_btn_02.png new file mode 100644 index 0000000..3f82018 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_call_btn_02.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_call_btn_02_press.png b/res/screen-density-xhigh/C01-1_conference_call_btn_02_press.png new file mode 100644 index 0000000..10a73a5 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_call_btn_02_press.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_end.png b/res/screen-density-xhigh/C01-1_conference_end.png new file mode 100644 index 0000000..f1103b7 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_end.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_end_press.png b/res/screen-density-xhigh/C01-1_conference_end_press.png new file mode 100644 index 0000000..ee17589 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_end_press.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_split.png b/res/screen-density-xhigh/C01-1_conference_split.png new file mode 100644 index 0000000..74cfc0b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_split.png differ diff --git a/res/screen-density-xhigh/C01-1_conference_split_press.png b/res/screen-density-xhigh/C01-1_conference_split_press.png new file mode 100644 index 0000000..ec1ceeb Binary files /dev/null and b/res/screen-density-xhigh/C01-1_conference_split_press.png differ diff --git a/res/screen-density-xhigh/C01-1_contact_btn.png b/res/screen-density-xhigh/C01-1_contact_btn.png new file mode 100644 index 0000000..19b1199 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_contact_btn.png differ diff --git a/res/screen-density-xhigh/C01-1_contact_btn_press.png b/res/screen-density-xhigh/C01-1_contact_btn_press.png new file mode 100644 index 0000000..629c5b7 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_contact_btn_press.png differ diff --git a/res/screen-density-xhigh/C01-1_end call_default_caller ID_366x366.png b/res/screen-density-xhigh/C01-1_end call_default_caller ID_366x366.png new file mode 100644 index 0000000..1ffd35b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_end call_default_caller ID_366x366.png differ diff --git a/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x370.png b/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x370.png new file mode 100644 index 0000000..1d6df58 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x370.png differ diff --git a/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x720.png b/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x720.png new file mode 100644 index 0000000..085c057 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_end call_default_caller ID_720x720.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Hide.png b/res/screen-density-xhigh/C01-1_icon_Hide.png new file mode 100644 index 0000000..88d3fa1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Hide.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Hide_dim.png b/res/screen-density-xhigh/C01-1_icon_Hide_dim.png new file mode 100644 index 0000000..03f7db6 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Hide_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Hide_press.png b/res/screen-density-xhigh/C01-1_icon_Hide_press.png new file mode 100644 index 0000000..ced239c Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Hide_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Hide_press_wh.png b/res/screen-density-xhigh/C01-1_icon_Hide_press_wh.png new file mode 100644 index 0000000..ca158c4 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Hide_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Pause.png b/res/screen-density-xhigh/C01-1_icon_Pause.png new file mode 100644 index 0000000..2134376 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Pause.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Play.png b/res/screen-density-xhigh/C01-1_icon_Play.png new file mode 100644 index 0000000..c59be52 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Play.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_REC_78x78.png b/res/screen-density-xhigh/C01-1_icon_REC_78x78.png new file mode 100644 index 0000000..b187c25 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_REC_78x78.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_Reject_with_Message.png b/res/screen-density-xhigh/C01-1_icon_Reject_with_Message.png new file mode 100644 index 0000000..24759b0 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_Reject_with_Message.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_add.png b/res/screen-density-xhigh/C01-1_icon_add.png new file mode 100644 index 0000000..ff5ad9a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_add.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_add_dim.png b/res/screen-density-xhigh/C01-1_icon_add_dim.png new file mode 100644 index 0000000..39791fa Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_add_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_add_press.png b/res/screen-density-xhigh/C01-1_icon_add_press.png new file mode 100644 index 0000000..3e6f27d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_add_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_add_press_wh.png b/res/screen-density-xhigh/C01-1_icon_add_press_wh.png new file mode 100644 index 0000000..c07e615 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_add_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_button_press.png b/res/screen-density-xhigh/C01-1_icon_button_press.png new file mode 100644 index 0000000..35d77b5 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_button_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_call.png b/res/screen-density-xhigh/C01-1_icon_call.png new file mode 100644 index 0000000..8414ffa Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_call.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_call_press.png b/res/screen-density-xhigh/C01-1_icon_call_press.png new file mode 100644 index 0000000..ca0f49c Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_call_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_contacts.png b/res/screen-density-xhigh/C01-1_icon_contacts.png new file mode 100644 index 0000000..3cf5856 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_contacts.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_contacts_dim.png b/res/screen-density-xhigh/C01-1_icon_contacts_dim.png new file mode 100644 index 0000000..56e771d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_contacts_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_contacts_press.png b/res/screen-density-xhigh/C01-1_icon_contacts_press.png new file mode 100644 index 0000000..4838c20 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_contacts_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_contacts_press_wh.png b/res/screen-density-xhigh/C01-1_icon_contacts_press_wh.png new file mode 100644 index 0000000..81913d4 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_contacts_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_end call.png b/res/screen-density-xhigh/C01-1_icon_end call.png new file mode 100644 index 0000000..fb619d1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_end call.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_end call_dim.png b/res/screen-density-xhigh/C01-1_icon_end call_dim.png new file mode 100644 index 0000000..4df489b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_end call_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_end call_press.png b/res/screen-density-xhigh/C01-1_icon_end call_press.png new file mode 100644 index 0000000..8b5178c Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_end call_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_end call_press_wh.png b/res/screen-density-xhigh/C01-1_icon_end call_press_wh.png new file mode 100644 index 0000000..c3d97a1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_end call_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_headset.png b/res/screen-density-xhigh/C01-1_icon_headset.png new file mode 100644 index 0000000..e604393 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_headset.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_headset_dim.png b/res/screen-density-xhigh/C01-1_icon_headset_dim.png new file mode 100644 index 0000000..dc00a7b Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_headset_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_headset_press.png b/res/screen-density-xhigh/C01-1_icon_headset_press.png new file mode 100644 index 0000000..0020f42 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_headset_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_headset_press_wh.png b/res/screen-density-xhigh/C01-1_icon_headset_press_wh.png new file mode 100644 index 0000000..2e5e588 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_headset_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold.png b/res/screen-density-xhigh/C01-1_icon_hold.png new file mode 100644 index 0000000..ff00328 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold_78x78.png b/res/screen-density-xhigh/C01-1_icon_hold_78x78.png new file mode 100644 index 0000000..2c1beab Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold_78x78.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold_78x78_press.png b/res/screen-density-xhigh/C01-1_icon_hold_78x78_press.png new file mode 100644 index 0000000..91078ac Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold_78x78_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold_dim.png b/res/screen-density-xhigh/C01-1_icon_hold_dim.png new file mode 100644 index 0000000..5d4731f Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold_press.png b/res/screen-density-xhigh/C01-1_icon_hold_press.png new file mode 100644 index 0000000..133dee7 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_hold_press_wh.png b/res/screen-density-xhigh/C01-1_icon_hold_press_wh.png new file mode 100644 index 0000000..3e78d46 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_hold_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_join.png b/res/screen-density-xhigh/C01-1_icon_join.png new file mode 100644 index 0000000..c9205df Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_join.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_join_dim.png b/res/screen-density-xhigh/C01-1_icon_join_dim.png new file mode 100644 index 0000000..45d2164 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_join_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_join_press.png b/res/screen-density-xhigh/C01-1_icon_join_press.png new file mode 100644 index 0000000..16af3a1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_join_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_join_press_wh.png b/res/screen-density-xhigh/C01-1_icon_join_press_wh.png new file mode 100644 index 0000000..4fc3ccd Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_join_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_keypad.png b/res/screen-density-xhigh/C01-1_icon_keypad.png new file mode 100644 index 0000000..75ce6ef Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_keypad.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_keypad_dim.png b/res/screen-density-xhigh/C01-1_icon_keypad_dim.png new file mode 100644 index 0000000..279bb63 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_keypad_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_keypad_press.png b/res/screen-density-xhigh/C01-1_icon_keypad_press.png new file mode 100644 index 0000000..a947324 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_keypad_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_keypad_press_wh.png b/res/screen-density-xhigh/C01-1_icon_keypad_press_wh.png new file mode 100644 index 0000000..a551ced Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_keypad_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_message.png b/res/screen-density-xhigh/C01-1_icon_message.png new file mode 100644 index 0000000..9485b47 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_message.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_message_dim.png b/res/screen-density-xhigh/C01-1_icon_message_dim.png new file mode 100644 index 0000000..5a2e171 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_message_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_message_press.png b/res/screen-density-xhigh/C01-1_icon_message_press.png new file mode 100644 index 0000000..2c61d01 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_message_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_message_press_wh.png b/res/screen-density-xhigh/C01-1_icon_message_press_wh.png new file mode 100644 index 0000000..8d658a0 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_message_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_more.png b/res/screen-density-xhigh/C01-1_icon_more.png new file mode 100644 index 0000000..bc3170d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_more.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_more_Manage conference call.png b/res/screen-density-xhigh/C01-1_icon_more_Manage conference call.png new file mode 100644 index 0000000..df93ba4 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_more_Manage conference call.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_more_press.png b/res/screen-density-xhigh/C01-1_icon_more_press.png new file mode 100644 index 0000000..9e30260 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_more_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute.png b/res/screen-density-xhigh/C01-1_icon_mute.png new file mode 100644 index 0000000..0f7811c Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_dim.png b/res/screen-density-xhigh/C01-1_icon_mute_dim.png new file mode 100644 index 0000000..c2a28b7 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_on.png b/res/screen-density-xhigh/C01-1_icon_mute_on.png new file mode 100644 index 0000000..780fd1a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_on.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_on_dim.png b/res/screen-density-xhigh/C01-1_icon_mute_on_dim.png new file mode 100644 index 0000000..bdf810d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_on_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_on_press.png b/res/screen-density-xhigh/C01-1_icon_mute_on_press.png new file mode 100644 index 0000000..48c86a9 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_on_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_press.png b/res/screen-density-xhigh/C01-1_icon_mute_press.png new file mode 100644 index 0000000..7547c0a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_mute_press_wh.png b/res/screen-density-xhigh/C01-1_icon_mute_press_wh.png new file mode 100644 index 0000000..6e7f648 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_mute_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_record.png b/res/screen-density-xhigh/C01-1_icon_record.png new file mode 100644 index 0000000..da6b8e8 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_record.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_record_dim.png b/res/screen-density-xhigh/C01-1_icon_record_dim.png new file mode 100644 index 0000000..74bcb2c Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_record_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_record_press.png b/res/screen-density-xhigh/C01-1_icon_record_press.png new file mode 100644 index 0000000..dca1d50 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_record_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_record_press_wh.png b/res/screen-density-xhigh/C01-1_icon_record_press_wh.png new file mode 100644 index 0000000..ff231cf Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_record_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker.png b/res/screen-density-xhigh/C01-1_icon_speaker.png new file mode 100644 index 0000000..cda8b82 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_dim.png b/res/screen-density-xhigh/C01-1_icon_speaker_dim.png new file mode 100644 index 0000000..1c68a0e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_on.png b/res/screen-density-xhigh/C01-1_icon_speaker_on.png new file mode 100644 index 0000000..28b462e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_on.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_on_dim.png b/res/screen-density-xhigh/C01-1_icon_speaker_on_dim.png new file mode 100644 index 0000000..089dc17 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_on_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_on_press.png b/res/screen-density-xhigh/C01-1_icon_speaker_on_press.png new file mode 100644 index 0000000..e32c033 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_on_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_press.png b/res/screen-density-xhigh/C01-1_icon_speaker_press.png new file mode 100644 index 0000000..46a0c9e Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_speaker_press_wh.png b/res/screen-density-xhigh/C01-1_icon_speaker_press_wh.png new file mode 100644 index 0000000..460944d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_speaker_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_stop.png b/res/screen-density-xhigh/C01-1_icon_stop.png new file mode 100644 index 0000000..6ce0b4a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_stop.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_stop_dim.png b/res/screen-density-xhigh/C01-1_icon_stop_dim.png new file mode 100644 index 0000000..1bfe8d5 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_stop_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_stop_press.png b/res/screen-density-xhigh/C01-1_icon_stop_press.png new file mode 100644 index 0000000..2e9cf56 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_stop_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_stop_press_wh.png b/res/screen-density-xhigh/C01-1_icon_stop_press_wh.png new file mode 100644 index 0000000..5032036 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_stop_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_swap.png b/res/screen-density-xhigh/C01-1_icon_swap.png new file mode 100644 index 0000000..12c0d8d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_swap.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_swap_press.png b/res/screen-density-xhigh/C01-1_icon_swap_press.png new file mode 100644 index 0000000..78a7510 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_swap_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold.png b/res/screen-density-xhigh/C01-1_icon_unhold.png new file mode 100644 index 0000000..8d28fa4 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold_78x78.png b/res/screen-density-xhigh/C01-1_icon_unhold_78x78.png new file mode 100644 index 0000000..95e21aa Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold_78x78.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold_78x78_press.png b/res/screen-density-xhigh/C01-1_icon_unhold_78x78_press.png new file mode 100644 index 0000000..158762f Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold_78x78_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold_dim.png b/res/screen-density-xhigh/C01-1_icon_unhold_dim.png new file mode 100644 index 0000000..4d68eac Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold_press.png b/res/screen-density-xhigh/C01-1_icon_unhold_press.png new file mode 100644 index 0000000..c27b75a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_unhold_press_wh.png b/res/screen-density-xhigh/C01-1_icon_unhold_press_wh.png new file mode 100644 index 0000000..7703fe3 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_unhold_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_video call.png b/res/screen-density-xhigh/C01-1_icon_video call.png new file mode 100644 index 0000000..a6ba953 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_video call.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_video call_dim.png b/res/screen-density-xhigh/C01-1_icon_video call_dim.png new file mode 100644 index 0000000..26bac38 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_video call_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_video call_press.png b/res/screen-density-xhigh/C01-1_icon_video call_press.png new file mode 100644 index 0000000..e1438b0 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_video call_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_video call_press_wh.png b/res/screen-density-xhigh/C01-1_icon_video call_press_wh.png new file mode 100644 index 0000000..2b58ccc Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_video call_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_voice call.png b/res/screen-density-xhigh/C01-1_icon_voice call.png new file mode 100644 index 0000000..70a166f Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_voice call.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_voice call_dim.png b/res/screen-density-xhigh/C01-1_icon_voice call_dim.png new file mode 100644 index 0000000..1432f1a Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_voice call_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_voice call_press.png b/res/screen-density-xhigh/C01-1_icon_voice call_press.png new file mode 100644 index 0000000..0c8456d Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_voice call_press.png differ diff --git a/res/screen-density-xhigh/C01-1_icon_voice call_press_wh.png b/res/screen-density-xhigh/C01-1_icon_voice call_press_wh.png new file mode 100644 index 0000000..f7796fd Binary files /dev/null and b/res/screen-density-xhigh/C01-1_icon_voice call_press_wh.png differ diff --git a/res/screen-density-xhigh/C01-1_keypad_btn_icon.png b/res/screen-density-xhigh/C01-1_keypad_btn_icon.png new file mode 100644 index 0000000..3601e35 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_keypad_btn_icon.png differ diff --git a/res/screen-density-xhigh/C01-1_keypad_btn_normal.png b/res/screen-density-xhigh/C01-1_keypad_btn_normal.png new file mode 100644 index 0000000..8dade07 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_keypad_btn_normal.png differ diff --git a/res/screen-density-xhigh/C01-1_keypad_btn_press.png b/res/screen-density-xhigh/C01-1_keypad_btn_press.png new file mode 100644 index 0000000..7c05577 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_keypad_btn_press.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_accept.png b/res/screen-density-xhigh/C01-1_lock_icon_accept.png new file mode 100644 index 0000000..18816ee Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_accept.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow.png b/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow.png new file mode 100644 index 0000000..ad2b227 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow_press.png b/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow_press.png new file mode 100644 index 0000000..29772b1 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_accept_arrow_press.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_accept_press.png b/res/screen-density-xhigh/C01-1_lock_icon_accept_press.png new file mode 100644 index 0000000..09d4d15 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_accept_press.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_reject.png b/res/screen-density-xhigh/C01-1_lock_icon_reject.png new file mode 100644 index 0000000..de951cc Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_reject.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow.png b/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow.png new file mode 100644 index 0000000..a003c38 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow_press.png b/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow_press.png new file mode 100644 index 0000000..d1c03e2 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_reject_arrow_press.png differ diff --git a/res/screen-density-xhigh/C01-1_lock_icon_reject_press.png b/res/screen-density-xhigh/C01-1_lock_icon_reject_press.png new file mode 100644 index 0000000..cc3cb42 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_lock_icon_reject_press.png differ diff --git a/res/screen-density-xhigh/C01-1_multil_default_caller ID_366x366.png b/res/screen-density-xhigh/C01-1_multil_default_caller ID_366x366.png new file mode 100644 index 0000000..3339901 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_multil_default_caller ID_366x366.png differ diff --git a/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x370.png b/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x370.png new file mode 100644 index 0000000..c638417 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x370.png differ diff --git a/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x720.png b/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x720.png new file mode 100644 index 0000000..f13ec55 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_multil_default_caller ID_720x720.png differ diff --git a/res/screen-density-xhigh/C01-1_outgoingcall_No caller ID.png b/res/screen-density-xhigh/C01-1_outgoingcall_No caller ID.png new file mode 100644 index 0000000..57c5d57 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_outgoingcall_No caller ID.png differ diff --git a/res/screen-density-xhigh/C01-1_popup_arrow.png b/res/screen-density-xhigh/C01-1_popup_arrow.png new file mode 100644 index 0000000..74cd5e2 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_popup_arrow.png differ diff --git a/res/screen-density-xhigh/C01-1_popup_bg.png b/res/screen-density-xhigh/C01-1_popup_bg.png new file mode 100644 index 0000000..78c64f2 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_popup_bg.png differ diff --git a/res/screen-density-xhigh/C01-1_reject_right.png b/res/screen-density-xhigh/C01-1_reject_right.png new file mode 100644 index 0000000..8494371 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_reject_right.png differ diff --git a/res/screen-density-xhigh/C01-1_reject_right_dial_decline.png b/res/screen-density-xhigh/C01-1_reject_right_dial_decline.png new file mode 100644 index 0000000..13aa50f Binary files /dev/null and b/res/screen-density-xhigh/C01-1_reject_right_dial_decline.png differ diff --git a/res/screen-density-xhigh/C01-1_reject_right_dial_decline_dim.png b/res/screen-density-xhigh/C01-1_reject_right_dial_decline_dim.png new file mode 100644 index 0000000..6a480da Binary files /dev/null and b/res/screen-density-xhigh/C01-1_reject_right_dial_decline_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_reject_right_dim.png b/res/screen-density-xhigh/C01-1_reject_right_dim.png new file mode 100644 index 0000000..6bdedea Binary files /dev/null and b/res/screen-density-xhigh/C01-1_reject_right_dim.png differ diff --git a/res/screen-density-xhigh/C01-1_voice_call_icon.png b/res/screen-density-xhigh/C01-1_voice_call_icon.png new file mode 100644 index 0000000..df2e9a8 Binary files /dev/null and b/res/screen-density-xhigh/C01-1_voice_call_icon.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.9.png new file mode 100644 index 0000000..598b82b Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.png new file mode 100644 index 0000000..87cc4fc Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_1line_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.9.png new file mode 100644 index 0000000..ab4018e Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.png new file mode 100644 index 0000000..b9f50ef Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_2line_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.9.png new file mode 100644 index 0000000..820ca77 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.png new file mode 100644 index 0000000..6198e88 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_3line_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.9.png new file mode 100644 index 0000000..c281a86 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.png new file mode 100644 index 0000000..3f5c80e Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_4line_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.9.png new file mode 100644 index 0000000..75e5b7c Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.png new file mode 100644 index 0000000..88801b3 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_5line_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.9.png new file mode 100644 index 0000000..38a69e6 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.png new file mode 100644 index 0000000..8d1fd3a Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_call_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.9.png new file mode 100644 index 0000000..795c513 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.png b/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.png new file mode 100644 index 0000000..a327add Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_option_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_option_press.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_option_press.9.png new file mode 100644 index 0000000..074d0a8 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_option_press.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_option_press.png b/res/screen-density-xhigh/C01-3_dialer_btn_option_press.png new file mode 100644 index 0000000..76cbd46 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_option_press.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_press.9.png b/res/screen-density-xhigh/C01-3_dialer_btn_press.9.png new file mode 100644 index 0000000..549481e Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_press.9.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_btn_press.png b/res/screen-density-xhigh/C01-3_dialer_btn_press.png new file mode 100644 index 0000000..6dc22bc Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_btn_press.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_icon_01.png b/res/screen-density-xhigh/C01-3_dialer_icon_01.png new file mode 100644 index 0000000..5753355 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_icon_01.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_icon_01_press.png b/res/screen-density-xhigh/C01-3_dialer_icon_01_press.png new file mode 100644 index 0000000..b79f2c6 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_icon_01_press.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_icon_clear.png b/res/screen-density-xhigh/C01-3_dialer_icon_clear.png new file mode 100644 index 0000000..719cde7 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_icon_clear.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_icon_star.png b/res/screen-density-xhigh/C01-3_dialer_icon_star.png new file mode 100644 index 0000000..d3893b4 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_icon_star.png differ diff --git a/res/screen-density-xhigh/C01-3_dialer_search_field_bg.png b/res/screen-density-xhigh/C01-3_dialer_search_field_bg.png new file mode 100644 index 0000000..c80a019 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_dialer_search_field_bg.png differ diff --git a/res/screen-density-xhigh/C01-3_icon_call.png b/res/screen-density-xhigh/C01-3_icon_call.png new file mode 100644 index 0000000..767fd97 Binary files /dev/null and b/res/screen-density-xhigh/C01-3_icon_call.png differ diff --git a/res/screen-density-xhigh/C01-3_icon_clear.png b/res/screen-density-xhigh/C01-3_icon_clear.png new file mode 100644 index 0000000..94fe6de Binary files /dev/null and b/res/screen-density-xhigh/C01-3_icon_clear.png differ diff --git a/res/screen-density-xhigh/C01-3_icon_message.png b/res/screen-density-xhigh/C01-3_icon_message.png new file mode 100644 index 0000000..e53f31a Binary files /dev/null and b/res/screen-density-xhigh/C01-3_icon_message.png differ diff --git a/res/screen-density-xhigh/C01-3_icon_voicecall.png b/res/screen-density-xhigh/C01-3_icon_voicecall.png new file mode 100644 index 0000000..4d1019f Binary files /dev/null and b/res/screen-density-xhigh/C01-3_icon_voicecall.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_call.png b/res/screen-density-xhigh/C01-4_btn_icon_call.png new file mode 100644 index 0000000..0b1038e Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_call.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_call_dim.png b/res/screen-density-xhigh/C01-4_btn_icon_call_dim.png new file mode 100644 index 0000000..d2a68f6 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_call_dim.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_message.png b/res/screen-density-xhigh/C01-4_btn_icon_message.png new file mode 100644 index 0000000..dd63da9 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_message.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_message_dim.png b/res/screen-density-xhigh/C01-4_btn_icon_message_dim.png new file mode 100644 index 0000000..485ff79 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_message_dim.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_video_call.png b/res/screen-density-xhigh/C01-4_btn_icon_video_call.png new file mode 100644 index 0000000..fe450c5 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_video_call.png differ diff --git a/res/screen-density-xhigh/C01-4_btn_icon_video_call_dim.png b/res/screen-density-xhigh/C01-4_btn_icon_video_call_dim.png new file mode 100644 index 0000000..29ce012 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_btn_icon_video_call_dim.png differ diff --git a/res/screen-density-xhigh/C01-4_controlbar_icon_cancel.png b/res/screen-density-xhigh/C01-4_controlbar_icon_cancel.png new file mode 100644 index 0000000..0960b62 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_controlbar_icon_cancel.png differ diff --git a/res/screen-density-xhigh/C01-4_controlbar_icon_delete.png b/res/screen-density-xhigh/C01-4_controlbar_icon_delete.png new file mode 100644 index 0000000..33a6bc7 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_controlbar_icon_delete.png differ diff --git a/res/screen-density-xhigh/C01-4_controlbar_icon_done.png b/res/screen-density-xhigh/C01-4_controlbar_icon_done.png new file mode 100644 index 0000000..c5ddbfe Binary files /dev/null and b/res/screen-density-xhigh/C01-4_controlbar_icon_done.png differ diff --git a/res/screen-density-xhigh/C01-4_controlbar_icon_save.png b/res/screen-density-xhigh/C01-4_controlbar_icon_save.png new file mode 100644 index 0000000..39baa6a Binary files /dev/null and b/res/screen-density-xhigh/C01-4_controlbar_icon_save.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_Blocked(Auto-rejected).png b/res/screen-density-xhigh/C01-4_icon_Blocked(Auto-rejected).png new file mode 100644 index 0000000..7f2cf70 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_Blocked(Auto-rejected).png differ diff --git a/res/screen-density-xhigh/C01-4_icon_Blocked.png b/res/screen-density-xhigh/C01-4_icon_Blocked.png new file mode 100644 index 0000000..a1cefa4 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_Blocked.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_call_blocked.png b/res/screen-density-xhigh/C01-4_icon_call_blocked.png new file mode 100644 index 0000000..b5bbe16 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_call_blocked.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_dialed.png b/res/screen-density-xhigh/C01-4_icon_dialed.png new file mode 100644 index 0000000..28c4c17 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_dialed.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_message_blocked.png b/res/screen-density-xhigh/C01-4_icon_message_blocked.png new file mode 100644 index 0000000..e665864 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_message_blocked.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_missed-call.png b/res/screen-density-xhigh/C01-4_icon_missed-call.png new file mode 100644 index 0000000..e778c32 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_missed-call.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_received.png b/res/screen-density-xhigh/C01-4_icon_received.png new file mode 100644 index 0000000..72c3b68 Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_received.png differ diff --git a/res/screen-density-xhigh/C01-4_icon_rejected.png b/res/screen-density-xhigh/C01-4_icon_rejected.png new file mode 100644 index 0000000..dcc739e Binary files /dev/null and b/res/screen-density-xhigh/C01-4_icon_rejected.png differ diff --git a/res/screen-density-xhigh/C01-5_icon_cancel.png b/res/screen-density-xhigh/C01-5_icon_cancel.png new file mode 100644 index 0000000..c6cb2de Binary files /dev/null and b/res/screen-density-xhigh/C01-5_icon_cancel.png differ diff --git a/res/screen-density-xhigh/C01-5_icon_speeddial_check.png b/res/screen-density-xhigh/C01-5_icon_speeddial_check.png new file mode 100644 index 0000000..df13f7e Binary files /dev/null and b/res/screen-density-xhigh/C01-5_icon_speeddial_check.png differ diff --git a/res/screen-density-xhigh/C01-5_icon_voicecall.png b/res/screen-density-xhigh/C01-5_icon_voicecall.png new file mode 100644 index 0000000..73f06db Binary files /dev/null and b/res/screen-density-xhigh/C01-5_icon_voicecall.png differ diff --git a/res/screen-density-xhigh/C01-5_speeddial_thumbnail_213x213.png b/res/screen-density-xhigh/C01-5_speeddial_thumbnail_213x213.png new file mode 100644 index 0000000..6d10770 Binary files /dev/null and b/res/screen-density-xhigh/C01-5_speeddial_thumbnail_213x213.png differ diff --git a/res/screen-density-xhigh/C01_3_dialer_icon_option.png b/res/screen-density-xhigh/C01_3_dialer_icon_option.png new file mode 100644 index 0000000..1d435fd Binary files /dev/null and b/res/screen-density-xhigh/C01_3_dialer_icon_option.png differ diff --git a/res/screen-density-xhigh/M01_contact_default_image.png b/res/screen-density-xhigh/M01_contact_default_image.png new file mode 100644 index 0000000..846a993 Binary files /dev/null and b/res/screen-density-xhigh/M01_contact_default_image.png differ diff --git a/res/screen-density-xhigh/M01_contact_default_image_press.png b/res/screen-density-xhigh/M01_contact_default_image_press.png new file mode 100644 index 0000000..a34bb4e Binary files /dev/null and b/res/screen-density-xhigh/M01_contact_default_image_press.png differ diff --git a/res/screen-density-xhigh/more.png b/res/screen-density-xhigh/more.png new file mode 100644 index 0000000..3110f55 Binary files /dev/null and b/res/screen-density-xhigh/more.png differ diff --git a/res/screen-density-xhigh/more_press.png b/res/screen-density-xhigh/more_press.png new file mode 100644 index 0000000..03a1c1d Binary files /dev/null and b/res/screen-density-xhigh/more_press.png differ diff --git a/res/screen-size-normal/IDL_CALL_FORM.xml b/res/screen-size-normal/IDL_CALL_FORM.xml new file mode 100644 index 0000000..ebf40e1 --- /dev/null +++ b/res/screen-size-normal/IDL_CALL_FORM.xml @@ -0,0 +1,59 @@ + + + + + + 720 +
+ + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_CALL_LOG_DETAIL_FORM.xml b/res/screen-size-normal/IDL_CALL_LOG_DETAIL_FORM.xml new file mode 100644 index 0000000..26be720 --- /dev/null +++ b/res/screen-size-normal/IDL_CALL_LOG_DETAIL_FORM.xml @@ -0,0 +1,63 @@ + + + + + + 720 +
+ + + + +
+ + +
+ + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_CALL_OPTION_POPUP.xml b/res/screen-size-normal/IDL_CALL_OPTION_POPUP.xml new file mode 100644 index 0000000..437aee0 --- /dev/null +++ b/res/screen-size-normal/IDL_CALL_OPTION_POPUP.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_CONFCALL_FORM.xml b/res/screen-size-normal/IDL_CONFCALL_FORM.xml new file mode 100644 index 0000000..b276259 --- /dev/null +++ b/res/screen-size-normal/IDL_CONFCALL_FORM.xml @@ -0,0 +1,64 @@ + + + + + + 720 +
+ + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_CONFCALL_LIST_FORM.xml b/res/screen-size-normal/IDL_CONFCALL_LIST_FORM.xml new file mode 100644 index 0000000..b197c33 --- /dev/null +++ b/res/screen-size-normal/IDL_CONFCALL_LIST_FORM.xml @@ -0,0 +1,169 @@ + + + + + + 720 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_DIALER_KEYPAD_PANEL.xml b/res/screen-size-normal/IDL_DIALER_KEYPAD_PANEL.xml new file mode 100644 index 0000000..939c42a --- /dev/null +++ b/res/screen-size-normal/IDL_DIALER_KEYPAD_PANEL.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_DIAL_FORM.xml b/res/screen-size-normal/IDL_DIAL_FORM.xml new file mode 100644 index 0000000..d72716e --- /dev/null +++ b/res/screen-size-normal/IDL_DIAL_FORM.xml @@ -0,0 +1,25 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + + + + +
+
diff --git a/res/screen-size-normal/IDL_DTMF_KEYPAD_PANEL.xml b/res/screen-size-normal/IDL_DTMF_KEYPAD_PANEL.xml new file mode 100644 index 0000000..effd686 --- /dev/null +++ b/res/screen-size-normal/IDL_DTMF_KEYPAD_PANEL.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_EMERGENCY_CALL_FORM.xml b/res/screen-size-normal/IDL_EMERGENCY_CALL_FORM.xml new file mode 100644 index 0000000..43e8648 --- /dev/null +++ b/res/screen-size-normal/IDL_EMERGENCY_CALL_FORM.xml @@ -0,0 +1,49 @@ + + + + + + 720 +
+ + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_EMERGENCY_DIAL_FORM.xml b/res/screen-size-normal/IDL_EMERGENCY_DIAL_FORM.xml new file mode 100644 index 0000000..cb75709 --- /dev/null +++ b/res/screen-size-normal/IDL_EMERGENCY_DIAL_FORM.xml @@ -0,0 +1,28 @@ + + + + + 720 +
+ + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_ENDCALLKEYS_PANEL.xml b/res/screen-size-normal/IDL_ENDCALLKEYS_PANEL.xml new file mode 100644 index 0000000..7c4ee62 --- /dev/null +++ b/res/screen-size-normal/IDL_ENDCALLKEYS_PANEL.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_END_CALL_FORM.xml b/res/screen-size-normal/IDL_END_CALL_FORM.xml new file mode 100644 index 0000000..653e6cf --- /dev/null +++ b/res/screen-size-normal/IDL_END_CALL_FORM.xml @@ -0,0 +1,49 @@ + + + + + + 720 +
+ + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_ERROR_MSG_POPUP.xml b/res/screen-size-normal/IDL_ERROR_MSG_POPUP.xml new file mode 100644 index 0000000..1549383 --- /dev/null +++ b/res/screen-size-normal/IDL_ERROR_MSG_POPUP.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_INCOMING_CALL_FORM.xml b/res/screen-size-normal/IDL_INCOMING_CALL_FORM.xml new file mode 100644 index 0000000..2147d82 --- /dev/null +++ b/res/screen-size-normal/IDL_INCOMING_CALL_FORM.xml @@ -0,0 +1,91 @@ + + + + + + 720 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_KEYS_PANEL.xml b/res/screen-size-normal/IDL_KEYS_PANEL.xml new file mode 100644 index 0000000..b79b8a3 --- /dev/null +++ b/res/screen-size-normal/IDL_KEYS_PANEL.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_MULTIPLE_CALL_FORM.xml b/res/screen-size-normal/IDL_MULTIPLE_CALL_FORM.xml new file mode 100644 index 0000000..e15fc9e --- /dev/null +++ b/res/screen-size-normal/IDL_MULTIPLE_CALL_FORM.xml @@ -0,0 +1,94 @@ + + + + + + 720 +
+ + + + + + + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_OUTCALL_FORM.xml b/res/screen-size-normal/IDL_OUTCALL_FORM.xml new file mode 100644 index 0000000..720c52d --- /dev/null +++ b/res/screen-size-normal/IDL_OUTCALL_FORM.xml @@ -0,0 +1,49 @@ + + + + + + 720 +
+ + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_OUT_EMERGENCYCALL_FORM.xml b/res/screen-size-normal/IDL_OUT_EMERGENCYCALL_FORM.xml new file mode 100644 index 0000000..e5051a9 --- /dev/null +++ b/res/screen-size-normal/IDL_OUT_EMERGENCYCALL_FORM.xml @@ -0,0 +1,49 @@ + + + + + + 720 +
+ + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_PANEL_CONTACTS.xml b/res/screen-size-normal/IDL_PANEL_CONTACTS.xml new file mode 100644 index 0000000..268377c --- /dev/null +++ b/res/screen-size-normal/IDL_PANEL_CONTACTS.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_PANEL_DIALER.xml b/res/screen-size-normal/IDL_PANEL_DIALER.xml new file mode 100644 index 0000000..636f5fa --- /dev/null +++ b/res/screen-size-normal/IDL_PANEL_DIALER.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_PANEL_FAVORITES.xml b/res/screen-size-normal/IDL_PANEL_FAVORITES.xml new file mode 100644 index 0000000..7669851 --- /dev/null +++ b/res/screen-size-normal/IDL_PANEL_FAVORITES.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_PANEL_LOGS.xml b/res/screen-size-normal/IDL_PANEL_LOGS.xml new file mode 100644 index 0000000..830f6f8 --- /dev/null +++ b/res/screen-size-normal/IDL_PANEL_LOGS.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/res/screen-size-normal/IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM.xml new file mode 100644 index 0000000..c2aac94 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM.xml @@ -0,0 +1,22 @@ + + + + + 720 +
+ + + + +
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_ADD_NUMBER_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_ADD_NUMBER_FORM.xml new file mode 100644 index 0000000..1a1d078 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_ADD_NUMBER_FORM.xml @@ -0,0 +1,48 @@ + + + + + + 720 +
+ + + + +
+ + +
+ + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_AUTO_AREA_CODE_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_AUTO_AREA_CODE_FORM.xml new file mode 100644 index 0000000..82f3b60 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_AUTO_AREA_CODE_FORM.xml @@ -0,0 +1,37 @@ + + + + + 720 +
+ + + + +
+ + +
+ + + + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM.xml new file mode 100644 index 0000000..23e569c --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_DELETE_LIST_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_DELETE_LIST_FORM.xml new file mode 100644 index 0000000..5f1e34c --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_DELETE_LIST_FORM.xml @@ -0,0 +1,32 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_FORWARDTO_NUMBER_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_FORWARDTO_NUMBER_FORM.xml new file mode 100644 index 0000000..e3d69e9 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_FORWARDTO_NUMBER_FORM.xml @@ -0,0 +1,47 @@ + + + + + 720 +
+ + + + +
+ + +
+ + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_MAINMENU_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_MAINMENU_FORM.xml new file mode 100644 index 0000000..354de64 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_MAINMENU_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_MOREOPTIONS_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_MOREOPTIONS_FORM.xml new file mode 100644 index 0000000..ebac1e1 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_MOREOPTIONS_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM.xml new file mode 100644 index 0000000..e585b37 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM.xml @@ -0,0 +1,52 @@ + + + + + 720 +
+ + + + +
+ + +
+ + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_REJECTLIST_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_REJECTLIST_FORM.xml new file mode 100644 index 0000000..afae8c3 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_REJECTLIST_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_REJECTMSGS_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_REJECTMSGS_FORM.xml new file mode 100644 index 0000000..4390d6a --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_REJECTMSGS_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_SET_BARRING_PWD__FORM.xml b/res/screen-size-normal/IDL_SETTINGS_SET_BARRING_PWD__FORM.xml new file mode 100644 index 0000000..4f03637 --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_SET_BARRING_PWD__FORM.xml @@ -0,0 +1,27 @@ + + + + + 720 +
+ + + + +
+ + +
+ + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_SPEEDDIAL_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_SPEEDDIAL_FORM.xml new file mode 100644 index 0000000..aa1990b --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_SPEEDDIAL_FORM.xml @@ -0,0 +1,426 @@ + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/res/screen-size-normal/IDL_SETTINGS_STATUS_TONES_FORM.xml b/res/screen-size-normal/IDL_SETTINGS_STATUS_TONES_FORM.xml new file mode 100644 index 0000000..feccc0a --- /dev/null +++ b/res/screen-size-normal/IDL_SETTINGS_STATUS_TONES_FORM.xml @@ -0,0 +1,27 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+ + + + + +
diff --git a/res/screen-size-normal/IDL_SPEED_DIAL_POPUP.xml b/res/screen-size-normal/IDL_SPEED_DIAL_POPUP.xml new file mode 100644 index 0000000..838e422 --- /dev/null +++ b/res/screen-size-normal/IDL_SPEED_DIAL_POPUP.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/shared/data/ringtone_sdk.mp3 b/shared/data/ringtone_sdk.mp3 new file mode 100644 index 0000000..f159e35 Binary files /dev/null and b/shared/data/ringtone_sdk.mp3 differ diff --git a/shared/res/screen-density-xhigh/mainmenu.png b/shared/res/screen-density-xhigh/mainmenu.png new file mode 100644 index 0000000..2b28ee4 Binary files /dev/null and b/shared/res/screen-density-xhigh/mainmenu.png differ diff --git a/shared/trusted/nofile.dummy b/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/src/PhnActiveCallForm.cpp b/src/PhnActiveCallForm.cpp new file mode 100644 index 0000000..a0f6a8c --- /dev/null +++ b/src/PhnActiveCallForm.cpp @@ -0,0 +1,1719 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnActiveCallForm.cpp + * @brief Active Call Form class + */ +#include +#include +#include +#include +#include "PhnActiveCallForm.h" +#include "PhnCallButtonsPanel.h" +#include "PhnCallInfo.h" +#include "PhnAppUtility.h" +#include "PhnDtmfKeypadPanel.h" +#include "PhnCallPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Social; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int IDI_MAX_SECONDS = 60; +const int IDI_MAX_MINS = 60; +const int W_HOLD_BITMAP = 78; +const int H_HOLD_BITMAP = 78; +//for Options menu list +const int IDI_POPUP_TEXT_SIZE = 33; +const unsigned int COLOR_POPUP_TEXT = Color32<255, 255, 255, 255>::Value; +const int IDI_MOREOPTIONS_LIST_ITEMS = 1; +const int W_OPTION_ANCHOR = 72; +const int H_OPTION_ANCHOR = 22; +const int W_MGR_CONFCALL_BITMAP = 64; +const int H_MGR_CONFCALL_BITMAP = 64; +const int X_DTMF_KEYPAD = 40; +const int IDI_YMARGIN_DTMF_KEYPAD = 26; +const int X_POPUP_ANCHOR = 632; +const int Y_POPUP_ANCHOR = 140; +const int W_POPUP_ANCHOR = 72; +const int H_POPUP_ANCHOR = 22; +const int IDI_OPTIONMENU_ITEM_SPACING = 16; +const Point IDI_OPTIONMENU_POS(238, 162); +const Dimension IDI_OPTIONMENU_DIMEN(466, 99); +const int X_PHOTO_LBL = 166; +const int Y_PHOTO_LBL = 232; +const int W_PHOTO_LBL = 388; +const int H_PHOTO_LBL = 388; +const int W_PHOTO_LABEL = 720; +const int H_PHOTO_LABEL = 720; + +static const wchar_t* IDC_CONF_CALL_MORE_BUTTON = L"IDC_CONF_CALL_MORE_BUTTON"; +static const wchar_t* IDC_HOLD_BUTTON = L"IDC_HOLD_BUTTON"; +static const wchar_t* IDC_SWAP_BUTTON = L"IDC_SWAP_BUTTON"; +static const wchar_t* IDC_HOLD_LABEL = L"IDC_HOLD_LABEL"; +static const wchar_t* IDC_TEXTBOX = L"IDC_TEXTBOX"; +static const wchar_t* IDC_LINE_LABEL = L"IDC_LINE_LABEL"; +static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL"; +static const wchar_t* IDC_BACKGROUND_LABEL = L"IDC_BACKGROUND_LABEL"; +static const wchar_t* IDC_CALLER1_TIME_LABEL = L"IDC_CALLER1_TIME_LABEL"; +static const wchar_t* IDC_NUMBER1_LABEL = L"IDC_NUMBER1_LABEL"; +static const wchar_t* IDC_VOICE_CALL_ICON_LABEL = L"IDC_VOICE_CALL_ICON_LABEL"; +static const wchar_t* IDC_CALLER2_LABEL = L"IDC_CALLER2_LABEL"; +static const wchar_t* IDC_NUMBER2_LABEL = L"IDC_NUMBER2_LABEL"; +static const wchar_t* IDC_CALLER2_TIME_LABEL = L"IDC_CALLER2_TIME_LABEL"; +static const wchar_t* IDC_SWAP_LABEL = L"IDC_SWAP_LABEL"; +static const wchar_t* IDC_BACKGROUND_LABEL2 = L"IDC_BACKGROUND_LABEL2"; +static const wchar_t* IDC_PARTICIPANTS_LABEL = L"IDC_PARTICIPANTS_LABEL"; +static const wchar_t* IDC_DIVIDER_LABEL = L"IDC_DIVIDER_LABEL"; +static const wchar_t* IDC_CALLER1_BIGPHOTO_LABEL = L"IDC_CALLER1_BIGPHOTO_LABEL"; +static const wchar_t* IDC_CALLER2_PHOTO_LABEL = L"IDC_CALLER2_PHOTO_LABEL"; +static const wchar_t* IDC_CALLER1_PHOTO_LABEL = L"IDC_CALLER1_PHOTO_LABEL"; + +ActiveCallForm::ActiveCallForm(FormType formType) + : BaseForm(formType) +{ + __pActiveCallTimer = null; + __pCallButtonsPanel = null; + __pDTMFKeypad = null; + __pMoreOptionsList = null; + __pMoreOptionsListAnchor = null; + __pSmallPhotoLabel = null; + __pActiveCallInfo = null; + __pHeldCallInfo = null; +} + +ActiveCallForm::~ActiveCallForm(void) +{ + if (__pActiveCallTimer != null) + { + __pActiveCallTimer->Cancel(); + delete __pActiveCallTimer; + } + if (__pMoreOptionsList != null) + { + RemoveControl(*__pMoreOptionsList); + __pMoreOptionsList = null; + } + if (__pMoreOptionsListAnchor != null) + { + RemoveControl(*__pMoreOptionsListAnchor); + __pMoreOptionsListAnchor = null; + } + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } + if (__pActiveCallInfo != null) + { + delete __pActiveCallInfo; + } + if (__pHeldCallInfo != null) + { + delete __pHeldCallInfo; + } + if(__pDTMFKeypad != null) + { + RemoveControl(*__pDTMFKeypad); + __pDTMFKeypad = null; + } +} + +void +ActiveCallForm::Initialize(void) +{ + switch (__formType) + { + case FORMTYPE_OUTGOINGCALL: + Construct(IDL_OUTCALL_FORM); + break; + + case FORMTYPE_EMERGENCYOUTGOINGCALL: + Construct(IDL_OUT_EMERGENCYCALL_FORM); + break; + + case FORMTYPE_ACTIVECALL: + Construct(IDL_CALL_FORM); + break; + + case FORMTYPE_EMERGENCYACTIVECALL: + Construct(IDL_EMERGENCY_CALL_FORM); + break; + + case FORMTYPE_MULTIPLECALLS: + Construct(IDL_MULTIPLE_CALL_FORM); + break; + + case FORMTYPE_ACTIVECONFCALL: + Construct(IDL_CONFCALL_FORM); + break; + + default: + break; + } + + //Initialize keypad and buttons + InitializeCallButtonsPanel(); + //Hold Button - Shown on single active/conf call scene + InitializeHoldButton(); + //Swap button for multiple call screen + InitializeSwapButton(); + //Initialize manage conf. call list form + InitializeManageConfCallButton(); +} + +result +ActiveCallForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + RelativeLayout* pRelativeLayout = dynamic_cast(GetParent()->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + pRelativeLayout = dynamic_cast(GetParent()->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + + __pCallPresentor = CallPresentationModel::GetInstance(); + + return r; +} + +void +ActiveCallForm::ShowDTMFKeypad(void) +{ + if(__pDTMFKeypad == null) + { + Rectangle rect(X_DTMF_KEYPAD, 0, 0, 0); + //update rect according to client screen area + rect.width = GetClientAreaBounds().width - (2 * X_DTMF_KEYPAD); + rect.height = GetClientAreaBounds().height - __pCallButtonsPanel->GetHeight() - IDI_YMARGIN_DTMF_KEYPAD; + __pDTMFKeypad = new (std::nothrow) DtmfKeyPadPanel(); + __pDTMFKeypad->Initialize(this, rect); + AddControl(*__pDTMFKeypad); + } + TextBox* pTextBox = static_cast(__pDTMFKeypad->GetControl(IDC_TEXTBOX)); + pTextBox->SetText(L""); + __pDTMFKeypad->SetShowState(true); + __pDTMFKeypad->Draw(true); + __pDTMFKeypad->Show(); +} + +void +ActiveCallForm::HideDTMFKeypad(void) +{ + if(__pDTMFKeypad != null) + { + __pDTMFKeypad->SetShowState(false); + } +} + +result +ActiveCallForm::InitializeCallButtonsPanel(void) +{ + __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel(); + __pCallButtonsPanel->ConstructPanel(this, __formType); + + result r = AddControl(*__pCallButtonsPanel); + return r; +} + +void +ActiveCallForm::InitializeSwapButton(void) +{ + Button* pSwapBtn = static_cast(GetControl(IDC_SWAP_BUTTON)); + if (pSwapBtn) + { + Bitmap* pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_NORMAL, + W_HOLD_BITMAP, H_HOLD_BITMAP); + if (pSwapBmp) + { + pSwapBtn->SetNormalBitmap(Point(0, 0), *pSwapBmp); + } + delete pSwapBmp; + pSwapBmp = null; + + pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_PRESS, + W_HOLD_BITMAP, H_HOLD_BITMAP); + if (pSwapBmp) + { + pSwapBtn->SetPressedBitmap(Point(0, 0), *pSwapBmp); + } + delete pSwapBmp; + pSwapBmp = null; + pSwapBtn->SetActionId(IDA_SWAP_CALLS); + pSwapBtn->AddActionEventListener(*this); + } +} + +void +ActiveCallForm::InitializeManageConfCallButton(void) +{ + Button* pMoreBtn = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + if (pMoreBtn != null) + { + pMoreBtn->SetActionId(IDA_MORE_OPTIONS_MENU); + pMoreBtn->AddActionEventListener(*this); + if (__formType == FORMTYPE_MULTIPLECALLS) + { + //Correct state will be set in OnSceneActivated based on the call + pMoreBtn->SetShowState(false); + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(false); + } + } + else if (__formType == FORMTYPE_ACTIVECONFCALL) + { + pMoreBtn->SetShowState(true); + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(true); + } + } + } +} + +void +ActiveCallForm::InitializeHoldButton(void) +{ + Button* pHoldBtn = static_cast(GetControl(IDC_HOLD_BUTTON)); + if (pHoldBtn != null) + { + //set status of Hold Button + SetHoldButtonStatus(true); + pHoldBtn->AddActionEventListener(*this); + } +} + +void +ActiveCallForm::SetHoldButtonStatus(bool toHoldCall) +{ + //background bitmap & button name + String btnName(""); + Bitmap* normalImg = null; + Bitmap* pressImg = null; + if (toHoldCall) + { + btnName.Append(AppUtility::GetResourceString(IDS_HOLD_BTN_NAME)); + normalImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_NORMAL_BUTTON_ICON, + W_HOLD_BITMAP, H_HOLD_BITMAP); + pressImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_PRESS_BUTTON_ICON, + W_HOLD_BITMAP, H_HOLD_BITMAP); + } + else + { + btnName.Append(AppUtility::GetResourceString(IDS_UNHOLD_BTN_NAME)); + normalImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_NORMAL_BUTTON_ICON, + W_HOLD_BITMAP, H_HOLD_BITMAP); + pressImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_PRESS_BUTTON_ICON, + W_HOLD_BITMAP, H_HOLD_BITMAP); + } + + //Action id + CommandIds cmdId = IDA_HOLD_CALL; + switch (__formType) + { + case FORMTYPE_ACTIVECALL: + { + cmdId = toHoldCall ? IDA_HOLD_CALL : IDA_UNHOLD_CALL; + } + break; + + case FORMTYPE_ACTIVECONFCALL: + { + cmdId = toHoldCall ? IDA_HOLD_CONF_CALL : IDA_UNHOLD_CONF_CALL; + } + break; + + default: + break; + } + + //set background bitmap, button name & action id + Button* pHoldBtn = static_cast(GetControl(IDC_HOLD_BUTTON)); + Label* pHoldLbl = static_cast(GetControl(IDC_HOLD_LABEL)); + if (pHoldBtn) + { + pHoldBtn->SetActionId(cmdId); + pHoldBtn->SetNormalBitmap(Point(0, 0),*normalImg); + pHoldBtn->SetPressedBitmap(Point(0, 0),*pressImg); + } + if (pHoldLbl) + { + pHoldLbl->SetText(btnName); + pHoldLbl->Invalidate(true); + } + + //free the resources + delete normalImg; + normalImg = null; + delete pressImg; + pressImg = null; +} + +void +ActiveCallForm::CreateMoreOptionsMenuList(void) +{ + //create option list anchor + if (__pMoreOptionsListAnchor == null) + { + Bitmap* pBgPopupArwBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_ARROW_ICON, W_OPTION_ANCHOR, + H_OPTION_ANCHOR); + __pMoreOptionsListAnchor = new (std::nothrow) Label(); + __pMoreOptionsListAnchor->Construct(Rectangle(X_POPUP_ANCHOR, Y_POPUP_ANCHOR, W_POPUP_ANCHOR, H_POPUP_ANCHOR), L""); + __pMoreOptionsListAnchor->SetBackgroundBitmap(*pBgPopupArwBmp); + + delete pBgPopupArwBmp; + pBgPopupArwBmp = null; + + // Adds a Label to the Form + AddControl(*__pMoreOptionsListAnchor); + } + + //create options menu list + if (__pMoreOptionsList == null) + { + __pMoreOptionsList = new (std::nothrow) ListView(); + __pMoreOptionsList->Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN), false, SCROLL_STYLE_FADE_OUT); + __pMoreOptionsList->SetItemProvider(*this); + __pMoreOptionsList->AddListViewItemEventListener(*this); + //Add option list to the form + AddControl(*__pMoreOptionsList); + } + else + { + //Hide option menu list + DestroyMoreOptionsMenuList(); + } +} + +void +ActiveCallForm::DestroyMoreOptionsMenuList(void) +{ + if (__pMoreOptionsListAnchor != null) + { + //removes and delete the child control + RemoveControl(*__pMoreOptionsListAnchor); + __pMoreOptionsListAnchor = null; + } + + if (__pMoreOptionsList != null) + { + //removes and delete the child control + RemoveControl(*__pMoreOptionsList); + __pMoreOptionsList = null; + } +} + +result +ActiveCallForm::OnTerminating(void) +{ + result r = E_SUCCESS; + if (__pCallPresentor != null) + { + __pCallPresentor = null; + } + return r; +} + +void +ActiveCallForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + + String dtmfString; + switch (actionId) + { + case IDA_END_CALL: + { + //End the currently active / dialing call + if (__pActiveCallInfo->IsConferenceCall() == false) + { + String activeContactNo; + activeContactNo.Append(__pActiveCallInfo->GetContactNumber()); + //In case of if its a hidden call + if(__pActiveCallInfo->GetContactNumber().IsEmpty() == true) + { + __pCallPresentor->EndCall(*__pActiveCallInfo->GetCallHandle()); + } + else + { + __pCallPresentor->EndCall(activeContactNo); + } + } + else + { + __pCallPresentor->EndConferenceCall(); + } + } + break; + + case IDA_END_CONF_CALL: + { + AppAssert(__formType == FORMTYPE_ACTIVECONFCALL); + __pCallPresentor->EndConferenceCall(); + } + break; + + case IDA_OPEN_NUMKEYPAD: + { + SetShowStateOnKeypad(false); + ShowDTMFKeypad(); + SetTextToDTMFTextField(L""); + __pCallButtonsPanel->SetKeypadButtonState(IDA_CLOSE_NUMKEYPAD); + } + break; + + case IDA_CLOSE_NUMKEYPAD: + { + SetShowStateOnKeypad(true); + HideDTMFKeypad(); + __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD); + } + break; + + case IDA_ADD_CALL: + { + //switch to Dialer Form to make an call + if(__pCallPresentor->GetCurrentCallCount() == 1) + { + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(); + String* formType = new (std::nothrow) String(); + formType->Append(__formType); + pArgs->Add(formType); + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY), pArgs); + } + } + break; + + case IDA_HOLD_CALL: + { + bool success = true; + if (__pActiveCallInfo->IsConferenceCall() == false) + { + if(__pActiveCallInfo->GetCallHandle() != null) + { + success = __pCallPresentor->HoldCall(*__pActiveCallInfo->GetCallHandle()); + } + } + else + { + success = __pCallPresentor->HoldConferenceCall(); + } + //reset hold status and "OnHold" text + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success); + if(__pActiveCallTimer != null) + { + __pActiveCallTimer->Cancel(); + } + SetHoldButtonStatus(!success); + } + break; + + case IDA_UNHOLD_CALL: + { + bool success = false; + if (__pActiveCallInfo->IsConferenceCall() == false) + { + if(__pActiveCallInfo->GetCallHandle() != null) + { + success = __pCallPresentor->UnHoldCall(*__pActiveCallInfo->GetCallHandle()); + } + } + else + { + success = __pCallPresentor->ActivateConferenceCall(); + } + //reset hold status and show call timer + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime); + SetHoldButtonStatus(success); + } + break; + + case IDA_HOLD_CONF_CALL: + { + AppAssert(__formType == FORMTYPE_ACTIVECONFCALL); + bool success = __pCallPresentor->HoldConferenceCall(); + //reset hold status and "OnHold" text + SetHoldButtonStatus(!success); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success); + if(__pActiveCallTimer != null) + { + __pActiveCallTimer->Cancel(); + } + } + break; + + case IDA_UNHOLD_CONF_CALL: + { + AppAssert(__formType == FORMTYPE_ACTIVECONFCALL); + bool success = __pCallPresentor->ActivateConferenceCall(); + //reset hold status and show call timer + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime); + SetHoldButtonStatus(success); + } + break; + + case IDA_OPEN_CONTACTS: + //Open Contacts APP + break; + + case IDA_MUTE: + { + bool success = __pCallPresentor->SetMuteStatus(true); + if (success) + { + __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE); + } + } + break; + + case IDA_UNMUTE: + { + bool success = __pCallPresentor->SetMuteStatus(false); + if (success) + { + __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE); + } + } + break; + + case IDA_SPEAKER: + { + bool success = __pCallPresentor->SetSpeakerStatus(true); + if (success) + { + __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF); + } + } + break; + + case IDA_SPEAKER_OFF: + { + bool success = __pCallPresentor->SetSpeakerStatus(false); + if (success) + { + __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER); + } + } + break; + + case IDA_JOIN_CALL: + { + AppAssert(__formType == FORMTYPE_MULTIPLECALLS); + __pCallPresentor->JoinCall(); + } + break; + + case IDA_SWAP_CALLS: + { + AppAssert(__formType == FORMTYPE_MULTIPLECALLS); + __pCallPresentor->SwapCalls(); + } + break; + + case IDA_MORE_OPTIONS_MENU: + { + //Show 'more' options menu + CreateMoreOptionsMenuList(); + } + break; + + case NUM_KEY0: + { + dtmfString.Append(L"0"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY1: + { + dtmfString.Append(L"1"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY2: + { + dtmfString.Append(L"2"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY3: + { + dtmfString.Append(L"3"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY4: + { + dtmfString.Append(L"4"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY5: + { + dtmfString.Append(L"5"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY6: + { + dtmfString.Append(L"6"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY7: + { + dtmfString.Append(L"7"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY8: + { + dtmfString.Append(L"8"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case NUM_KEY9: + { + dtmfString.Append(L"9"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case PAUSE_KEY: + { + dtmfString.Append(L"*"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + case HASH_KEY: + { + dtmfString.Append(L"#"); + SetTextToDTMFTextField(dtmfString); + __pCallPresentor->SendDTMFSignal(dtmfString); + } + break; + + default: + break; + } +} + +void +ActiveCallForm::SetTextToDTMFTextField(const String& dtmfStr) +{ + if(__pDTMFKeypad != null) + { + TextBox* pTextBox = static_cast(__pDTMFKeypad->GetControl(IDC_TEXTBOX)); + pTextBox->AppendText(dtmfStr); + pTextBox->Invalidate(true); + } +} + +void +ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + //set itself as listener + __pCallPresentor->SetTelEventListener(this); + if (__pActiveCallInfo != null) + { + delete __pActiveCallInfo; + __pActiveCallInfo = null; + } + if (__pHeldCallInfo != null) + { + delete __pHeldCallInfo; + __pHeldCallInfo = null; + } + DestroyMoreOptionsMenuList(); + + switch (__formType) + { + case FORMTYPE_OUTGOINGCALL: + { + String contactNo; + contactNo.Append(*(static_cast(pArgs->GetAt(0)))); + __pActiveCallInfo = new (std::nothrow) CallInfo(); + __pActiveCallInfo->SetContactNumber(contactNo); + Contact* pContact = __pCallPresentor->GetContactN(contactNo); + if (pContact != null) + { + __pActiveCallInfo->SetContactInfo(*pContact); + delete pContact; + } + ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo); + //make an normal outgoing call + __pCallPresentor->DialCall(contactNo, false); + } + break; + + case FORMTYPE_EMERGENCYOUTGOINGCALL: + { + String* pContactNo = static_cast(pArgs->GetAt(0)); + __pActiveCallInfo = new (std::nothrow) CallInfo(); + long long phNumber = 0; + LongLong::Parse(*pContactNo, phNumber); + __pActiveCallInfo->SetContactNumber(*pContactNo); + //make an emergency call + __pCallPresentor->DialCall(*pContactNo, true); + } + break; + + case FORMTYPE_ACTIVECALL: + { + //get contact number + CallInfo* pCall = static_cast(pArgs->GetAt(0)); + + __pActiveCallInfo = new (std::nothrow) CallInfo(); + *__pActiveCallInfo = *pCall; + String activeContactNo; + activeContactNo.Append(pCall->GetContactNumber()); + ShowPersonDetails(activeContactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo); + + //show call active time using Timer + __activeCallStartTime = pCall->GetCallConnectTime(); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime); + } + break; + + case FORMTYPE_EMERGENCYACTIVECALL: + { + //get contact number + CallInfo* pCall = static_cast(pArgs->GetAt(0)); + + __pActiveCallInfo = new (std::nothrow) CallInfo(); + *__pActiveCallInfo = *pCall; + + //show call active time using Timer + __activeCallStartTime = pCall->GetCallConnectTime(); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime); + } + break; + + case FORMTYPE_MULTIPLECALLS: + { + Button* pMoreBtn = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + if (pMoreBtn != null) + { + pMoreBtn->SetShowState(false); + } + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(false); + } + //show caller's info. + for (int index = 0; index < pArgs->GetCount();index++) + { + //Fetch call info + CallInfo* pCallInfo = static_cast(pArgs->GetAt(index)); + + String contactNo; + contactNo.Append(pCallInfo->GetContactNumber()); + + if (pCallInfo->IsOnHold() == false) + { + __pActiveCallInfo = new (std::nothrow) CallInfo(); + *__pActiveCallInfo = *pCallInfo; + + if (pCallInfo->IsConferenceCall() == false) + { + Label* pVoiceIconLbl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + if (pVoiceIconLbl) + { + pVoiceIconLbl->SetShowState(true); + } + if (pMoreBtn != null) + { + pMoreBtn->SetShowState(false); + } + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(false); + } + ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo); + } + else + { + // show display name on name Label + Label* pPeopleCountLbl = static_cast(GetControl(IDC_NUMBER1_LABEL)); + if (pPeopleCountLbl) + { + String count; + count.Append(pCallInfo->GetCallerListCount()); + count.Append(" "); + count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR)); + pPeopleCountLbl->SetText(count); + } + String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING"); + Label* pNameLbl = static_cast(GetControl(IDC_CALLER1_LABEL)); + if (pNameLbl) + { + pNameLbl->SetText(nameStr); + } + Label* pVoiceIconLbl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + if (pVoiceIconLbl) + { + pVoiceIconLbl->SetShowState(false); + } + if (pMoreBtn != null) + { + pMoreBtn->SetShowState(true); + } + if (pLblControl) + { + pLblControl->SetShowState(true); + } + Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO); + if (pPhotoBitmap != null) + { + Label* pPhotoLbl = static_cast(GetControl(IDC_CALLER1_PHOTO_LABEL)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap); + pPhotoLbl->Invalidate(true); + } + delete pPhotoBitmap; + } + } + //show call active time using Timer + __activeCallStartTime = pCallInfo->GetCallConnectTime(); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime); + } + else + { + __pHeldCallInfo = new (std::nothrow) CallInfo(); + *__pHeldCallInfo = *pCallInfo; + + if (pCallInfo->IsConferenceCall() == false) + { + ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo); + } + else + { + // show display name on name Label + Label* pPeopleCountLbl = static_cast(GetControl(IDC_NUMBER2_LABEL)); + if (pPeopleCountLbl) + { + String count; + count.Append(pCallInfo->GetCallerListCount()); + count.Append(" "); + count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR)); + pPeopleCountLbl->SetText(count); + } + String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING"); + Label* pNameLbl = static_cast(GetControl(IDC_CALLER2_LABEL)); + if (pNameLbl) + { + pNameLbl->SetText(nameStr); + } + Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO); + if (pPhotoBitmap != null) + { + Label* pPhotoLbl = static_cast(GetControl(IDC_CALLER2_PHOTO_LABEL)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap); + pPhotoLbl->Invalidate(true); + } + delete pPhotoBitmap; + } + } + //show "On Hold" + ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true); + } + } + } + break; + + case FORMTYPE_ACTIVECONFCALL: + { + //get contact number + CallInfo* pConfInfo = static_cast(pArgs->GetAt(0)); + int participantsCount = pConfInfo->GetCallerListCount(); + + // show display name on name Label + Label* pPeopleCountLbl = static_cast(GetControl(IDC_PARTICIPANTS_LABEL)); + if (pPeopleCountLbl) + { + String count; + count.Append(participantsCount); + count.Append(" "); + count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR)); + pPeopleCountLbl->SetText(count); + } + + if(participantsCount >= IDI_MAX_CONF_CALL_PARTICIPANTS) + { + __pCallButtonsPanel->EnableAddCallButton(false); + } + else + { + __pCallButtonsPanel->EnableAddCallButton(true); + } + + //show call active time using Timer + __activeCallStartTime = pConfInfo->GetCallConnectTime(); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pConfInfo->IsOnHold(),__activeCallStartTime); + } + break; + + default: + break; + } + + //Hide DTMFKeypad, if visible and show caller info + HideDTMFKeypad(); + SetShowStateOnKeypad(true); + __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD); + + //Set the correct speaker status + if(__pCallPresentor->IsSpeakerOn() == true) + { + __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF); + } + else + { + __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER); + } + + //Set the correct Mute status + if (__pCallPresentor->IsCallMuted() == true) + { + __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE); + } + else + { + __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE); + } + + if (pArgs) + { + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + // Add your scene deactivate code here + if (__pActiveCallTimer != null) + { + __pActiveCallTimer->Cancel(); + delete __pActiveCallTimer; + __pActiveCallTimer = null; + } + if (__pSmallPhotoLabel != null) + { + __pSmallPhotoLabel->SetShowState(false); + } + //Hide "Manage conf. Call" Context menu + if (__pMoreOptionsListAnchor != null) + { + __pMoreOptionsListAnchor->SetShowState(false); + } + if (__pMoreOptionsList != null) + { + __pMoreOptionsList->SetShowState(false); + } +} + +void +ActiveCallForm::HandleCallSwapN(IList* pCallList) +{ + if (pCallList != null) + { + if (__pActiveCallInfo) + { + delete __pActiveCallInfo; + } + if (__pHeldCallInfo) + { + delete __pHeldCallInfo; + } + //show caller's info. + for (int index = 0; index < pCallList->GetCount();index++) + { + //Fetch call info + CallInfo* pCallInfo = static_cast(pCallList->GetAt(index)); + + String contactNo; + contactNo.Append(pCallInfo->GetContactNumber()); + + if (pCallInfo->IsOnHold() == false) + { + __pActiveCallInfo = new (std::nothrow) CallInfo(); + *__pActiveCallInfo = *pCallInfo; + + if (pCallInfo->IsConferenceCall() == false) + { + Label* pVoiceIconLbl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + if (pVoiceIconLbl) + { + pVoiceIconLbl->SetShowState(true); + } + Button* pMoreBtn = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + if (pMoreBtn != null) + { + pMoreBtn->SetShowState(false); + } + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(false); + } + ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo); + } + else + { + Label* pVoiceIconLbl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + if (pVoiceIconLbl) + { + pVoiceIconLbl->SetShowState(false); + } + Button* pMoreBtn = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + if (pMoreBtn != null) + { + pMoreBtn->SetShowState(true); + } + Label* pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + if (pLblControl) + { + pLblControl->SetShowState(true); + } + // show display name on name Label + Label* pPeopleCountLbl = static_cast(GetControl(IDC_NUMBER1_LABEL)); + if (pPeopleCountLbl) + { + String count; + count.Append(pCallInfo->GetCallerListCount()); + count.Append(" "); + count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR)); + pPeopleCountLbl->SetText(count); + } + String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING"); + Label* pNameLbl = static_cast(GetControl(IDC_CALLER1_LABEL)); + if (pNameLbl) + { + pNameLbl->SetText(nameStr); + } + Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO); + if (pPhotoBitmap != null) + { + Label* pPhotoLbl = static_cast(GetControl(IDC_CALLER1_PHOTO_LABEL)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap); + } + delete pPhotoBitmap; + } + } + //show call active time using Timer + __activeCallStartTime = pCallInfo->GetCallConnectTime(); + ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime); + } + else + { + __pHeldCallInfo = new (std::nothrow) CallInfo(); + *__pHeldCallInfo = *pCallInfo; + + if (pCallInfo->IsConferenceCall() == false) + { + ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo); + } + else + { + // show display name on name Label + Label* pPeopleCountLbl = static_cast(GetControl(IDC_NUMBER2_LABEL)); + if (pPeopleCountLbl) + { + String count; + count.Append(pCallInfo->GetCallerListCount()); + count.Append(" "); + count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR)); + pPeopleCountLbl->SetText(count); + } + String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING"); + Label* pNameLbl = static_cast(GetControl(IDC_CALLER2_LABEL)); + if (pNameLbl) + { + pNameLbl->SetText(nameStr); + } + Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO); + if (pPhotoBitmap != null) + { + Label* pPhotoLbl = static_cast(GetControl(IDC_CALLER2_PHOTO_LABEL)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap); + } + delete pPhotoBitmap; + } + } + //show "On Hold" + ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true); + } + } + Invalidate(true); + } +} + +void +ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, CallInfo* pCallInfo) +{ + //call individual methods to show contact number, caller name & photo + ShowPhoneNumber(phoneNumber, contactLblName); + + //fetch contact details based on phone number + String* pDisplayName = pCallInfo->FetchCallerNameN(); + ShowCallerName(*pDisplayName, nameLblName); + + Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN(); + ShowCallerPhoto(pPhotoBitmap, isSecondCaller); + + //free resources + if (pDisplayName) + { + delete pDisplayName; + pDisplayName = null; + } + if (pPhotoBitmap) + { + delete pPhotoBitmap; + pPhotoBitmap = null; + } +} + +void +ActiveCallForm::ShowPhoneNumber(const String& phoneNumber, const String& contactLblName) +{ + String formattedNumber = phoneNumber; + + Label* pContactLbl = static_cast(GetControl(contactLblName)); + if (pContactLbl) + { + pContactLbl->SetText(formattedNumber); + pContactLbl->Invalidate(true); + } +} + +void +ActiveCallForm::ShowCallerName(const String& callerName, const String& nameLblName) +{ + // show display name on name Label + Label* pNameLbl = static_cast(GetControl(nameLblName)); + if (pNameLbl) + { + //passing an empty string to SetText fails in label, + //if previously valid text has been set + if (callerName.IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false) + { + String stringToBeSet(L" "); + pNameLbl->SetText(stringToBeSet); + } + else + { + pNameLbl->SetText(callerName); + } + pNameLbl->Invalidate(true); + } +} + +void +ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller) +{ + //to check if default image is to be shown + bool showDefaultPhoto = false; + String photoLabel(""); + + switch (__formType) + { + case FORMTYPE_OUTGOINGCALL: + case FORMTYPE_ACTIVECALL: + { + if (pPhotoId == null) + { + //show default caller image + showDefaultPhoto = true; + } + photoLabel.Append(IDC_CALLER1_BIGPHOTO_LABEL); + } + break; + + case FORMTYPE_MULTIPLECALLS: + { + if (isSecondCaller) + { + photoLabel.Append(IDC_CALLER2_PHOTO_LABEL); + } + else + { + photoLabel.Append(IDC_CALLER1_PHOTO_LABEL); + } + + if (pPhotoId == null) + { + showDefaultPhoto = true; + } + else + { + if (pPhotoId->GetHeight() <= H_SMALL_PHOTO + || pPhotoId->GetWidth() <= W_SMALL_PHOTO) + { + pPhotoId->Scale(Dimension(W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO)); + } + } + } + break; + + default: + break; + } + + //Remove small photo label + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } + + //show photo - for Big Photo Id, Animated Call Image + if (!showDefaultPhoto) + { + Label* pPhotoLbl = static_cast(GetControl(photoLabel)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoId); + pPhotoLbl->Invalidate(true); + } + } + else + { + Bitmap* pDefaultPhoto = null; + switch (__formType) + { + case FORMTYPE_OUTGOINGCALL: + case FORMTYPE_ACTIVECALL: + pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO); + break; + + case FORMTYPE_MULTIPLECALLS: + pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_MULTIPLE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO); + break; + + case FORMTYPE_ACTIVECONFCALL: + pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BIG_BG_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO); + break; + + default: + break; + } + if (pDefaultPhoto != null) + { + Label* pPhotoLbl = static_cast(GetControl(photoLabel)); + if (pPhotoLbl) + { + pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto); + } + delete pDefaultPhoto; + } + } +} + +void +ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId) +{ + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } + //Draw Small Photo and show on small photo label + __pSmallPhotoLabel = new (std::nothrow) Label();//static_cast(GetControl(IDC_SMALL_PHOTO_LABEL)); + __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L""); + __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0)); + __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId); + // Add a Label to the Form + AddControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel->Invalidate(true); +} + +void +ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long long startTime) +{ + Label* pTimerLbl = static_cast(GetControl(timerLblName)); + + if (__pActiveCallTimer == null) + { + __pActiveCallTimer = new (std::nothrow) Tizen::Base::Runtime::Timer(); + __pActiveCallTimer->Construct(*this); + } + + if (pTimerLbl != null) + { + if (isOnHold == true) + { + pTimerLbl->SetText(L"On hold"); + //update Hold button status + SetHoldButtonStatus(false); + } + else + { + //update Hold button status + SetHoldButtonStatus(true); + //current system time + long long currTime = 0; + SystemTime::GetTicks(currTime); + //Set call duration + TimeSpan diffSpan(abs(startTime - currTime)); + + String activeCallTime(L""); + + long long hr = diffSpan.GetHours(); + if (hr <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(hr); + activeCallTime.Append(L":"); + + long long min = diffSpan.GetMinutes(); + if (min <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(min); + activeCallTime.Append(L":"); + + long long sec = diffSpan.GetSeconds(); + if (sec <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(sec); + + pTimerLbl->SetText(activeCallTime); + __pActiveCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND); + } + pTimerLbl->Invalidate(true); + } +} + +void +ActiveCallForm::SetShowStateOnKeypad(bool showState) +{ + Label* pLblControl = static_cast(GetControl(IDC_LINE_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_CALLER1_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_BACKGROUND_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_CALLER1_TIME_LABEL)); + pLblControl->SetShowState(showState); + if (__pSmallPhotoLabel != null) + { + __pSmallPhotoLabel->SetShowState(showState); + } + + switch (__formType) + { + case FORMTYPE_ACTIVECALL: + { + pLblControl = static_cast(GetControl(IDC_NUMBER1_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_HOLD_LABEL)); + pLblControl->SetShowState(showState); + Button* pButtonControl = static_cast(GetControl(IDC_HOLD_BUTTON)); + pButtonControl->SetShowState(showState); + } + break; + + case FORMTYPE_MULTIPLECALLS: + { + pLblControl = static_cast(GetControl(IDC_NUMBER1_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_CALLER2_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_NUMBER2_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_CALLER2_TIME_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_SWAP_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_BACKGROUND_LABEL2)); + pLblControl->SetShowState(showState); + if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == false) + { + pLblControl = static_cast(GetControl(IDC_VOICE_CALL_ICON_LABEL)); + pLblControl->SetShowState(showState); + } + else + { + Button* pButtonControl = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + pButtonControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + pLblControl->SetShowState(showState); + } + Button* pButtonControl = static_cast(GetControl(IDC_SWAP_BUTTON)); + pButtonControl->SetShowState(showState); + } + break; + + case FORMTYPE_ACTIVECONFCALL: + { + pLblControl = static_cast(GetControl(IDC_PARTICIPANTS_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_HOLD_LABEL)); + pLblControl->SetShowState(showState); + pLblControl = static_cast(GetControl(IDC_DIVIDER_LABEL)); + pLblControl->SetShowState(showState); + Button* pButtonControl = static_cast(GetControl(IDC_HOLD_BUTTON)); + pButtonControl->SetShowState(showState); + pButtonControl = static_cast(GetControl(IDC_CONF_CALL_MORE_BUTTON)); + pButtonControl->SetShowState(showState); + } + break; + + default: + break; + } +} + +void +ActiveCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + //Call default implementation of "Object.Equals()" + //returns true, if they are pointing to same address. + if (__pActiveCallTimer->Equals(timer)) + { + Label* pTimerLbl = static_cast(GetControl(IDC_CALLER1_TIME_LABEL)); + if (pTimerLbl) + { + String activeCallTime = pTimerLbl->GetText(); + // Create a StringTokenizer instance + StringTokenizer strTokens(activeCallTime, L":"); + + int count = strTokens.GetTokenCount(); // count == 3 + String token; + int sec = 0; + int min = 0; + int hr = 0; + for (int index = 0; index < count; index++) + { + switch (index) + { + case 0: + strTokens.GetNextToken(token); + Integer::Parse(token, hr); + break; + + case 1: + strTokens.GetNextToken(token); + Integer::Parse(token, min); + break; + + case 2: + strTokens.GetNextToken(token); + Integer::Parse(token, sec); + break; + } + } + //update all values + sec = sec + 1; + if (sec == IDI_MAX_SECONDS) + { + sec = 0; + min = min + 1; + } + if (min == IDI_MAX_MINS) + { + min = 0; + hr = hr + 1; + } + + //replace string + activeCallTime.Clear(); + if (hr <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(hr); + activeCallTime.Append(":"); + if (min <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(min); + activeCallTime.Append(":"); + if (sec <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(sec); + //update timer label + pTimerLbl->SetText(activeCallTime); + pTimerLbl->Invalidate(true); + } + } +} + +/////////////////////////////////////////////////////////// +/////////// Options Menu List Functionality ///////// +/////////////////////////////////////////////////////////// +void +ActiveCallForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state) +{ +} + +void +ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status) +{ + //Goto conference call list form + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST), null); +} + +void +ActiveCallForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction) +{ +} + +void +ActiveCallForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback) +{ +} + +int +ActiveCallForm::GetItemCount(void) +{ + return IDI_MOREOPTIONS_LIST_ITEMS; +} + +ListItemBase* +ActiveCallForm::CreateItem(int index, int itemWidth) +{ + //create 1st Menu option + CustomItem* pItem = new (std::nothrow) CustomItem(); + pItem->Construct(IDI_OPTIONMENU_DIMEN, LIST_ANNEX_STYLE_NORMAL); + + //Set background 9-patch bitmap to option menu + Bitmap* pBgBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_BG_ICON); + if (pBgBmp != null && pBgBmp->IsNinePatchedBitmap()) + { + Canvas bgCanvas; + bgCanvas.Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN)); + bgCanvas.DrawNinePatchedBitmap(bgCanvas.GetBounds(), *pBgBmp); + } + else + { + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(40, 45, 48)); + } + delete pBgBmp; + pBgBmp = null; + + //Set bitmap to option menu + Bitmap* pNormalConfCallBmp = AppUtility::GetBitmapFromResourcesN(IDB_MORE_MANAGE_CONFERENCE_ICON , + W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP); + pItem->AddElement(Rectangle(16, 17, W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP), 1, *pNormalConfCallBmp, null, null); + // Deallocate bitmaps + delete pNormalConfCallBmp; + pNormalConfCallBmp = null; + + //Set text to menu option + String confCallName = AppUtility::GetResourceString(IDS_MGR_CONF_CALL_LIST_STR); + + TextElement* pTextElement = new (std::nothrow) TextElement(); + pTextElement->Construct(confCallName); + pTextElement->SetTextColor(COLOR_POPUP_TEXT); + //create font + Font font; + font.Construct(FONT_STYLE_PLAIN, IDI_POPUP_TEXT_SIZE); + pTextElement->SetFont(font); + //construct Enriched text + EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText(); + Dimension textDimension; + font.GetTextExtent(confCallName, confCallName.GetLength(), textDimension); + textDimension.height = textDimension.height + font.GetDescender(); + pEnrichedText->Construct(textDimension); + //add text element to enriched text + pEnrichedText->Add(*pTextElement); + + //Add Enriched text to pItem + Point textPos(((2 * IDI_OPTIONMENU_ITEM_SPACING) + W_MGR_CONFCALL_BITMAP), ((IDI_OPTIONMENU_DIMEN.height - textDimension.height) / 2)); + pItem->AddElement(Rectangle(textPos, textDimension), 2, *pEnrichedText); + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + return pItem; +} + +bool +ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + delete pItem; + return true; +} diff --git a/src/PhnAppUtility.cpp b/src/PhnAppUtility.cpp new file mode 100644 index 0000000..0f50033 --- /dev/null +++ b/src/PhnAppUtility.cpp @@ -0,0 +1,65 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnAppUtility.cpp + * @brief Utility Class for Phone Application + */ +#include +#include "PhnAppUtility.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +AppUtility::AppUtility(void) +{ +} + +AppUtility::~AppUtility(void) +{ +} + +String +AppUtility::GetResourceString(const String& stringId) +{ + String resourceString(L""); + AppResource* pAppResource = AppResource::GetInstance(); + if (pAppResource) + { + pAppResource->GetString(stringId, resourceString); + } + + return resourceString; +} + +Bitmap* +AppUtility::GetBitmapFromResourcesN(const String& imagePath, int imgWidth, int imgHeight) +{ + Bitmap* pBitmap = null; + AppResource* pAppResource = AppResource::GetInstance(); + if (pAppResource) + { + pBitmap = pAppResource->GetBitmapN(imagePath); + if (pBitmap && imgWidth > 0 && imgHeight > 0) + { + //scale bitmap to predefined size + pBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pBitmap->Scale(Dimension(imgWidth, imgHeight)); + } + } + return pBitmap; +} diff --git a/src/PhnBaseForm.cpp b/src/PhnBaseForm.cpp new file mode 100644 index 0000000..27a7105 --- /dev/null +++ b/src/PhnBaseForm.cpp @@ -0,0 +1,410 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnBaseForm.cpp + * @brief Base class for all Call forms + */ +#include "PhnActiveCallForm.h" +#include "PhnBaseForm.h" +#include "PhnCallInfo.h" +#include "PhnCallPresentationModel.h" +#include "PhnConfCallerListForm.h" +#include "PhnPhoneFormFactory.h" +#include "PhnSceneRegister.h" +#include "PhnPhoneApp.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Ui::Controls; + +BaseForm::BaseForm(FormType formType) + : __formType(formType) +{ + __pCallPresentor = null; + __pErrorMsgPopup = null; +} + +BaseForm::~BaseForm(void) +{ +} + +result +BaseForm::OnInitializing(void) +{ + AddOrientationEventListener(*this); + //To be implemented in sub classes + return E_SUCCESS; +} + +void +BaseForm::OnActionPerformed(const Control& source, int actionId) +{ +} + +///////////////////////////////////////////////////////////////// +///// Event Listener methods from ITelephonyEventListener ///// +///////////////////////////////////////////////////////////////// + +void +BaseForm::HandleCallConnected(IListT& pCallList) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + + switch (__formType) + { + case FORMTYPE_OUTGOINGCALL: + case FORMTYPE_INCOMINGCALL: + case FORMTYPE_CONFCALLLIST: + case FORMTYPE_ACTIVECALL: + case FORMTYPE_ACTIVECONFCALL: + { + int noOfCalls = pCallList.GetCount(); + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(noOfCalls); + + for (int index = 0; index < noOfCalls; index++) + { + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList.GetAt(index, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCaller = new (std::nothrow) CallInfo(); + *pCaller = callInfo; + pCallInfoList->Add(pCaller); + } + } + + if (noOfCalls == 1) + { + //Check if active call is conference call + CallInfo* pActiveCallInfo = static_cast(pCallInfoList->GetAt(0)); + if(pActiveCallInfo->IsConferenceCall() == true) + { + //single Conference call - goto active Conf. call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList); + } + else + { + //single active call - goto active call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList); + } + } + else if(noOfCalls == 2) + { + //goto multiple active call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList); + } + } + break; + + case FORMTYPE_EMERGENCYOUTGOINGCALL: + { + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(1); + + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList.GetAt(0, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCaller = new (std::nothrow) CallInfo(); + *pCaller = callInfo; + pCallInfoList->Add(pCaller); + //single active call - goto active call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL), pCallInfoList); + } + } + break; + + default: + break; + } +} + +void +BaseForm::HandleCallDisconnected(bool isLastCall, IListT& pCallList) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + + int callCount = pCallList.GetCount(); + if (callCount > 0) + { + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(callCount); + for (int index = 0; index < callCount; index++) + { + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList.GetAt(index, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCaller = new (std::nothrow) CallInfo(); + *pCaller = callInfo; + pCallInfoList->Add(pCaller); + } + } + if (callCount == 1) + { + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList.GetAt(0, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCaller = new (std::nothrow) CallInfo(); + *pCaller = callInfo; + pCallInfoList->Add(pCaller); + } + + if (isLastCall == true) + { + //goto End Call form if single call. else go to dialer + SceneId nextSceneId = pPhoneApp->GetInitialScene(); + if (callInfo.IsConferenceCall() == false) + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL), pCallInfoList); + } + else if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG) + { + pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + pCallInfoList->RemoveAll(); + delete pCallInfoList; + pCallInfoList = null; + } + else + { + pPhoneApp->Terminate(); + } + } + else + { + if (pCallList.GetCount() == 1) + { + if (callInfo.IsConferenceCall() == true) + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList); + } + else + { + //goto Single Active Call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList); + } + } + } + } + else + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList); + } + } + else + { + SceneId nextSceneId = pPhoneApp->GetInitialScene(); + //No more calls are active + if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG) + { + pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + else + { + pPhoneApp->Terminate(); + } + } +} + + +void +BaseForm::HandleConferenceCall(CallInfo& pCallInfo) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(1); + + //update list to be passed + CallInfo* pConfInfo = new (std::nothrow) CallInfo(); + *pConfInfo = pCallInfo; + pCallInfoList->Add(pConfInfo); + + //Todo: create screens for single conf call and conf call with another held call + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList); +} + +void +BaseForm::HandleIncomingCall(CallInfo& pCallInfo) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(1); + + //update list to be passed + CallInfo* pIncomingCall = new (std::nothrow) CallInfo(); + *pIncomingCall = pCallInfo; + pCallInfoList->Add(pIncomingCall); + + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList); +} + +void +BaseForm::HandleCallSwapOccured(IListT& pCallList) +{ + int noOfCalls = pCallList.GetCount(); + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(noOfCalls); + + for (int index = 0; index < noOfCalls; index++) + { + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList.GetAt(index, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCallInfo = new (std::nothrow) CallInfo(); + *pCallInfo = callInfo; + pCallInfoList->Add(pCallInfo); + } + } + + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager != null) + { + Scene* pActiveScene = pSceneManager->GetCurrentScene(); + if (pActiveScene != null) + { + String formString = pActiveScene->GetFormId(); + if (formString == IDL_FORM_MULTIPLEACTIVECALL) + { + ActiveCallForm* pActiveForm = (ActiveCallForm*) pActiveScene->GetForm(); + pActiveForm->HandleCallSwapN(pCallInfoList); + } + } + } +} + +void +BaseForm::HandleConferenceChange(void) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager != null) + { + Scene* pActiveScene = pSceneManager->GetCurrentScene(); + if (pActiveScene != null) + { + String formString = pActiveScene->GetFormId(); + if (formString == IDL_FORM_CONFCALLLIST) + { + ConfCallerListForm* pConfListForm = (ConfCallerListForm*) pActiveScene->GetForm(); + pConfListForm->HandleCallChange(); + } + } + } +} + +void +BaseForm::HandleTelephonyError(int errorCode) +{ + //show error msg Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode); +} + +void +BaseForm::HandlePopupClosed(void) +{ + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + switch(__formType) + { + case FORMTYPE_OUTGOINGCALL: + { + //fetch no of calls from telephony + CallPresentationModel* pPresentor = CallPresentationModel::GetInstance(); + if(pPresentor != null) + { + //check if any call is present + if(pPresentor->GetCurrentCallCount() > 0) + { + //fetch current call list + IListT* pCurrentCallList = pPresentor->GetCallListN(); + HandleCallDisconnected(false,*pCurrentCallList); + delete pCurrentCallList; + pCurrentCallList = null; + } + else + { + //No more calls are active + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + SceneId nextSceneId = pPhoneApp->GetInitialScene(); + if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG) + { + pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + else + { + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + pPhoneApp->Terminate(); + } + } + } + } + break; + + case FORMTYPE_ENDCALL: + { + //It comes here, only when we make voice call for Last call from EndCallForm + //and some TAPI error is encountered. + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + pPhoneApp->Terminate(); + } + break; + + default: + break; + } +} + +void +BaseForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus) +{ + SetOrientation(ORIENTATION_PORTRAIT); +} + diff --git a/src/PhnCallButtonsPanel.cpp b/src/PhnCallButtonsPanel.cpp new file mode 100644 index 0000000..8d84ae5 --- /dev/null +++ b/src/PhnCallButtonsPanel.cpp @@ -0,0 +1,648 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallButtonsPanel.cpp + * @brief Base class for all Call forms + */ +#include "PhnCallButtonsPanel.h" +#include "PhnAppUtility.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +//Constants - Scene name +const wchar_t* IDC_ADDJOINCALL_BUTTON = L"IDC_ADDJOINCALL_BUTTON"; +const wchar_t* IDC_KEYPAD_BUTTON = L"IDC_KEYPAD_BUTTON"; +const wchar_t* IDC_MUTE_BUTTON = L"IDC_MUTE_BUTTON"; +const wchar_t* IDC_CONTACT_BUTTON = L"IDC_CONTACT_BUTTON"; +const wchar_t* IDC_SPEAKER_BUTTON = L"IDC_SPEAKER_BUTTON"; +const wchar_t* IDC_VOICECALL_BUTTON = L"IDC_VOICECALL_BUTTON"; +const wchar_t* IDC_VIDEOCALL_BUTTON = L"IDC_VIDEOCALL_BUTTON"; +const wchar_t* IDC_MSG_BUTTON = L"IDC_MSG_BUTTON"; +const wchar_t* IDC_ENDCALL_BUTTON = L"IDC_ENDCALL_BUTTON"; + +//Button Dimensions +const int W_BG_BITMAP = 80; +const int H_BG_BITMAP = 80; +const int Y_BG_BITMAP_POS = 56; +const int IDI_TEXT_SIZE = 38; +const int IDI_VERTICAL_SPACE = 6; + +CallButtonsPanel::CallButtonsPanel(void) +{ +} + +CallButtonsPanel::~CallButtonsPanel(void) +{ + //Empty Implementation +} + +bool +CallButtonsPanel::ConstructPanel(IActionEventListener* pEventListener, FormType parentFormType) +{ + if (pEventListener == null) + { + return false; + } + + result r = E_SUCCESS; + + //set action listener & save form state + __pActionListener = pEventListener; + __parentFormType = parentFormType; + + switch (__parentFormType) + { + case FORMTYPE_ENDCALL: + r = Construct(IDL_END_CALL_PANEL); + break; + + default: + r = Construct(IDL_CALL_PANEL); + break; + } + + TryCatch(r == E_SUCCESS, , "CallButtonsPanel::Initialize() resource not found"); + + return true; +CATCH: + return false; +} + +result +CallButtonsPanel::OnInitializing(void) +{ + result r = E_FAILURE; + + RelativeLayout* pRelativeLayout = dynamic_cast(GetParent()->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetRelation(*this, *GetParent(), RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + delete pRelativeLayout; + } + + pRelativeLayout = dynamic_cast(GetParent()->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetRelation(*this, *GetParent(), RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + delete pRelativeLayout; + } + + //Set background bitmap + r = AddBackgroundBitmap(); + if (IsFailed(r)) + { + return r; + } + //set buttons as child controls + switch (__parentFormType) + { + case FORMTYPE_ENDCALL: + r = ConstructEndCallPanel(); + break; + + default: + r = ConstructActiveCallPanel(); + break; + } + + if (IsFailed(r)) + { + return r; + } + SetButtonPosition(); + Draw(); + Show(); + return r; +} + +result +CallButtonsPanel::OnTerminating(void) +{ + //remove all child controls... + RemoveAllControls(); + return E_SUCCESS; +} + +void +CallButtonsPanel::SetSpeakerButtonState(CommandIds cmdId) +{ + //Speaker + String speakerButtonId(IDC_SPEAKER_BUTTON); + Button* pButton = static_cast(GetControl(speakerButtonId)); + //Check if Button exist and needs to change state. + if(pButton == null || pButton->GetActionId() == cmdId) + { + return; + } + + String btnName = AppUtility::GetResourceString(IDS_SPEAKER_BTN_NAME); + AddKeyPadActionListener(speakerButtonId, cmdId); + switch (cmdId) + { + case IDA_SPEAKER: + { + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_OFF_ICON, BTN_NORMAL); + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_OFF_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_OFF_DIM_ICON, BTN_DIM); + } + break; + + case IDA_SPEAKER_OFF: + { + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_ON_ICON, BTN_NORMAL); + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_ON_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(speakerButtonId, btnName, IDB_SPEAKER_ON_DIM_ICON, BTN_DIM); + } + break; + + default: + break; + } +} + +void +CallButtonsPanel::SetMuteButtonState(CommandIds cmdId) +{ + String muteButtonId(IDC_MUTE_BUTTON); + Button* pButton = static_cast(GetControl(muteButtonId)); + //Check if Button exist and needs to change state. + if(pButton == null || pButton->GetActionId() == cmdId) + { + return; + } + + String btnName = AppUtility::GetResourceString(IDS_MUTE_BTN_NAME); + AddKeyPadActionListener(muteButtonId, cmdId); + switch(cmdId) + { + case IDA_UNMUTE: + { + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_ON_ICON, BTN_NORMAL); + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_ON_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_ON_DIM_ICON, BTN_DIM); + } + break; + + case IDA_MUTE: + { + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_OFF_ICON, BTN_NORMAL); + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_OFF_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(muteButtonId, btnName, IDB_MUTE_OFF_DIM_ICON, BTN_DIM); + } + break; + + default: + break; + } +} + +void +CallButtonsPanel::SetKeypadButtonState(CommandIds cmdId) +{ + String keypadButtonId(IDC_KEYPAD_BUTTON); + Button* pButton = static_cast(GetControl(keypadButtonId)); + //Check if Button exist and needs to change state. + if(pButton == null || pButton->GetActionId() == cmdId) + { + return; + } + + String btnName = AppUtility::GetResourceString(IDS_KEYPAD_BTN_NAME); + AddKeyPadActionListener(keypadButtonId, cmdId); + switch (cmdId) + { + case IDA_CLOSE_NUMKEYPAD: + { + SetBitmapsToButton(keypadButtonId, btnName, IDB_HIDE_KEYPAD_ICON, BTN_NORMAL); + SetBitmapsToButton(keypadButtonId, btnName, IDB_HIDE_KEYPAD_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(keypadButtonId, btnName, IDB_HIDE_KEYPAD_DIM_ICON, BTN_DIM); + } + break; + + case IDA_OPEN_NUMKEYPAD: + { + SetBitmapsToButton(keypadButtonId, btnName, IDB_CLOSE_KEYPAD_ICON, BTN_NORMAL); + SetBitmapsToButton(keypadButtonId, btnName, IDB_CLOSE_KEYPAD_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(keypadButtonId, btnName, IDB_CLOSE_KEYPAD_DIM_ICON, BTN_DIM); + } + break; + + default: + break; + } +} + +result +CallButtonsPanel::AddBackgroundBitmap(void) +{ + result r = E_FAILURE; + + Rectangle panelRect = GetBounds(); + //Set BackGround bitmap + Bitmap* pBgBitmap = null; + AppResource* pAppResource = AppResource::GetInstance(); + if (pAppResource) + { + pBgBitmap = pAppResource->GetBitmapN(IDB_BACKGROUND_BITMAP); + if (pBgBitmap) + { + Label* pBackgroundLabel = new (std::nothrow) Label(); + pBackgroundLabel->Construct(Rectangle(0, 1, panelRect.width, panelRect.height), L""); + pBackgroundLabel->SetBackgroundBitmap(*pBgBitmap); + r = AddControl(*pBackgroundLabel); + + //always display in background + SetControlAlwaysAtBottom(*pBackgroundLabel, true); + + delete pBgBitmap; + pBgBitmap = null; + } + } + return r; +} + +result +CallButtonsPanel::ConstructEndCallPanel(void) +{ + result r = E_SUCCESS; + Rectangle relativeCtrlRect = GetBounds(); + + //Voice Call + String voiceButtonId(IDC_VOICECALL_BUTTON); + String btnName = AppUtility::GetResourceString(IDS_VOICE_CALL_BTN_NAME); + SetBitmapsToButton(voiceButtonId, btnName, IDB_VOICE_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(voiceButtonId, btnName, IDB_VOICE_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(voiceButtonId, btnName, IDB_VOICE_CALL_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(voiceButtonId, IDA_VOICE_CALL); + + //Video Call + String videoButtonId(IDC_VIDEOCALL_BUTTON); + btnName = AppUtility::GetResourceString(IDS_VIDEO_CALL_BTN_NAME); + SetBitmapsToButton(videoButtonId, btnName, IDB_VIDEO_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(videoButtonId, btnName, IDB_VIDEO_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(videoButtonId, btnName, IDB_VIDEO_CALL_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(videoButtonId, IDA_VIDEO_CALL); + + //Message + String msgButtonId(IDC_MSG_BUTTON); + btnName = AppUtility::GetResourceString(IDS_MSG_BTN_NAME); + SetBitmapsToButton(msgButtonId, btnName, IDB_MESSAGE_ICON, BTN_NORMAL); + SetBitmapsToButton(msgButtonId, btnName, IDB_MESSAGE_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(msgButtonId, btnName, IDB_MESSAGE_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(msgButtonId, IDA_MESSAGE); + + return r; +} + +result +CallButtonsPanel::ConstructActiveCallPanel(void) +{ + result r = E_SUCCESS; + + //End Call + String endButtonId(IDC_ENDCALL_BUTTON); + String btnName = AppUtility::GetResourceString(IDS_ENDCALL_BTN_NAME); + SetBitmapsToButton(endButtonId, btnName, IDB_END_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(endButtonId, btnName, IDB_END_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(endButtonId, btnName, IDB_END_CALL_DIM_ICON, BTN_DIM); + + //Add or Join call based on form state + String addJoinButtonId(IDC_ADDJOINCALL_BUTTON); + switch (__parentFormType) + { + case FORMTYPE_OUTGOINGCALL: + case FORMTYPE_ACTIVECALL: + case FORMTYPE_EMERGENCYOUTGOINGCALL: + case FORMTYPE_EMERGENCYACTIVECALL: + { + //End call listener + AddKeyPadActionListener(endButtonId, IDA_END_CALL); + //Add Call + btnName = AppUtility::GetResourceString(IDS_ADDCALL_BTN_NAME); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(addJoinButtonId, IDA_ADD_CALL); + } + break; + + case FORMTYPE_ACTIVECONFCALL: + { + //End call listener + AddKeyPadActionListener(endButtonId, IDA_END_CONF_CALL); + //Add Call + btnName = AppUtility::GetResourceString(IDS_ADDCALL_BTN_NAME); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_ADD_CALL_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(addJoinButtonId, IDA_ADD_CALL); + } + break; + + case FORMTYPE_MULTIPLECALLS: + { + //End call listener + AddKeyPadActionListener(endButtonId, IDA_END_CALL); + //Join Call + btnName = AppUtility::GetResourceString(IDS_JOINCALL_BTN_NAME); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_JOIN_CALL_ICON, BTN_NORMAL); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_JOIN_CALL_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(addJoinButtonId, btnName, IDB_JOIN_CALL_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(addJoinButtonId, IDA_JOIN_CALL); + } + break; + + default: + break; + } + + //Keypad is closed, bt default + SetKeypadButtonState(IDA_OPEN_NUMKEYPAD); + //Speaker is off, by default + SetSpeakerButtonState(IDA_SPEAKER); + //Mute is off, by default + SetMuteButtonState(IDA_MUTE); + //Contact + String contactButtonId(IDC_CONTACT_BUTTON); + btnName = AppUtility::GetResourceString(IDS_CONTACT_BTN_NAME); + SetBitmapsToButton(contactButtonId, btnName, IDB_CONTACT_ICON, BTN_NORMAL); + SetBitmapsToButton(contactButtonId, btnName, IDB_CONTACT_PRESS_ICON, BTN_PRESS); + SetBitmapsToButton(contactButtonId, btnName, IDB_CONTACT_DIM_ICON, BTN_DIM); + AddKeyPadActionListener(contactButtonId, IDA_OPEN_CONTACTS); + + //ToDO: For now disabling the contact button as there is no way to launch contact app control + // just for viewwing + Button* pButton = static_cast(GetControl(IDC_CONTACT_BUTTON)); + pButton->SetEnabled(false); + //disable all keys except 'Speaker' keys while dialing outgoing call + if (__parentFormType == FORMTYPE_OUTGOINGCALL || __parentFormType == FORMTYPE_EMERGENCYOUTGOINGCALL + || __parentFormType == FORMTYPE_EMERGENCYACTIVECALL) + { + DisableKeysForOutgoingCall(); + } + + return r; +} + +void +CallButtonsPanel::SetBitmapsToButton(const String& buttonId, const String& buttonName, const String& imgPath, ButtonState state) +{ + Button* pButton = static_cast(GetControl(buttonId)); + if (pButton != null) + { + //Fetch Bitmap from resource + Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(imgPath, + W_BG_BITMAP, H_BG_BITMAP); + + //Create a new canvas + Canvas* pCanvas = new (std::nothrow) Canvas; + pCanvas->Construct(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + + //Set Text to Canvas + Point bitmapPos(0, 0); + bitmapPos.SetPosition(((pCanvas->GetBounds().width - pBitmap->GetWidth()) / 2), Y_BG_BITMAP_POS); + SetEnrichedTextToButton(buttonName, pCanvas, state, (bitmapPos.y + pBitmap->GetHeight() + IDI_VERTICAL_SPACE)); + + //set normal bitmap to canvas + pCanvas->DrawBitmap(Rectangle(bitmapPos, Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap); + + //Set the final Bitmap to Button + Bitmap* pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds()); + + switch (state) + { + case BTN_NORMAL: + { + pButton->SetNormalBackgroundBitmap(*pActualBgBmp); + } + break; + + case BTN_PRESS: + { + Bitmap* highlightedBmp = AppUtility::GetBitmapFromResourcesN(L"C01-1_icon_button_press.png",236,237); + if(highlightedBmp != null) + { + pButton->SetHighlightedBackgroundBitmap(*highlightedBmp); + delete highlightedBmp; + highlightedBmp = null; + } + pButton->SetPressedBitmap(Point(0,0),*pActualBgBmp); + } + break; + + case BTN_DIM: + { + pButton->SetDisabledBitmap(Point(0, 0), *pActualBgBmp); + } + break; + } + pButton->Invalidate(true); + + delete pBitmap; + delete pActualBgBmp; + delete pCanvas; + } +} + +void +CallButtonsPanel::SetEnrichedTextToButton(const String& buttonName, Canvas* pCanvas, ButtonState state, int verticalPos) +{ + //find text color + Color textColor(255, 255, 255); + switch (state) + { + case BTN_NORMAL: + textColor.SetAlpha(255); + break; + + case BTN_PRESS: + textColor.SetAlpha(127); + break; + + case BTN_DIM: + textColor.SetAlpha(77); + break; + } + + Font font; + font.Construct(FONT_STYLE_PLAIN, IDI_TEXT_SIZE); + Dimension textDimension; + font.GetTextExtent(buttonName, buttonName.GetLength(), textDimension); + textDimension.height = textDimension.height + font.GetDescender(); + TextElement* pTextElement = new (std::nothrow) TextElement(); + pTextElement->Construct(buttonName); + pTextElement->SetTextColor(textColor); + pTextElement->SetFont(font); + + EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText(); + pEnrichedText->Construct(textDimension); + pEnrichedText->Add(*pTextElement); + + //Draw text + Point textPos(((pCanvas->GetBounds().width - pEnrichedText->GetWidth()) / 2), verticalPos); + pCanvas->DrawText(textPos, *pEnrichedText); + + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; +} + +void +CallButtonsPanel::AddKeyPadActionListener(const String& buttonId, CommandIds cmdId) +{ + Button* pButton = static_cast(GetControl(buttonId)); + if (pButton != null) + { + pButton->SetActionId(cmdId); + pButton->AddActionEventListener(*__pActionListener); + } +} + +void +CallButtonsPanel::DisableKeysForOutgoingCall(void) +{ + //add call + EnableAddCallButton(false); + + //keypad + Button* pButton = static_cast(GetControl(IDC_KEYPAD_BUTTON)); + pButton->SetEnabled(false); + + //mute + pButton = static_cast(GetControl(IDC_MUTE_BUTTON)); + pButton->SetEnabled(false); + + //contact + pButton = static_cast(GetControl(IDC_CONTACT_BUTTON)); + pButton->SetEnabled(false); +} + +void +CallButtonsPanel::SetEndCallPanelState(bool isEnabled) +{ + //Voice Call + Button* pButton = static_cast(GetControl(IDC_VOICECALL_BUTTON)); + pButton->SetEnabled(isEnabled); + + //Video Call + pButton = static_cast(GetControl(IDC_VIDEOCALL_BUTTON)); + pButton->SetEnabled(isEnabled); + + //Message + pButton = static_cast(GetControl(IDC_MSG_BUTTON)); + pButton->SetEnabled(isEnabled); +} + +void +CallButtonsPanel::EnableAddCallButton(bool enable) +{ + //add call + Button* pButton = static_cast(GetControl(IDC_ADDJOINCALL_BUTTON)); + if(pButton != null && pButton->GetActionId() == IDA_ADD_CALL) + { + pButton->SetEnabled(enable); + } +} + +void +CallButtonsPanel::SetButtonPosition(void) +{ + switch (__parentFormType) + { + case FORMTYPE_ENDCALL: + { + //Voice Call + Button* pButton = static_cast(GetControl(IDC_VOICECALL_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + + //Video Call + pButton = static_cast(GetControl(IDC_VIDEOCALL_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + + //Message + pButton = static_cast(GetControl(IDC_MSG_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + Label* pLabel = static_cast(GetControl(L"IDC_LABEL1")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL5")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL6")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL7")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL8")); + SetControlAlwaysOnTop(*pLabel,true); + } + break; + + default: + { + //keypad + Button* pButton = static_cast(GetControl(IDC_KEYPAD_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + //mute + pButton = static_cast(GetControl(IDC_MUTE_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + //contact + pButton = static_cast(GetControl(IDC_CONTACT_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + //Add or Join call based on form state + pButton = static_cast(GetControl(IDC_ADDJOINCALL_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + //End call + pButton = static_cast(GetControl(IDC_ENDCALL_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + //Speaker + pButton = static_cast(GetControl(IDC_SPEAKER_BUTTON)); + SetControlAlwaysOnTop(*pButton,true); + Label* pLabel = static_cast(GetControl(L"IDC_LABEL1")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL1")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL2")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL4")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL5")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL6")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL7")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL8")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL9")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL10")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL11")); + SetControlAlwaysOnTop(*pLabel,true); + pLabel = static_cast(GetControl(L"IDC_LABEL12")); + SetControlAlwaysOnTop(*pLabel,true); + + } + break; + } +} diff --git a/src/PhnCallInfo.cpp b/src/PhnCallInfo.cpp new file mode 100644 index 0000000..b713956 --- /dev/null +++ b/src/PhnCallInfo.cpp @@ -0,0 +1,357 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallInfo.cpp + * @brief Call Information class + */ +#include "PhnAppUtility.h" +#include "PhnCallInfo.h" +#include + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Social; + +CallInfo::CallInfo(void) +{ + //by Default, neither a conference call nor emergency call + __isConfCall = false; + __isEmergency = false; + __callType = VOICE_CALL; + __isOnHold = false; + __callConnectTime = 0; + __callNotificationTime = 0; + __pCallHandle = null; + __pEndCallCause = null; + __pParticipantCallHandles = null; + __pContact = null; +} + +CallInfo::~CallInfo(void) +{ + if (__pCallHandle) + { + delete __pCallHandle; + } + + if (__pEndCallCause) + { + delete __pEndCallCause; + } + + if (__pParticipantCallHandles) + { + delete __pParticipantCallHandles; + __pParticipantCallHandles = null; + } + if (__pContact != null) + { + delete __pContact; + } +} + +Long* +CallInfo::GetCallHandle(void) +{ + return __pCallHandle; +} + +void +CallInfo::SetCallHandle(unsigned int handle) +{ + if (__pCallHandle != null) + { + delete __pCallHandle; + } + __pCallHandle = new (std::nothrow) Long(handle); +} + +bool +CallInfo::IsConferenceCall(void) +{ + return __isConfCall; +} + +void +CallInfo::SetConference(bool isConferenceCall) +{ + __isConfCall = isConferenceCall; +} + +bool +CallInfo::IsEmergency(void) +{ + return __isEmergency; +} + +void +CallInfo::SetEmergency(bool isEmergency) +{ + __isEmergency = isEmergency; +} + +String& +CallInfo::GetContactNumber(void) +{ + return __contactNumber; +} + +void +CallInfo::SetContactNumber(String& contactNumber) +{ + if (__isConfCall == false) + { + __contactNumber = contactNumber; + } +} + +void +CallInfo::SetContactInfo(const Contact& contact) +{ + if (__pContact != null) + { + delete __pContact; + __pContact = null; + } + __pContact = new (std::nothrow) Contact(contact); +} + +bool +CallInfo::IsOnHold(void) +{ + return __isOnHold; +} + +void +CallInfo::SetOnHold(bool onHold) +{ + __isOnHold = onHold; +} + +long long +CallInfo::GetCallConnectTime(void) +{ + return __callConnectTime; +} + +void +CallInfo::SetCallConnectTime(long long connectTime) +{ + __callConnectTime = connectTime; +} + +long long +CallInfo::GetCallNotificationTime(void) +{ + return __callNotificationTime; +} + +void +CallInfo::SetCallNotificationTime(long long callNotificationTime) +{ + __callNotificationTime = callNotificationTime; +} + +String& +CallInfo::GetEndCallCause(void) +{ + return *(__pEndCallCause); +} + +void +CallInfo::SetEndCallCause(String& pEndCause) +{ + if (__pEndCallCause != null) + { + delete __pEndCallCause; + } + __pEndCallCause = new (std::nothrow) String(pEndCause); +} + +IListT* +CallInfo::GetCallerList(void) +{ + return __pParticipantCallHandles; +} + +int +CallInfo::GetCallerListCount(void) +{ + if (__pParticipantCallHandles != null) + { + return __pParticipantCallHandles->GetCount(); + } + return -1; +} + +result +CallInfo::AddCallToCallerList(CallInfo& callInfo) +{ + if (__pParticipantCallHandles == NULL) + { + __pParticipantCallHandles = new (std::nothrow) ArrayListT(); + } + result r = E_FAILURE; + CallInfo* pNewCallInfo = new (std::nothrow) CallInfo(); + *pNewCallInfo = callInfo; + r = __pParticipantCallHandles->Add(*pNewCallInfo); + pNewCallInfo = NULL; + return r; +} + +result +CallInfo::RemoveCallFromCallerList(int index) +{ + result r = E_FAILURE; + if (__pParticipantCallHandles == NULL) + { + return r; + } + r = __pParticipantCallHandles->RemoveAt(index); + return r; +} + +void +CallInfo::SetCalllogType(CallLogType callLogType) +{ + __calllogType = callLogType; +} + +CallLogType +CallInfo::GetCalllogType(void) +{ + return __calllogType; +} + +bool +CallInfo::operator ==(const CallInfo& rhs) const +{ + return (this->__pCallHandle->Equals(*(rhs.__pCallHandle))); +} + +bool +CallInfo::operator !=(const CallInfo& rhs) const +{ + return (!(this->__pCallHandle->Equals(*(rhs.__pCallHandle)))); +} + +CallInfo& +CallInfo::operator =(const CallInfo& rhs) +{ + if (this != null) + { + this->__isConfCall = rhs.__isConfCall; + this->__callType = rhs.__callType; + this->__isEmergency = rhs.__isEmergency; + this->__contactNumber = rhs.__contactNumber; + this->__isOnHold = rhs.__isOnHold; + //call connected time + this->__callConnectTime = rhs.__callConnectTime; + //call notification time + this->__callNotificationTime = rhs.__callNotificationTime; + this->__calllogType = rhs.__calllogType; + //copy call handle, if exist + if (this->__pCallHandle != null) + { + delete this->__pCallHandle; + this->__pCallHandle = null; + } + if (rhs.__pCallHandle != null) + { + this->__pCallHandle = new (std::nothrow) Long(*(rhs.__pCallHandle)); + } + + //copy end call cause, if any exist + if (this->__pEndCallCause != null) + { + delete this->__pEndCallCause; + this->__pEndCallCause = null; + } + if (rhs.__pEndCallCause) + { + this->__pEndCallCause = new (std::nothrow) String(*(rhs.__pEndCallCause)); + } + + //Add participant call list + if (this->__pParticipantCallHandles != null) + { + delete this->__pParticipantCallHandles; + this->__pParticipantCallHandles = null; + } + if (rhs.__pParticipantCallHandles != null) + { + this->__pParticipantCallHandles = new (std::nothrow) ArrayListT(); + this->__pParticipantCallHandles->Construct(*(rhs.__pParticipantCallHandles)); + } + if (this->__pContact != null) + { + delete this->__pContact; + this->__pContact = null; + } + if (rhs.__pContact != null) + { + this->__pContact = new (std::nothrow) Contact(*(rhs.__pContact)); + } + } + + return *this; +} + +String* +CallInfo::FetchCallerNameN(void) +{ + String displayName(L""); + + //get caller name from already fetched or newly fetched contact info + if (__pContact != null) + { + //fetch name to be displayed + __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName); + if (displayName.IsEmpty()) + { + String firstName(L""); + String lastName(L""); + __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); + __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); + displayName.Append(firstName + " " + lastName); + } + } + + return new (std::nothrow) String(displayName); +} + +Bitmap* +CallInfo::FetchCallerPhotoN(void) +{ + if (__pContact != null) + { + return __pContact->GetThumbnailN(); + } + return null; +} + +bool +CallInfo::IsNumberPresent(void) +{ + if (__pContact != null) + { + return true; + } + return false; +} diff --git a/src/PhnCallOptionPopup.cpp b/src/PhnCallOptionPopup.cpp new file mode 100644 index 0000000..5543998 --- /dev/null +++ b/src/PhnCallOptionPopup.cpp @@ -0,0 +1,348 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallOptionPopup.cpp + * @brief Call Options Popup class + */ +#include +#include +#include +#include +#include +#include + +#include "PhnCallOptionPopup.h" +#include "PhnAppUtility.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +const int W_POPUP = 620; +const int H_POPUP = 712; +const int W_CANCEL_BUTTON = 400; +const int H_CANCEL_BUTTON = 72; +const int CANCEL_BUTTON_PADDING = 20; +const int H_LIST_ITEM = 112; +const int W_LIST_ITEM = 112; +const int HORIZONTAL_PADDING = 16; +const int VERTICAL_PADDING = 110; +const int IDA_BUTTON_CANCEL_OPTIONS_POPUP = 502; +static const wchar_t* IDL_CALL_OPTION_POPUP = L"IDL_CALL_OPTION_POPUP"; + +CallOptionPopup::CallOptionPopup(IPopupItemSelectListener& listener, CallPresentationModel& callPresenter) + : __pContactList(null) + , __popupListener(listener) + , __callPresenter(callPresenter) +{ + +} + +CallOptionPopup::~CallOptionPopup(void) +{ + if (__pContactList) + { + __pContactList->RemoveAll(); + delete __pContactList; + __pContactList = null; + } +} + +result +CallOptionPopup::Initialize(void) +{ + result r = E_SUCCESS; + r = Construct(IDL_CALL_OPTION_POPUP); + TryReturn(r == E_SUCCESS, r, "CallOptionPopup construction failed"); + + ConstructListData(); + int listHeight = H_LIST_ITEM * __pContactList->GetCount(); + int popupHeight = H_CANCEL_BUTTON + listHeight + CANCEL_BUTTON_PADDING + VERTICAL_PADDING; + r = SetSize(Dimension(W_POPUP + HORIZONTAL_PADDING, popupHeight)); + TryReturn(r == E_SUCCESS, r, "CallOptionPopup::SetSize() failed"); + + String strText; + Application::GetInstance()->GetAppResource()->GetString(L"IDS_CANCEL", strText); + Button* pCancelButton = new (std::nothrow) Button(); + r = pCancelButton->Construct(Rectangle(VERTICAL_PADDING, listHeight + CANCEL_BUTTON_PADDING , W_CANCEL_BUTTON, H_CANCEL_BUTTON), strText); + pCancelButton->SetActionId(IDA_BUTTON_CANCEL_OPTIONS_POPUP); + pCancelButton->AddActionEventListener(*this); + r = AddControl(*pCancelButton); + TryReturn(r == E_SUCCESS, r, "CallOptionPopup::AddControl() failed"); + + ListView* pListView = new (std::nothrow) ListView(); + pListView->Construct(Rectangle(0, 0, W_POPUP - HORIZONTAL_PADDING, listHeight), true, SCROLL_STYLE_FADE_OUT); + pListView->AddListViewItemEventListener(*this); + pListView->SetItemProvider(*this); + r = AddControl(*pListView); + + return r; +} + +void +CallOptionPopup::ConstructListData(void) +{ + ArrayListT* pCallList = static_cast*>(__callPresenter.GetCallListN()); + if (pCallList != null) + { + int callCount = pCallList->GetCount(); + switch (callCount) + { + case 1: + { + //only one call. + CallInfo phnCallInfo; + pCallList->GetAt(0,phnCallInfo); + //show contact number + String contactNo; + contactNo.Append(phnCallInfo.GetContactNumber()); + String* displayName = phnCallInfo.FetchCallerNameN(); + if (displayName->IsEmpty() == true) + { + displayName->Append(contactNo); + } + + __pContactList = new (std::nothrow) ArrayList(); + __pContactList->Construct(2); + if (phnCallInfo.IsConferenceCall() == false) + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION1"); + String* listItem1 = new (std::nothrow) String(); + listItem1->Format(100,optionStr.GetPointer(),displayName->GetPointer());//(L"Putting " + *displayName + L" on hold"); + __pContactList->Add(*listItem1); + optionStr.Clear(); + optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION2"); + String* listItem2 = new (std::nothrow) String(); + listItem2->Append(optionStr + *displayName); + __pContactList->Add(*listItem2); + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION7"); + String* listItem1 = new (std::nothrow) String(); + if (phnCallInfo.IsOnHold() == true) + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION8"); + listItem1->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount()); + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION7"); + listItem1->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount()); + } + __pContactList->Add(*listItem1); + String* listItem2 = new (std::nothrow) String(); + if (phnCallInfo.IsOnHold() == true) + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3"); + listItem2->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount()); + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4"); + listItem2->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount()); + } + __pContactList->Add(*listItem2); + } + + delete displayName; + } + break; + + case 2: + { + //2calls present. active call and held call + CallInfo firstCallInfo; + pCallList->GetAt(0,firstCallInfo); + CallInfo secondCallInfo; + pCallList->GetAt(1,secondCallInfo); + __pContactList = new (std::nothrow) ArrayList(); + __pContactList->Construct(3); + //show contact number + String contactNo; + contactNo.Append(firstCallInfo.GetContactNumber()); + String* displayName = firstCallInfo.FetchCallerNameN(); + if (displayName->IsEmpty() == true) + { + displayName->Append(contactNo); + } + String* listItem1 = new (std::nothrow) String(); + if (firstCallInfo.IsConferenceCall() == true) + { + if (firstCallInfo.IsOnHold() == true) + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3"); + listItem1->Format(100, optionStr.GetPointer(),firstCallInfo.GetCallerListCount()); + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4"); + listItem1->Format(100, optionStr.GetPointer(),firstCallInfo.GetCallerListCount()); + } + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION5"); + listItem1->Append(optionStr + *displayName ); + } + delete displayName; + contactNo.Clear(); + contactNo.Append(secondCallInfo.GetContactNumber()); + displayName = secondCallInfo.FetchCallerNameN(); + if (displayName->IsEmpty() == true) + { + displayName->Append(contactNo); + } + String* listItem2 = new (std::nothrow) String(); + if (secondCallInfo.IsConferenceCall() == true) + { + String callCountStr; + callCountStr.Append(secondCallInfo.GetCallerListCount()); + + if (secondCallInfo.IsOnHold() == true) + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3"); + listItem2->Format(100, optionStr.GetPointer(),secondCallInfo.GetCallerListCount()); + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4"); + listItem2->Format(100, optionStr.GetPointer(),secondCallInfo.GetCallerListCount()); + } + } + else + { + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION5"); + listItem2->Append(optionStr + *displayName ); + } + if (firstCallInfo.IsOnHold() == true) + { + __pContactList->Add(*listItem2); + __pContactList->Add(*listItem1); + } + else + { + __pContactList->Add(*listItem1); + __pContactList->Add(*listItem2); + } + String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION6"); + String* listItem3 = new (std::nothrow) String(); + listItem3->Append(optionStr); + __pContactList->Add(*listItem3); + delete displayName; + } + break; + + default: + break; + } + pCallList->RemoveAll(); + delete pCallList; + } +} + +void +CallOptionPopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status) +{ + Popup::SetShowState(false); + __popupListener.OnItemSelected(elementId); + return; +} + +void +CallOptionPopup::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction) +{ + return; +} + +void +CallOptionPopup::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListContextItemStatus state) +{ + return; +} + +void +CallOptionPopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + bool& invokeListViewItemCallback) +{ + return; +} + +int +CallOptionPopup::GetItemCount(void) +{ + if (__pContactList != null) + { + return __pContactList->GetCount(); + } + return 0; +} + +Tizen::Ui::Controls::ListItemBase* +CallOptionPopup::CreateItem(int index, int itemWidth) +{ + int elementId = 0; + String* strText = static_cast(__pContactList->GetAt(index)); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + CustomItem* pItem = new CustomItem(); + pItem->Construct(Dimension(itemWidth, W_LIST_ITEM), style); + if (__pContactList->GetCount() == 2) + { + elementId = ID_SECOND_INCOMING_CALL + index; + } + else + { + elementId = ID_MULTI_PARTY_CALL + index; + } + pItem->AddElement(Rectangle(HORIZONTAL_PADDING, 0, W_POPUP - HORIZONTAL_PADDING, H_LIST_ITEM), elementId, *strText); + return pItem; +} + +bool +CallOptionPopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + + +void +CallOptionPopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch (actionId) + { + case IDA_BUTTON_CANCEL_OPTIONS_POPUP: + { + Popup::SetShowState(false); + __popupListener.OnItemSelected(IDA_BUTTON_CANCEL_OPTIONS_POPUP); + } + break; + + default: + break; + } +} diff --git a/src/PhnCallPresentationModel.cpp b/src/PhnCallPresentationModel.cpp new file mode 100644 index 0000000..ae84fab --- /dev/null +++ b/src/PhnCallPresentationModel.cpp @@ -0,0 +1,584 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallPresentationModel.cpp + * @brief Call Presentation model class + */ +#include +#include +#include +#include "PhnPhoneApp.h" +#include "PhnActiveCallForm.h" +#include "PhnCallInfo.h" +#include "PhnCallPresentationModel.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnConfCallerListForm.h" +#include "PhnTelephonyManager.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Social; +using namespace Tizen::Ui::Scenes; + +CallPresentationModel* CallPresentationModel::__pInstance = null; + +CallPresentationModel::CallPresentationModel(void) +{ + __pTelephonyMgr = null; + __pTelEventListener = null; + __pSettingsPresentor = null; + __isMessageAppControlRunning = false; +} + +CallPresentationModel::~CallPresentationModel(void) +{ + __pTelephonyMgr = null; + __pSettingsPresentor = null; +} + +void +CallPresentationModel::CreateInstance(void) +{ + __pInstance = new (std::nothrow) CallPresentationModel(); + result r = __pInstance->Construct(); + if(IsFailed(r)) + { + delete __pInstance; + __pInstance = null; + return; + } + + std::atexit(DestroyInstance); +} + +CallPresentationModel* +CallPresentationModel::GetInstance(void) +{ + if (__pInstance == null) + { + CreateInstance(); + } + return __pInstance; +} + +void +CallPresentationModel::DestroyInstance(void) +{ + if (__pInstance != null) + { + delete __pInstance; + __pInstance = null; + } +} + +result +CallPresentationModel::Construct(void) +{ + //Fetch Telephony Manager + __pTelephonyMgr = TelephonyManager::GetInstance(this); + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + return E_SUCCESS; +} + +void +CallPresentationModel::SetTelEventListener(ITelephonyEventListener* pTelEventListener) +{ + //set form as telephony event listener + __pTelEventListener = pTelEventListener; +} + +void +CallPresentationModel::DialCall(String& contactNumber, bool isEmergency) +{ + int errorCode = ERROR_NONE; + //Check if Telephony Manager is initialized + TryCatch(__pTelephonyMgr != null, (errorCode = ERROR_TAPI_INIT_FAILED), "TAPI initialization failed"); + + //setup outgoing call + errorCode = __pTelephonyMgr->SetupMoCall(contactNumber, isEmergency); + TryCatch(errorCode == ERROR_NONE,,"Error occurred while setup MO call"); + if(__pSettingsPresentor != null) + { + __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING); + } + return; + +CATCH: + __pTelEventListener->HandleTelephonyError(errorCode); +} + +void +CallPresentationModel::EndCall(Long callHandle) +{ + if(__pTelephonyMgr != null) + { + __pTelephonyMgr->EndCall(callHandle); + } +} + +void +CallPresentationModel::EndCall(String& contactNumber) +{ + if(__pTelephonyMgr != null) + { + __pTelephonyMgr->EndCall(contactNumber); + } +} + +bool +CallPresentationModel::EndConferenceCall(void) +{ + result r = __pTelephonyMgr->EndConferenceCall(); + if (IsFailed(r)) + { + //TODO: send proper error code + __pTelEventListener->HandleTelephonyError(ERROR_GENERAL); + return false; + } + return true; +} + +bool +CallPresentationModel::HoldCall(Tizen::Base::Long callHandle) +{ + result r = __pTelephonyMgr->HoldCall(callHandle, true); + return (!IsFailed(r)); +} + +bool +CallPresentationModel::UnHoldCall(Tizen::Base::Long callHandle) +{ + result r = __pTelephonyMgr->HoldCall(callHandle, false); + return (!IsFailed(r)); +} + +bool +CallPresentationModel::HoldConferenceCall(void) +{ + result r = __pTelephonyMgr->HoldConferenceCall(true); + return (!IsFailed(r)); +} + +bool +CallPresentationModel::ActivateConferenceCall(void) +{ + result r = __pTelephonyMgr->HoldConferenceCall(false); + return (!IsFailed(r)); +} + +void +CallPresentationModel::JoinCall(void) +{ + result r = __pTelephonyMgr->JoinCall(); + if (IsFailed(r)) + { + __pTelEventListener->HandleTelephonyError(ERROR_JOIN_FAILED); + } +} + +void +CallPresentationModel::SwapCalls(void) +{ + result r = __pTelephonyMgr->SwapCalls(); + if (IsFailed(r)) + { + __pTelEventListener->HandleTelephonyError(ERROR_SWAP_FAILED); + } +} + +bool +CallPresentationModel::SetMuteStatus(bool setMute) +{ + result r = __pTelephonyMgr->SetMuteStatus(setMute); + return (!IsFailed(r)); +} + +bool +CallPresentationModel::IsCallMuted(void) +{ + return __pTelephonyMgr->IsCallMuted(); +} + +bool +CallPresentationModel::SetSpeakerStatus(bool setSpeaker) +{ + result r = __pTelephonyMgr->SetSpeakerStatus(setSpeaker); + return (!IsFailed(r)); +} + +bool +CallPresentationModel::IsSpeakerOn(void) +{ + return __pTelephonyMgr->IsSpeakerOn(); +} +void +CallPresentationModel::SendDTMFSignal(String& textToBeSent) +{ + __pTelephonyMgr->SendCallDTMF(textToBeSent); +} + +CallInfo* +CallPresentationModel::GetConferenceCallInfoN(void) +{ + return __pTelephonyMgr->GetConferenceCallInfoN(); +} + +void +CallPresentationModel::SplitFromConference(SplitConfCallerCmdIds splitCallerCmdId, IListT* pConfCallList) +{ + int callIndex = -1; + CallInfo callToBeSpli; + switch (splitCallerCmdId) + { + case IDA_SPLIT_CALLER1: + callIndex = 0; + break; + + case IDA_SPLIT_CALLER2: + callIndex = 1; + break; + + case IDA_SPLIT_CALLER3: + callIndex = 2; + break; + + case IDA_SPLIT_CALLER4: + callIndex = 3; + break; + + case IDA_SPLIT_CALLER5: + callIndex = 4; + break; + + default: + break; + } + + result r = pConfCallList->GetAt(callIndex, callToBeSpli); + TryCatch(r == E_SUCCESS,,"conf. call list corrupted"); + //split single call from conference + r = __pTelephonyMgr->SplitFromConference(callToBeSpli.GetCallHandle()->ToLong()); + TryCatch(r == E_SUCCESS,,"Split from conf. call failed"); + return; + +CATCH: + __pTelEventListener->HandleTelephonyError(ERROR_SPLIT_FROM_CONFERENCE_FAILED); + return; +} + +void +CallPresentationModel::EndCallFromConference(EndConfCallerCmdIds endCallerCmdId, IListT* pConfCallList) +{ + int callIndex = -1; + CallInfo callToBeEnded; + switch (endCallerCmdId) + { + case IDA_END_CALLER1: + callIndex = 0; + break; + + case IDA_END_CALLER2: + callIndex = 1; + break; + + case IDA_END_CALLER3: + callIndex = 2; + break; + + case IDA_END_CALLER4: + callIndex = 3; + break; + + case IDA_END_CALLER5: + callIndex = 4; + break; + + default: + break; + } + + result r = pConfCallList->GetAt(callIndex, callToBeEnded); + TryCatch(r == E_SUCCESS,,"conference call list corrupted"); + //end single call + r = __pTelephonyMgr->EndFromConference(callToBeEnded.GetCallHandle()->ToLong()); + TryCatch(r == E_SUCCESS,,"End single call from conference call failed"); + + return; + +CATCH: + __pTelEventListener->HandleTelephonyError(ERROR_END_CALL_FAILED); + return; +} + +bool +CallPresentationModel::IsSplitAllowed(void) +{ + return __pTelephonyMgr->IsSplitAllowed(); +} + +void +CallPresentationModel::AcceptIncomingCall(CallAnswerOptions answerOptions,int callHandle) +{ + result r = E_FAILURE; + if (answerOptions == CALL_ANSWER_CALL) + { + r = __pTelephonyMgr->AnswerCall(callHandle, true); + } + else + { + r = __pTelephonyMgr->AcceptCall(answerOptions,callHandle); + } + if (IsFailed(r)) + { + __pTelEventListener->HandleTelephonyError(ERROR_GENERAL); + } +} + +IListT* +CallPresentationModel::GetCallListN(void) +{ + return __pTelephonyMgr->GetCallListN(); +} + + +bool +CallPresentationModel::RejectCall(int callHandle, bool sendMsg, const String& contactNumber) +{ + result r = __pTelephonyMgr->AnswerCall(callHandle, false); + if (IsFailed(r)) + { + __pTelEventListener->HandleTelephonyError(ERROR_GENERAL); + return false; + } + + if (sendMsg == true) + { + //launch message + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE)); + extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(contactNumber)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + __isMessageAppControlRunning = true; + delete pAc; + } + + extraData.RemoveAll(true); + } + return true; +} + +void +CallPresentationModel::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + if (__isMessageAppControlRunning == true) + { + //This comes here, when Message AppControl is finished working. + __isMessageAppControlRunning = false; + //Check if this was the last call, then terminate application. + //And if any calls are active, then those cases are already handled from Other places. + if( GetCurrentCallCount() == 0) + { + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + SceneManager* pSceneManager = SceneManager::GetInstance(); + SceneId startingScene = pPhoneApp->GetInitialScene(); + //No more calls are active + if (startingScene == IDSCN_DIALER || startingScene == IDSCN_CALL_LOG) + { + pSceneManager->GoForward( ForwardSceneTransition(startingScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + else + { + pPhoneApp->Terminate(); + } + } + } +} + +int +CallPresentationModel::GetCurrentCallCount(void) +{ + return __pTelephonyMgr->GetCurrentCallCount(); +} + +bool +CallPresentationModel::CheckSimInitializationIsCompleted() +{ + result r = E_FAILURE; + if(__pTelephonyMgr != null) + { + r = __pTelephonyMgr->CheckIfMOCallIsPossible(); + } + return (!IsFailed(r)); +} + +bool +CallPresentationModel::IsEmergencyNumber(const Tizen::Base::String& phoneNumber, bool isSimInitialized) +{ + return __pTelephonyMgr->CheckIfMOCallIsEmergency(phoneNumber, isSimInitialized); +} + +void +CallPresentationModel::StartAlert(CallInfo& incomingCallInfo) +{ + __pTelephonyMgr->StartAlert(incomingCallInfo); +} + +void +CallPresentationModel::StopAlert(void) +{ + __pTelephonyMgr->StopAlert(); +} + +Contact* +CallPresentationModel::GetContactN(const String& phoneNumber) +{ + return __pTelephonyMgr->GetContactN(phoneNumber); +} + +CallInfo* +CallPresentationModel::FetchIncomingCallDetailsN(const String& callHandle, const String& contactNumber) +{ + //Adding incoming call sate setting here + if(__pSettingsPresentor != null) + { + __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING); + } + return __pTelephonyMgr->FetchIncomingCallHandleN(callHandle, contactNumber); +} + +bool +CallPresentationModel::CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo) +{ + return __pTelephonyMgr->CheckIncomingCallToBeRejected(pIncomingCallInfo); +} + +///////////////////////////////////////////////////////////////// +///// Event Listener methods from ITelephonyEventListener ///// +///////////////////////////////////////////////////////////////// +void +CallPresentationModel::HandleCallConnected(Tizen::Base::Collection::IListT& pCallList) +{ + if (__pTelEventListener != null) + { + __pTelEventListener->HandleCallConnected(pCallList); + } + if(__pSettingsPresentor != null) + { + __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE); + } +} + +void +CallPresentationModel::HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT& pCallList) +{ + if (isLastCall == true) + { + SetSpeakerStatus(false); + SetMuteStatus(false); + if(__pSettingsPresentor != null) + { + __pSettingsPresentor->SetCallState(CALL_STATE__CALL_OFF); + } + } + //Defer from sending call disconnected event to form, in case Msg AppControl is running, + //to avoid PhoneApp from going to EndCall form, where it shows for 3 sec. and automatically closes. + if (__pTelEventListener != null && __isMessageAppControlRunning == false) + { + __pTelEventListener->HandleCallDisconnected(isLastCall, pCallList); + } + +} + +void +CallPresentationModel::HandleConferenceCall(CallInfo& pCallInfo) +{ + if (__pTelEventListener != null) + { + __pTelEventListener->HandleConferenceCall(pCallInfo); + } +} + +void +CallPresentationModel::HandleIncomingCall(CallInfo& pCallInfo) +{ + StartAlert(pCallInfo); + if (__pTelEventListener != null) + { + __pTelEventListener->HandleIncomingCall(pCallInfo); + } + else + { + //as base form not created. So no listener set. + SceneManager* pSceneManager = SceneManager::GetInstance(); + + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(1); + + //update list to be passed + CallInfo* pIncomingCall = new (std::nothrow) CallInfo(); + *pIncomingCall = pCallInfo; + pCallInfoList->Add(pIncomingCall); + + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList); + } + if(__pSettingsPresentor != null) + { + __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING); + } +} + +void +CallPresentationModel::HandleCallSwapOccured(Tizen::Base::Collection::IListT& pCallList) +{ + if (__pTelEventListener != null) + { + __pTelEventListener->HandleCallSwapOccured(pCallList); + } +} + +void +CallPresentationModel::HandleConferenceChange(void) +{ + if (__pTelEventListener != null) + { + __pTelEventListener->HandleConferenceChange(); + } +} + +void +CallPresentationModel::HandleTelephonyError(int errorCode) +{ + if (__pTelEventListener != null) + { + __pTelEventListener->HandleTelephonyError(errorCode); + } +} + diff --git a/src/PhnCallRejectInfo.cpp b/src/PhnCallRejectInfo.cpp new file mode 100644 index 0000000..7e820da --- /dev/null +++ b/src/PhnCallRejectInfo.cpp @@ -0,0 +1,69 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallRejectInfo.cpp + * @brief Call Reject info class + */ +#include "PhnCallRejectInfo.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +CallRejectInfo::CallRejectInfo(void) +{ +} + +CallRejectInfo::~CallRejectInfo(void) +{ +} + +bool +CallRejectInfo::operator ==(const CallRejectInfo& rhs) const +{ + /*return (this->rowId == rhs.rowId);*/ + if ((this->phoneNumber == rhs.phoneNumber) + && (this->rejectCondition == rhs.rejectCondition)) + { + return true; + } + return false; +} + +bool +CallRejectInfo::operator !=(const CallRejectInfo& rhs) const +{ + /*return (!(this->rowId == rhs.rowId));*/ + if ((this->phoneNumber == rhs.phoneNumber) + && (this->rejectCondition == rhs.rejectCondition)) + { + return false; + } + return true; +} + +CallRejectInfo& +CallRejectInfo::operator =(const CallRejectInfo& rhs) +{ + if (this != null) + { + this->rowId = rhs.rowId; + this->phoneNumber.Append(rhs.phoneNumber); + this->rejectCondition = rhs.rejectCondition; + this->isActivated = rhs.isActivated; + } + return *this; +} diff --git a/src/PhnCallSettingDataService.cpp b/src/PhnCallSettingDataService.cpp new file mode 100644 index 0000000..4a46972 --- /dev/null +++ b/src/PhnCallSettingDataService.cpp @@ -0,0 +1,819 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCallSettingDataService.cpp + * @brief Call Database class + */ + +#include +#include +#include +#include "PhnCallSettingDataService.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::App; +using namespace Tizen::Social; + +CallSettingDataService* CallSettingDataService::__pCallSettingDataService = null; +Database* CallSettingDataService::__pDatabase = null; + +CallSettingDataService::CallSettingDataService(void) +: __strDbName(App::GetInstance()->GetAppRootPath() + L"data/CallRejectInfoListDataBase") +{ + __pStmt = null; + __pEnum = null; + + return; +} + +CallSettingDataService::~CallSettingDataService(void) +{ + if (__pDatabase != null) + { + delete __pDatabase; + __pDatabase = null; + } + __pCallSettingDataService = null; + return; +} + +CallSettingDataService* +CallSettingDataService::CreateInstance(void) +{ + if (__pCallSettingDataService == null) + { + __pCallSettingDataService = new (std::nothrow) CallSettingDataService(); + } + return __pCallSettingDataService; +} +result +CallSettingDataService::OpenDatabase(void) +{ + result r = E_SUCCESS; + + // create the database if it doesn't exist + if (__pDatabase != null) + { + return E_OBJ_ALREADY_EXIST; + } + __pDatabase = new (std::nothrow) Database(); + r = __pDatabase->Construct(__strDbName, true); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::OpenDatabase() database construct failed"); + + r = CreateCallRejectTableDatabase(); + // TryCatch(r == E_SUCCESS, , "CallSettingDataService::OpenDatabase() call reject Create Table failed"); + r = CreateSpeedDialTableDatabase(); + // TryCatch(r == E_SUCCESS, , "CallSettingDataService::OpenDatabase() speed dial Create Table failed"); + + return r; + + CATCH: + delete __pDatabase; + __pDatabase = null; + return r; +} + +result +CallSettingDataService::CreateCallRejectTableDatabase(void) +{ + String sqlQuery; + result r = E_SUCCESS; + + sqlQuery.Append(L"CREATE TABLE IF NOT EXISTS CallRejectInfoTable(id INTEGER PRIMARY KEY AUTOINCREMENT,phonenumber TEXT,rejectcondition INT,activated INT)"); + + r = __pDatabase->ExecuteSql(sqlQuery, true); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::CreateCallRejectInfoTableDatabase() Create Table failed"); + + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::CreateSpeedDialTableDatabase(void) +{ + String sqlQuery; + result r = E_SUCCESS; + + sqlQuery.Append(L"CREATE TABLE IF NOT EXISTS SpeedDialTable(id INTEGER PRIMARY KEY AUTOINCREMENT,contactInfo TEXT,keyMappedTo INT)"); + + r = __pDatabase->ExecuteSql(sqlQuery, true); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::CreateCallRejectInfoTableDatabase() Create Table failed"); + + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::CloseDatabase(void) +{ + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pDatabase != null) + { + delete __pDatabase; + __pDatabase = null; + } + + return E_SUCCESS; +} + +result +CallSettingDataService::AddCallRejectInfoToDatabase(CallRejectInfo* pNewItem) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_FAILURE; + + TryCatch(pNewItem != null, , "CallSettingDataService::AddCallRejectInfoToDatabase() no item to add"); + + __pDatabase->BeginTransaction(); + + statement.Append(L"INSERT INTO CallRejectInfoTable(phonenumber,rejectcondition,activated) VALUES (?,?,?)"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddCallRejectInfoToDatabase() CreateStatementN failed"); + if (__pStmt != null) + { + r = __pStmt->BindString(0, pNewItem->phoneNumber); + __pStmt->BindInt(1, pNewItem->rejectCondition); + __pStmt->BindInt(2, pNewItem->isActivated); + + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddCallRejectInfoToDatabase() Add CallRejectInfo to DB failed"); + + r = __pDatabase->CommitTransaction(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddCallRejectInfoToDatabase() CommitTransaction to DB failed"); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::DeleteCallRejectInfoListFromDatabase(ArrayList* pIndexArray) +{ + result r = E_SUCCESS; + IEnumerator* pEnum = null; + Integer* index; + + TryCatch(pIndexArray != null, , "CallSettingDataService::DeleteCallRejectInfoListFromDatabase() no item to delete"); + + pEnum = pIndexArray->GetEnumeratorN(); + index = null; + if (pEnum != null) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + index = static_cast(pEnum->GetCurrent()); + r = DeleteCallRejectInfoFromDatabase(index->ToInt()); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddCallRejectInfoToDatabase() Add CallRejectInfo to DB failed"); + } + delete pEnum; + pEnum = null; + } + + if (pIndexArray != null) + { + pIndexArray->RemoveAll(true); + delete pIndexArray; + pIndexArray = null; + } + return r; + + CATCH: + if (pEnum != null) + { + delete pEnum; + pEnum = null; + } + if (pIndexArray != null) + { + pIndexArray->RemoveAll(true); + delete pIndexArray; + pIndexArray = null; + } + return r; +} + +result +CallSettingDataService::DeleteCallRejectInfoFromDatabase(int aIndex) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + + __pDatabase->BeginTransaction(); + + statement.Append(L"DELETE FROM CallRejectInfoTable WHERE id = ?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::DeleteCallRejectInfoFromDatabase CreateStatementN failed"); + if (__pStmt != null) + { + __pStmt->BindInt(0, aIndex); + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::DeleteCallRejectInfoFromDatabase Delete CallRejectInfo from DB failed"); + + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::UpdateCallRejectInfoDatabase(int aIndex, CallRejectInfo* pCallInfoItem) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + + TryCatch(pCallInfoItem != null, , "CallSettingDataService::UpdateCallRejectInfoDatabase() no item to update"); + + __pDatabase->BeginTransaction(); + + statement.Append(L"UPDATE CallRejectInfoTable SET phonenumber=?,rejectcondition=?,activated=? WHERE id=?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::UpdateCallRejectInfoDatabase CreateStatementN failed"); + if (__pStmt != null) + { + r = __pStmt->BindString(0, pCallInfoItem->phoneNumber); + __pStmt->BindInt(1, pCallInfoItem->rejectCondition); + __pStmt->BindInt(2, pCallInfoItem->isActivated); + __pStmt->BindInt(3, aIndex); + + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::UpdateCallRejectInfoDatabase Update CallRejectInfo in DB failed"); + + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::GetCallRejectInfoFromDatabase(int aIndex, CallRejectInfo& dbItem) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + __pDatabase->BeginTransaction(); + statement.Append(L"SELECT id,phonenumber,rejectcondition,activated FROM CallRejectInfoTable WHERE id=?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetCallRejectInfoFromDatabase CreateStatementN failed"); + + __pStmt->BindInt(0, aIndex); + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetCallRejectInfoFromDatabase Get CallRejectInfo from DB failed"); + + if (__pEnum != null) + { + int activateflag; + int rejectCondition; + __pEnum->GetIntAt(0, dbItem.rowId); + __pEnum->GetStringAt(1, dbItem.phoneNumber); + __pEnum->GetIntAt(2, rejectCondition); + __pEnum->GetIntAt(3, activateflag); + dbItem.rejectCondition = (CallRejectMatchCondition)rejectCondition; + dbItem.isActivated = (bool)activateflag; + } + __pDatabase->CommitTransaction(); + + + delete __pStmt; + __pStmt = NULL; + + if (__pEnum != null) + { + delete __pEnum; + __pEnum = NULL; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::GetAllCallRejectInfoFromDatabaseN(ArrayListT& callRejectInfoList) +{ + String sql; + __pEnum = null; + result r = E_SUCCESS; + __pDatabase->BeginTransaction(); + + sql.Append(L"SELECT id,phonenumber,rejectcondition,activated from CallRejectInfoTable"); + __pEnum = __pDatabase->QueryN(sql); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetAllCallRejectInfoFromDatabase Get CallRejectInfo from DB failed"); + + //check if the query returned any result and then iterate through the results + if (__pEnum != null) + { + while (__pEnum->MoveNext() == E_SUCCESS) + { + CallRejectInfo* pCallRejectInfoItem = new (std::nothrow) CallRejectInfo; + int activateflag; + int rejectCondition; + __pEnum->GetIntAt(0, pCallRejectInfoItem->rowId); + __pEnum->GetStringAt(1, pCallRejectInfoItem->phoneNumber); + __pEnum->GetIntAt(2, rejectCondition); + __pEnum->GetIntAt(3, activateflag); + pCallRejectInfoItem->rejectCondition = (CallRejectMatchCondition)rejectCondition; + pCallRejectInfoItem->isActivated = (bool)activateflag; + callRejectInfoList.Add(*pCallRejectInfoItem); + } + } + __pDatabase->CommitTransaction(); + if (__pEnum != null) + { + delete __pEnum; + __pEnum = NULL; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::GetCallRejectCount(int& count) +{ + String statement; + result r = E_SUCCESS; + __pStmt = null; + __pEnum = null; + + __pDatabase->BeginTransaction(); + statement.Append(L"SELECT COUNT (*) FROM CallRejectInfoTable"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetCount CreateStatementN failed"); + if (__pStmt != null) + { + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetCount Count from DB failed"); + + if (__pEnum != null) + { + r = __pEnum->MoveNext(); + __pEnum->GetIntAt(0, count); + } + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = NULL; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = NULL; + } + return r; + + CATCH: + return r; +} + +bool +CallSettingDataService::IsCallToBeRejected(String& phoneNumber) +{ + bool isCallToBeRejected = false; + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + __pDatabase->BeginTransaction(); + + //statement.Append(L"SELECT * FROM CallRejectInfoTable WHERE phonenumber LIKE ?"); + statement.Append(L"SELECT * FROM CallRejectInfoTable WHERE activated=?"); + + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::SearchFromDataBase CreateStatementN failed"); + + //__pStmt->BindString(0, phoneNumber); + if (__pStmt != null) + { + __pStmt->BindInt(0,(int)true); + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::SearchFromDataBaseN search failed"); + + //check if the query returned any result and then iterate through the results + if (__pEnum != null) + { + while (__pEnum->MoveNext() == E_SUCCESS) + { + CallRejectInfo* pCallRejectInfoItem = new (std::nothrow) CallRejectInfo; + int activateflag; + int rejectCondition; + __pEnum->GetIntAt(0, pCallRejectInfoItem->rowId); + __pEnum->GetStringAt(1, pCallRejectInfoItem->phoneNumber); + __pEnum->GetIntAt(2, rejectCondition); + __pEnum->GetIntAt(3, activateflag); + pCallRejectInfoItem->rejectCondition = (CallRejectMatchCondition)rejectCondition; + pCallRejectInfoItem->isActivated = (bool)activateflag; + if (CheckRejectCondition(phoneNumber, *pCallRejectInfoItem) == true) + { + delete pCallRejectInfoItem; + isCallToBeRejected = true; + break; + } + delete pCallRejectInfoItem; + } + } + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = NULL; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = NULL; + } + return isCallToBeRejected; + + CATCH: + return isCallToBeRejected; +} + +bool +CallSettingDataService::CheckRejectCondition(String& phoneNumber, CallRejectInfo& callRejectInfo) +{ + bool isCallToBeRejected = false; + switch (callRejectInfo.rejectCondition) + { + case CALL_REJECT_MATCH_EXACTLY: + { + if (callRejectInfo.phoneNumber.CompareTo(phoneNumber) == 0) + { + isCallToBeRejected = true; + } + } + break; + case CALL_REJECT_MATCH_START: + { + isCallToBeRejected = phoneNumber.StartsWith(callRejectInfo.phoneNumber, 0); + } + break; + case CALL_REJECT_MATCH_END: + { + isCallToBeRejected = phoneNumber.EndsWith(callRejectInfo.phoneNumber); + } + break; + case CALL_REJECT_MATCH_INCLUDE: + { + isCallToBeRejected = phoneNumber.Contains(callRejectInfo.phoneNumber); + } + break; + default: + break; + } + + return isCallToBeRejected; +} +result +CallSettingDataService::AddSpeedDialInfoToDatabase(SpeedDialInfo* pNewItem) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_FAILURE; + + TryCatch(pNewItem != null, , "CallSettingDataService::AddSpeedDialInfoToDatabase() no item to add"); + + __pDatabase->BeginTransaction(); + + statement.Append(L"INSERT INTO SpeedDialTable(contactInfo,keyMappedTo) VALUES (?,?)"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddSpeedDialInfoToDatabase() CreateStatementN failed"); + if (__pStmt != null) + { + r = __pStmt->BindString(0, pNewItem->contactId); + __pStmt->BindInt(1, pNewItem->keyMapping); + + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddSpeedDialInfoToDatabase() Add SpeedDialInfo to DB failed"); + + r = __pDatabase->CommitTransaction(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::AddSpeedDialInfoToDatabase() CommitTransaction to DB failed"); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::DeleteSpeedDialInfoFromDatabase(int aIndex) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + + __pDatabase->BeginTransaction(); + + statement.Append(L"DELETE FROM SpeedDialTable WHERE id = ?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::DeleteSpeedDialInfoFromDatabase CreateStatementN failed"); + if (__pStmt != null) + { + __pStmt->BindInt(0, aIndex); + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::DeleteSpeedDialInfoFromDatabase Delete SpeedDialInfo from DB failed"); + + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +result +CallSettingDataService::UpdateSpeedDialInfoDatabase(int aIndex, SpeedDialInfo* pSpeedDialInfoItem) +{ + String statement; + __pStmt = null; + __pEnum = null; + result r = E_SUCCESS; + + TryCatch(pSpeedDialInfoItem != null, , "CallSettingDataService::UpdateSpeedDialInfoDatabase() no item to update"); + + __pDatabase->BeginTransaction(); + + statement.Append(L"UPDATE SpeedDialTable SET contactInfo=?,keyMappedTo=? WHERE id=?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::UpdateSpeedDialInfoDatabase CreateStatementN failed"); + if (__pStmt != null) + { + r = __pStmt->BindString(0, pSpeedDialInfoItem->contactId); + __pStmt->BindInt(1, pSpeedDialInfoItem->keyMapping); + __pStmt->BindInt(2, aIndex); + + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::UpdateSpeedDialInfoDatabase Update SpeedDialInfo in DB failed"); + + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return r; + + CATCH: + return r; +} + +IMapT* +CallSettingDataService::GetAllSpeedDialInfoMapFromDatabaseN(void) +{ + String sql; + __pEnum = null; + result r = E_SUCCESS; + HashMapT* pSpeedDialInfoList = null; + r = __pDatabase->BeginTransaction(); + + sql.Append(L"SELECT id,contactInfo,keyMappedTo from SpeedDialTable"); + __pEnum = __pDatabase->QueryN(sql); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "CallSettingDataService::GetAllSpeedDialInfoFromDatabase Get SpeedDialInfo from DB failed"); + + //check if the query returned any result and then iterate through the results + if (__pEnum != null) + { + pSpeedDialInfoList = new (std::nothrow) HashMapT(); + pSpeedDialInfoList->Construct(10); + while (__pEnum->MoveNext() == E_SUCCESS) + { + SpeedDialInfo* pSpeedDialInfoItem = new (std::nothrow) SpeedDialInfo(); + int keyMappedTo;; + __pEnum->GetIntAt(0, pSpeedDialInfoItem->rowId); + __pEnum->GetStringAt(1, pSpeedDialInfoItem->contactId); + __pEnum->GetIntAt(2, keyMappedTo); + pSpeedDialInfoItem->keyMapping = keyMappedTo; + pSpeedDialInfoList->Add(keyMappedTo ,*pSpeedDialInfoItem); + } + } + + __pDatabase->CommitTransaction(); + + if (__pEnum != null) + { + delete __pEnum; + __pEnum = NULL; + } + SyncWithCurrentAddressbookStatus(pSpeedDialInfoList); + return pSpeedDialInfoList; + + CATCH: + return pSpeedDialInfoList; +} + +void +CallSettingDataService::SyncWithCurrentAddressbookStatus(HashMapT* pSpeedDialInfoList) +{ + AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); + Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); + + if(pAddressbook == null || pSpeedDialInfoList == null) + { + return; + } + + IListT* pSpeedDialList = pSpeedDialInfoList->GetValuesN(); + IEnumeratorT *pSpeedDialListEnum = pSpeedDialList->GetEnumeratorN(); + while(pSpeedDialListEnum->MoveNext() == E_SUCCESS) + { + SpeedDialInfo speeDialInfo; + RecordId recordId = INVALID_RECORD_ID; + pSpeedDialListEnum->GetCurrent(speeDialInfo); + Integer::Parse(speeDialInfo.contactId, recordId); + + Contact* pMappedContact = pAddressbook->GetContactN(recordId); + if(pMappedContact == null) + { + DeleteSpeedDialInfoFromDatabase(speeDialInfo.rowId); + pSpeedDialInfoList->Remove(speeDialInfo.keyMapping); + } + else + { + delete pMappedContact; + } + } + delete pAddressbook; + delete pSpeedDialListEnum; + delete pSpeedDialList; + +} + +String* +CallSettingDataService::GetSpeedDialContactN(int aIndex) +{ + result r = E_SUCCESS; + String statement; + __pStmt = null; + __pEnum = null; + String* fetchedInfo = null; + + __pDatabase->BeginTransaction(); + + statement.Append(L"SELECT contactInfo from SpeedDialTable WHERE keyMappedTo=?"); + __pStmt = __pDatabase->CreateStatementN(statement); + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "GetSpeedDialInfoN - CreateStatementN failed"); + if (__pStmt != null) + { + __pStmt->BindInt(0, aIndex); + + __pEnum = __pDatabase->ExecuteStatementN(*__pStmt); + } + r = GetLastResult(); + TryCatch(r == E_SUCCESS, , "GetSpeedDialInfoN - ExecuteStatementN failed"); + + //check if the query returned any result and then iterate through the results + if (__pEnum != null && __pEnum->MoveNext() == E_SUCCESS) + { + String contact; + __pEnum->GetStringAt(0, contact); + fetchedInfo = new (std::nothrow) String(contact); + } + + __pDatabase->CommitTransaction(); + + if (__pStmt != null) + { + delete __pStmt; + __pStmt = null; + } + if (__pEnum != null) + { + delete __pEnum; + __pEnum = null; + } + return fetchedInfo; + + CATCH: + return fetchedInfo; +} diff --git a/src/PhnCalllogManager.cpp b/src/PhnCalllogManager.cpp new file mode 100644 index 0000000..345450f --- /dev/null +++ b/src/PhnCalllogManager.cpp @@ -0,0 +1,960 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCalllogManager.cpp + * @brief This class provides call log APIs + */ +#include "PhnCalllogManager.h" +#include + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::System; +using namespace Tizen::Locales; + +static const int MAX_CALL_LOG_COUNT = 100; +CallLogManager* CallLogManager::__pCallogManager = null; + +result +LogListComparer::Compare(const CallLogDetails& obj1, const CallLogDetails& obj2, int& cmp) const +{ + CallLogDetails* log1 = const_cast((&obj1)); + CallLogDetails* log2 = const_cast((&obj2)); + if(log1 == null || log2 == null) + { + return E_FAILURE; + } + log1->ConvertTimetoDateTime(); + DateTime date1 = log1->GetDateTime(); + //AppLog(" %d %d %s %d:%d:%d", log1->GetCalllogDbId(), log1->GetCalllogType(), log1->GetPhoneNumber(), date1.GetDay(), date1.GetMonth(), date1.GetYear()); + log2->ConvertTimetoDateTime(); + DateTime date2 = log2->GetDateTime(); + //AppLog(" %d %d %s %d:%d:%d", log2->GetCalllogDbId(), log2->GetCalllogType(), log2->GetPhoneNumber(), date2.GetDay(), date2.GetMonth(), date2.GetYear()); + cmp = date2.CompareTo(date1); + return E_SUCCESS; +} + +CallLogDetails::CallLogDetails(void) +{ + dateTime.SetValue(0,0,0); + first_name = null; + last_name = null; + display_name = null; + contact_image_path = null; + phone_number = null; + short_message = null; + contact_db_id = -1; +} + +CallLogDetails::~CallLogDetails(void) +{ + //NOTE: none of the fields are owned. Free() them will lead to crash. +} + +bool +CallLogDetails::operator ==(const CallLogDetails& rhs) const +{ + if(this->calllog_db_id == rhs.calllog_db_id) + { + return true; + } + return false; +} + +bool +CallLogDetails::operator !=(const CallLogDetails& rhs) const +{ + if(this->calllog_db_id != rhs.calllog_db_id) + { + return true; + } + return false; +} + +CallLogDetails& +CallLogDetails::operator =(const CallLogDetails& rhs) +{ + this->calllog_db_id = rhs.calllog_db_id; + this->contact_db_id = rhs.contact_db_id; + this->calllog_type = rhs.calllog_type; + /*if(rhs.contact_image_path != null) + { + this->contact_image_path = strdup(rhs.contact_image_path); + } + if(rhs.display_name != null) + { + this->display_name = strdup(rhs.display_name); + }*/ + + this->duration_sec = rhs.duration_sec; + + /*if(rhs.first_name != null) + { + this->first_name = strdup(rhs.first_name); + } + + if(rhs.last_name != null) + { + this->last_name = strdup(rhs.last_name); + } +*/ + if(rhs.phone_number != null) + { + this->phone_number = strdup(rhs.phone_number); + } + + /*if(rhs.short_message != null) + { + this->short_message = strdup(rhs.short_message); + }*/ + + this->startTime = rhs.startTime; + return *this; +} + + +void +CallLogDetails::SetCalllogDbId(int id) +{ + calllog_db_id = id; +} + + +int +CallLogDetails::GetCalllogDbId(void) +{ + return calllog_db_id; +} + +void +CallLogDetails::SetCalllogType(contacts_phone_log_type_e type) +{ + switch (type) + { + case CONTACTS_PLOG_TYPE_VOICE_INCOMMING: + calllog_type = CALL_LOG_TYPE_VOICE_INCOMING; + break; + case CONTACTS_PLOG_TYPE_VOICE_OUTGOING: + calllog_type = CALL_LOG_TYPE_VOICE_OUTGOING; + break; + case CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: + calllog_type = CALL_LOG_TYPE_VOICE_MISSED; + break; + case CONTACTS_PLOG_TYPE_VOICE_REJECT: + calllog_type = CALL_LOG_TYPE_VOICE_REJECTED; + break; + case CONTACTS_PLOG_TYPE_VOICE_BLOCKED: + calllog_type = CALL_LOG_TYPE_VOICE_BLOCKED; + break; + default: + break; + } +} + +CallLogType +CallLogDetails::GetCalllogType(void) +{ + return calllog_type; +} + +void +CallLogDetails::SetContactDbId(int id) +{ + contact_db_id = id; +} + +int +CallLogDetails::GetContactDbId(void) +{ + return contact_db_id; +} + +void +CallLogDetails::SetFirstName(char* name) +{ + first_name = strdup(name); +} + +char* +CallLogDetails::GetFirstName(void) +{ + return first_name; +} + +void +CallLogDetails::SetLastName(char* name) +{ + last_name = strdup(name); +} + +char* +CallLogDetails::GetLastName(void) +{ + return last_name; +} + +void +CallLogDetails::SetDisplayName(char* name) +{ + display_name = strdup(name); +} + +char* +CallLogDetails::GetDisplayName(void) +{ + return display_name; +} + +void +CallLogDetails::SetContactImagePath(char* name) +{ + contact_image_path = strdup(name); +} + +char* +CallLogDetails::GetContactImagePath(void) +{ + return contact_image_path; +} + +void +CallLogDetails::SetPhoneNumber(char* name) +{ + phone_number = strdup(name); +} + +char* +CallLogDetails::GetPhoneNumber(void) +{ + return phone_number; +} + +void +CallLogDetails::SetShortMessage(char* name) +{ + short_message = strdup(name); +} + +char* +CallLogDetails::GetShortMessage(void) +{ + return short_message; +} + +void +CallLogDetails::ConvertTimetoDateTime(void) +{ + DateTime dtNow; + struct tm* time = null; + time = gmtime(&startTime); + LocaleManager localManager; + TimeZone tz; + if(time != null) + { + dtNow.SetValue(time->tm_year+1900,time->tm_mon+1, time->tm_mday,time->tm_hour, time->tm_min, time->tm_sec); + + } + localManager.Construct(); + tz = localManager.GetSystemTimeZone(); + dateTime = tz.UtcTimeToWallTime(dtNow); + + +} + +void +CallLogDetails::SetStartTime(time_t time) +{ + startTime = time; + ConvertTimetoDateTime(); +} + +time_t +CallLogDetails::GetStartTime(void) +{ + return startTime; +} + +DateTime +CallLogDetails::GetDateTime(void) +{ + return dateTime; +} + +void +CallLogDetails::SetDuration(int duration) +{ + duration_sec = duration; +} + +int +CallLogDetails::GetDuration(void) +{ + return duration_sec; +} + +CallLogManager* +CallLogManager::GetInstance(void) +{ + if(__pCallogManager == null) + { + CreateInstance(); + } + return __pCallogManager; +} + +void +CallLogManager::CreateInstance(void) +{ + __pCallogManager = new CallLogManager(); + result r = __pCallogManager->Construct(); + if(IsFailed(r)) + { + delete __pCallogManager; + __pCallogManager = null; + return; + } + std::atexit(DestroyInstance); +} +void +CallLogManager::DestroyInstance(void) +{ + contacts_disconnect2(); + delete __pCallogManager; +} +result +CallLogManager::Construct(void) +{ + int ret = contacts_connect2(); + if(ret != 0) + { + return E_FAILURE; + } + + __pCalllogList = new (std::nothrow) LinkedListT; + __pCalllogChangeListerners = new (std::nothrow) ArrayListT; + __pCalllogChangeListerners->Construct(10); + __pCalllogDBIds = new (std::nothrow) HashMapT(); + __pCalllogDBIds->Construct(100); + + GetAllCallogDataFromDatabseCB(); + SortCalllogList(); + //TODO + //calllog_add_calllog_db_changed_cb(changed_db_cb, this); + return E_SUCCESS; + +} +///////////////////////////////////////Calllog Manager//////////////////////////////////////////////////////////////////////////////// +CallLogManager::CallLogManager(void) +{ + __pCalllogList = null; + __pCalllogListByNumber = null; + __pNumber = null; + __pCalllogChangeListerners = null; +} + +CallLogManager::~CallLogManager(void) +{ + if (__pCalllogList != null) + { + __pCalllogList->RemoveAll(); + delete __pCalllogList; + __pCalllogList = null; + } + if(__pCalllogListByNumber != null) + { + __pCalllogListByNumber = null; + } + if(__pNumber != null) + { + delete __pNumber; + __pNumber = null; + } + if(__pCalllogChangeListerners != null) + { + delete __pCalllogChangeListerners; + } + __pCallogManager = null; +} + +unsigned long +CallLogManager::GetDuration(long long start_time) +{ + time_t curr_time; + unsigned long call_duration_in_sec = 50; + curr_time = time(0); + /*if(start_time != 0) + { + start_time /= 1000; + }*/ + call_duration_in_sec = curr_time - start_time; + return call_duration_in_sec; +} + +result +CallLogManager::AddCallogInfoToDatabase(CallInfo* calllogInfo) +{ + AppLog(" AddVoiceCallInfo Entry"); + int duration = 0; + long long startTime; + + if(calllogInfo != null) + { + CallLogType callLogType = calllogInfo->GetCalllogType(); + contacts_phone_log_type_e logType = CONTACTS_PLOG_TYPE_NONE; + switch (callLogType) + { + case CALL_LOG_TYPE_VOICE_INCOMING: + logType = CONTACTS_PLOG_TYPE_VOICE_INCOMMING; + break; + case CALL_LOG_TYPE_VOICE_OUTGOING: + logType = CONTACTS_PLOG_TYPE_VOICE_OUTGOING; + break; + case CALL_LOG_TYPE_VOICE_MISSED: + logType = CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; + break; + case CALL_LOG_TYPE_VOICE_REJECTED: + logType = CONTACTS_PLOG_TYPE_VOICE_REJECT; + break; + case CALL_LOG_TYPE_VOICE_BLOCKED: + logType = CONTACTS_PLOG_TYPE_VOICE_BLOCKED; + break; + default: + break; + } + startTime = calllogInfo->GetCallNotificationTime(); + if ((logType == CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN) + || (logType == CONTACTS_PLOG_TYPE_VOICE_REJECT) + || (logType == CONTACTS_PLOG_TYPE_VOICE_BLOCKED)) + { + duration = 0; + } + else + { + //start time is in miliseconds . so convert to seconds and set it to time_t format. + long long connectTime = calllogInfo->GetCallConnectTime(); + if(connectTime == 0 || connectTime < 0) + { + connectTime = time(null); + } + else + { + connectTime = calllogInfo->GetCallConnectTime()/ 1000; + } + duration = (int)GetDuration(connectTime); + } + + String PhNumber(L""); + ByteBuffer* pByteBuffer = null; + + if(calllogInfo->GetContactNumber().IsEmpty() == false) + { + PhNumber.Append(calllogInfo->GetContactNumber()); + pByteBuffer = StringUtil::StringToUtf8N(PhNumber); + } + + + contacts_record_h hContactLog=0; + int ret = contacts_record_create(_contacts_phone_log._uri,&hContactLog); + if (ret != 0) + { + return E_FAILURE; + } + int id; + + + if (contacts_record_set_int(hContactLog,_contacts_phone_log.log_type,logType) != CONTACTS_ERROR_NONE) + { + AppLog(" calllog_set_type is failed"); + } + else if (contacts_record_set_int(hContactLog,_contacts_phone_log.log_time,startTime/1000) != CONTACTS_ERROR_NONE) + { + AppLog(" calllog_set_time is failed"); + } + else if (contacts_record_set_int(hContactLog,_contacts_phone_log.extra_data1,duration) != CONTACTS_ERROR_NONE) + { + AppLog(" calllog_set_duration is failed"); + } + else if ((pByteBuffer != null) && (contacts_record_set_str(hContactLog,_contacts_phone_log.address,(const char*) pByteBuffer->GetPointer()) != CONTACTS_ERROR_NONE)) + { + AppLog(" calllog_set_number is failed"); + } + else if (contacts_db_insert_record(hContactLog,&id) != CONTACTS_ERROR_NONE) + { + AppLog(" calllog_insert_to_db is failed"); + } + else + { + AppLog(" Call log is added successfully"); + } + + } + changed_db_cb(); + AppLog(" AddVoiceCallInfo Exit"); + return E_SUCCESS; +} + +void +CallLogManager::CopyDataToCallLogDetails(CallLogDetails* calllogInfo , contacts_record_h getrec) +{ + int logid=0; + contacts_record_get_int(getrec,_contacts_phone_log.id,&logid); + calllogInfo->SetCalllogDbId(logid); + + contacts_phone_log_type_e logType=CONTACTS_PLOG_TYPE_NONE; + contacts_record_get_int(getrec,_contacts_phone_log.log_type,(int*)&logType); + calllogInfo->SetCalllogType(logType); + + int log_time=0; + contacts_record_get_int(getrec,_contacts_phone_log.log_time,&log_time); + calllogInfo->SetStartTime((time_t)log_time); + + char* address = null; + int ret = contacts_record_get_str(getrec,_contacts_phone_log.address,&address); + if(ret == 0 && address != null) + { + calllogInfo->SetPhoneNumber(address); + } + + int duration=0; + contacts_record_get_int(getrec,_contacts_phone_log.extra_data1,&duration); + calllogInfo->SetDuration(duration); + + char* shortMsg=0; + contacts_record_get_str(getrec,_contacts_phone_log.extra_data2,&shortMsg); + if(shortMsg) + calllogInfo->SetShortMessage(shortMsg); + +} + +bool +CallLogManager::GetAllCallogDataFromDatabseCB() +{ + contacts_list_h list; + int ret; + int calLogCount = 0; + + contacts_db_get_count(_contacts_phone_log._uri,&calLogCount); + + if(calLogCount > MAX_CALL_LOG_COUNT) + { + ret = contacts_db_get_all_records(_contacts_phone_log._uri,calLogCount - MAX_CALL_LOG_COUNT,MAX_CALL_LOG_COUNT,&list); + } + else + { + ret = contacts_db_get_all_records(_contacts_phone_log._uri,0,MAX_CALL_LOG_COUNT,&list); + } + if (ret != 0) + { + return false; + } + + unsigned int count; + + ret = contacts_list_get_count(list,&count); + contacts_list_first(list); + for (unsigned int i = 0; i < count; i++) + { + CallLogDetails* calllogInfo = new CallLogDetails(); + + contacts_record_h getrec=0; + ret = contacts_list_get_current_record_p(list,&getrec); + if(ret == 0) + { + contacts_phone_log_type_e logType=CONTACTS_PLOG_TYPE_NONE; + contacts_record_get_int(getrec,_contacts_phone_log.log_type,(int*)&logType); + + if(logType == CONTACTS_PLOG_TYPE_VOICE_INCOMMING || + logType == CONTACTS_PLOG_TYPE_VOICE_OUTGOING || + logType == CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN|| + logType == CONTACTS_PLOG_TYPE_VOICE_REJECT || + logType == CONTACTS_PLOG_TYPE_VOICE_BLOCKED) + { + + CopyDataToCallLogDetails(calllogInfo, getrec); + if(__pCalllogDBIds->Add(calllogInfo->GetCalllogDbId(),calllogInfo->GetCalllogDbId()) == E_SUCCESS) + { + __pCalllogList->InsertAt(*calllogInfo, 0); + } + } + } + delete calllogInfo; + //move to next record + ret = contacts_list_next(list); + if (ret != 0) + { + continue; + } + contacts_record_destroy(getrec,true); + } + + return true; +} + + +void +CallLogManager::ResetAndNotifyCalllogData(void) +{ + if(__pCalllogList != null) + { + __pCalllogList->RemoveAll(); + delete __pCalllogList; + } + if(__pCalllogDBIds != null) + { + __pCalllogDBIds->RemoveAll(); + delete __pCalllogDBIds; + } + + __pCalllogList = new (std::nothrow) LinkedListT; + __pCalllogDBIds = new (std::nothrow) HashMapT; + __pCalllogDBIds->Construct(100); + + GetAllCallogDataFromDatabseCB(); + SortCalllogList(); + + //__pCalllogChangeListerners->GetEnumeratorN(); + + IEnumeratorT* pListenerEnum = null; + result r = E_FAILURE; + if (__pCalllogChangeListerners != null) + { + pListenerEnum = __pCalllogChangeListerners->GetEnumeratorN(); + while ((r = pListenerEnum->MoveNext()) != E_OUT_OF_RANGE) + { + ICalllogChangeListener* pListener; + r = pListenerEnum->GetCurrent(pListener); + pListener->OnCalllogChanged(); + + } + } + +} + + + +IListT* +CallLogManager::GetCalllogListByNumValues(void) //to be verified +{ + if(__pCalllogListByNumber != null) + { + //return __pCalllogListByNumber->GetValuesN(); + return __pCalllogListByNumber->GetItemsN(0, __pCalllogListByNumber->GetCount()); + } + return null; +} + +bool +CallLogManager::GetCallogListByNumberFromDatabaseCB(char* number) +{ + + contacts_filter_h filter=NULL; + contacts_list_h list=NULL; + contacts_query_h query = NULL; + unsigned int count = 0; + int ret = 0; + + contacts_filter_create(_contacts_phone_log._uri,&filter); + contacts_filter_add_str(filter,_contacts_phone_log.address,CONTACTS_MATCH_EXACTLY,number); + contacts_query_create(_contacts_phone_log._uri,&query); + contacts_query_set_filter(query,filter); + + ret = contacts_db_get_records_with_query(query,0,0,&list); + if (ret != 0) + { + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return false; + } + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + + contacts_list_get_count(list,&count); + contacts_list_first(list); + for(unsigned int i=0;iAdd( calllogInfo->GetCalllogDbId(), *calllogInfo); + contacts_phone_log_type_e logType=CONTACTS_PLOG_TYPE_NONE; + contacts_record_get_int(getrec,_contacts_phone_log.log_type,(int*)&logType); + + if(logType == CONTACTS_PLOG_TYPE_VOICE_INCOMMING || + logType == CONTACTS_PLOG_TYPE_VOICE_OUTGOING || + logType == CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN|| + logType == CONTACTS_PLOG_TYPE_VOICE_REJECT || + logType == CONTACTS_PLOG_TYPE_VOICE_BLOCKED) + { + CopyDataToCallLogDetails(calllogInfo, getrec); + __pCalllogListByNumber->Add(*calllogInfo); //to be verified + } + } + + delete calllogInfo; + ret = contacts_list_next(list); + if (ret != 0) + { + continue; + } + contacts_record_destroy(getrec,true); + } + + return true; +} + +Tizen::Base::Collection::ArrayListT* +CallLogManager::GetCallogListByNumberFromDatabaseN(char* number) +{ + __pCalllogListByNumber = new (std::nothrow) Tizen::Base::Collection::ArrayListT(); //to be verified + __pCalllogListByNumber->Construct(100); + if(__pNumber != null) + { + delete __pNumber; + } + int len = strlen(number) + 1; + __pNumber = new (std::nothrow) char[len]; + strcpy(__pNumber,number); + + GetCallogListByNumberFromDatabaseCB(number); + + if (__pCalllogListByNumber->GetCount() > 0) + { + SortCalllogListByNumber(); + return __pCalllogListByNumber; + } + delete __pCalllogListByNumber; + __pCalllogListByNumber = null; + return null; +} + +HashMapT* +CallLogManager::GetCallogListByUnknownNumberFromDatabaseN(char* number) +{ + //Used to fetch list of call from unknown numbers from logs. + __pCalllogUnkownListByNumber = new (std::nothrow) HashMapT(); + __pCalllogUnkownListByNumber->Construct(100); + if(__pNumber != null) + { + delete __pNumber; + } + int len = strlen(number) + 1; + __pNumber = new (std::nothrow) char[len]; + strcpy(__pNumber,number); + + GetCallogListByNumberFromDatabaseCB(number); + if (__pCalllogUnkownListByNumber->GetCount() > 0) + { + return __pCalllogUnkownListByNumber; + } + delete __pCalllogUnkownListByNumber; + __pCalllogUnkownListByNumber = null; + return null; +} + +void +CallLogManager::changed_db_cb() +{ + ResetAndNotifyCalllogData(); +} + + +void +CallLogManager::DeleteCalllogByDbId(int dbId) +{ + int ret = 0; + contacts_filter_h filter=NULL; + contacts_list_h list=NULL; + contacts_query_h query = NULL; + unsigned int count; + + contacts_filter_create(_contacts_phone_log._uri,&filter); + contacts_filter_add_int(filter,_contacts_phone_log.id,CONTACTS_MATCH_EQUAL,dbId); + contacts_query_create(_contacts_phone_log._uri,&query); + contacts_query_set_filter(query,filter); + + ret = contacts_db_get_records_with_query(query,0,0,&list); + if (ret != 0) + { + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return ; + } + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + + ret = contacts_list_get_count(list,&count); + contacts_list_first(list); + for(unsigned int i=0;iGetCount(); + + for(int i=0; i< count; i++) + { + CallLogDetails latestCallLog; + if(__pCalllogList->GetAt(i,latestCallLog) == E_SUCCESS) + { + contacts_db_delete_record(_contacts_phone_log._uri,latestCallLog.GetCalllogDbId()); + } + } + AppLogDebug("Exit"); + contacts_phone_log_reset_statistics(); + changed_db_cb(); +} + +int +CallLogManager::GetAllCalllogCount(void) +{ + if(__pCalllogList != null) + { + return __pCalllogList->GetCount(); + } + return 0; +} + +int +CallLogManager::GetCalllogCountByNumber(void) +{ + if(__pCalllogListByNumber != null) + { + return __pCalllogListByNumber->GetCount(); + } + return 0; +} + +void +CallLogManager::SortCalllogList(void) +{ + LogListComparer cmp; + __pCalllogList->Sort(cmp); +} + +void +CallLogManager::SortCalllogListByNumber(void) //to be verified +{ + LogListComparer cmp; + __pCalllogListByNumber->Sort(cmp); +} + +String* +CallLogManager::GetLatestCallLogFromDbN(void) +{ + String* latestNumber = null; + if(__pCalllogList != null && __pCalllogList->GetCount() > 0) + { + CallLogDetails latestCallLog; + if(__pCalllogList->GetAt(0,latestCallLog) == E_SUCCESS) + { + latestNumber = new String(latestCallLog.GetPhoneNumber()); + } + } + + return latestNumber; +} + +result CallLogManager::GetCallLogItemAtIndex(int index, CallLogDetails& calllogInfo) +{ + return __pCalllogList->GetAt(index,calllogInfo); +} + + + + +void CallLogManager::AddCalllogChangeListener(ICalllogChangeListener& listner ) +{ + if(!__pCalllogChangeListerners->Contains(&listner)) + __pCalllogChangeListerners->Add(&listner); + +} + +void CallLogManager::RemoveCalllogChangeListner(ICalllogChangeListener& listner) +{ + __pCalllogChangeListerners->Remove(&listner); +} + +void CallLogManager::GetCalllogContactName(String number,String& name) +{ + + ByteBuffer* pByteBuffer; + char * charname=NULL; + pByteBuffer = StringUtil::StringToUtf8N(number); + + contacts_filter_h filter=NULL; + contacts_list_h list=NULL; + contacts_query_h query = NULL; + unsigned int count = 0; + + contacts_filter_create(_contacts_contact_number._uri,&filter); + contacts_filter_add_str(filter,_contacts_contact_number.number,CONTACTS_MATCH_EXACTLY,(const char*)pByteBuffer->GetPointer()); + contacts_query_create(_contacts_contact_number._uri,&query); + contacts_query_set_filter(query,filter); + + int ret = contacts_db_get_records_with_query(query,0,0,&list); + if (ret != 0) + { + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return ; + } + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + + contacts_list_get_count(list,&count); + AppLogTag("Amith","%d",count); + if(count > 0) + { + contacts_record_h getrec=0; + contacts_list_first(list); + contacts_list_get_current_record_p(list,&getrec); + + contacts_record_get_str(getrec,_contacts_contact_number.display_name,&charname); + AppLogTag("Amith","%s",charname); + if(charname) + { + String buffer(charname); + name.Clear(); + name.Append(buffer); + + } + contacts_record_destroy(getrec,true); + } + + + + +} diff --git a/src/PhnCommonUtils.cpp b/src/PhnCommonUtils.cpp new file mode 100644 index 0000000..de9a5ab --- /dev/null +++ b/src/PhnCommonUtils.cpp @@ -0,0 +1,641 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file CommonUtils.cpp + * @brief commonly used functions + */ + +#include +#include +#include +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Collection; + +const int ID_NAME_STRING = 100; +const int ID_NUMBER_STRING = 101; +const int ID_TIME_STRING = 102; +const int ID_CONTACT_BITMAP = 103; +const int ID_CALLTYPE_BITMAP = 104; + + +const int X_TEXT_LINE1_ITEM = 16; +const int Y_TEXT_LINE1_ITEM = 10; +const int H_TEXT_LINE1_ITEM = 60; +const int W_TEXT_LINE1_ITEM = 560; + +const int X_TEXT_LINE2_ITEM = 64; +const int Y_TEXT_LINE2_ITEM = 70; +const int H_TEXT_LINE2_ITEM = 48; +const int W_TEXT_LINE2_ITEM = 256; + +const int X_TEXT_TIME_ITEM = 320; +const int Y_TEXT_TIME_ITEM = 70; +const int H_TEXT_TIME_ITEM = 48; +const int W_TEXT_TIME_ITEM = 256; + +const int X_CONTACT_BITMAP_ITEM = 592; +const int Y_CONTACT_BITMAP_ITEM = 0; +const int H_CONTACT_BITMAP_ITEM = 128; +const int W_CONTACT_BITMAP_ITEM = 128; + +const int X_CALLTYPE_BITMAP_ITEM = 16; +const int Y_CALLTYPE_BITMAP_ITEM = 70 + 8; +const int H_CALLTYPE_BITMAP_ITEM = 32; +const int W_CALLTYPE_BITMAP_ITEM = 32; + +const int X_DIALER_BTN_TXT = 13; +const int W_DIALER_BTN_NUM_TXT = 77; +const int W_DIALER_BTN_ALPHA_TXT = 121; + +const int W_ENRICHED_TEXT = 190; +const int X_ENRICHED_TEXT = 143; + +Font* +DialUtil::GetTextFontN(int textFontStyle) +{ + Font* font = new (std::nothrow) Font(); + + switch (textFontStyle) + { + case FONT_CALLING_TEXT: + { + font->Construct(FONT_STYLE_PLAIN, 94); + } + break; + + case FONT_KEYPAD_NUMBER: + { + font->Construct(FONT_STYLE_PLAIN, 116); + } + break; + + case FONT_KEYPAD_TEXT: + { + font->Construct(FONT_STYLE_BOLD, 40); + } + break; + + case FONT_KEYPAD_P: + { + font->Construct(FONT_STYLE_BOLD, 56); + } + break; + + case FONT_KEYPAD_PLUS: + { + font->Construct(FONT_STYLE_BOLD, 64); + } + break; + + case FONT_KEYPAD_CANCEL: + { + font->Construct(FONT_STYLE_PLAIN, 34); + } + break; + + case FONT_SUGGESTION_NAME: + { + font->Construct(FONT_STYLE_PLAIN, 40); + } + break; + + case FONT_SUGGESTION_MOBILE: + { + font->Construct(FONT_STYLE_PLAIN, 35); + } + break; + + case FONT_SUGGESTION_NUMBER: + { + font->Construct(FONT_STYLE_PLAIN, 35); + } + break; + + case FONT_SUGGESTION_LIST_NUMBER: + { + font->Construct(FONT_STYLE_PLAIN, 40); + } + break; + } + return font; +} + +Color* +DialUtil::GetTextColorN(int textColor, int buttonStatus) +{ + Color* color = new (std::nothrow) Color(); + + if (buttonStatus == BUTTON_STATUS_PRESSED) + { + color->SetColorComponents(249, 249, 249); + return color; + } + + switch (textColor) + { + case FONT_CALLING_TEXT: + { + color->SetColorComponents(0, 0, 0); + } + break; + + case FONT_KEYPAD_NUMBER: + { + color->SetColorComponents(255, 255, 255); + } + break; + + case FONT_KEYPAD_TEXT: + case FONT_KEYPAD_P: + case FONT_KEYPAD_PLUS: + { + color->SetColorComponents(148, 177, 200); + } + break; + + case FONT_KEYPAD_CANCEL: + { + color->SetColorComponents(255, 255, 255); + } + break; + + case FONT_SUGGESTION_NAME: + { + color->SetColorComponents(255, 255, 255); + } + break; + + case FONT_SUGGESTION_MOBILE: + { + color->SetColorComponents(148, 177, 200); + } + break; + + case FONT_HIGHLIGHT_SEARCH_KEYWORD: + case FONT_SUGGESTION_NUMBER: + { + color->SetColorComponents(26, 214, 227); + } + break; + + case FONT_SUGGESTION_LIST_NUMBER: + { + color->SetColorComponents(124, 189, 224); + } + break; + } + return color; +} + +bool +DialUtil::IsNumericString(Tizen::Base::String& keyWord) +{ + bool isDigit = false; + String digitStr(L""); + if(keyWord.SubString(0,1,digitStr) == E_SUCCESS) + { + int digit; + if(Integer::Parse(digitStr,digit) == E_SUCCESS) + { + isDigit = true; + } + } + return isDigit; +} + +void +DialUtil::Draw9PatchToCanvas(Canvas& pCanvas, const String& bgImg) +{ + AppResource* pAppResource = AppResource::GetInstance(); + Bitmap* pBitmap = pAppResource->GetBitmapN(bgImg); + + if (pBitmap->IsNinePatchedBitmap()) + { + pCanvas.DrawNinePatchedBitmap(pCanvas.GetBounds(), *pBitmap); + } + delete pBitmap; + + return; +} + +void +DialUtil::DrawImageToCanvas(const String& image, Dimension imageDimention, Canvas& pCanvas, int pos) +{ + //create and scale bitmap + Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(image, imageDimention.width, imageDimention.height); + + //Find position to draw bitmap + Point bitmapPos(0, 0); + switch (pos) + { + case POSITION_LEFT: + { + bitmapPos.SetPosition(X_DIALER_BTN_TXT + (W_DIALER_BTN_NUM_TXT - pBitmap->GetWidth()) / 2, (pCanvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + + case POSITION_RIGHT: + { + bitmapPos.SetPosition(X_DIALER_BTN_TXT + W_DIALER_BTN_NUM_TXT + ((W_DIALER_BTN_ALPHA_TXT - pBitmap->GetWidth()) / 2), (pCanvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + + case POSITION_CENTER: + { + bitmapPos.SetPosition((pCanvas.GetBounds().width - pBitmap->GetWidth()) / 2, (pCanvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + + case POSITION_BOTTOM_CENTER: + { + bitmapPos.SetPosition((pCanvas.GetBounds().width - pBitmap->GetWidth()) / 2, pCanvas.GetBounds().height / 2 + (pCanvas.GetBounds().height / 2 - pBitmap->GetHeight()) / 2); + } + break; + } + + //draw bitmap + pCanvas.DrawBitmap(Rectangle(bitmapPos, Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap); + delete pBitmap; + pBitmap = null; + + return; +} + +void +DialUtil::DrawTextToCanvas(const String& buttonText, int textFontStyle, Canvas& pCanvas, int pos, int buttonStatus) +{ + AppLogDebug("ENTER"); + if (buttonText == null) + { + return; + } + + //get text font + Font* font = GetTextFontN(textFontStyle); + + //get text color + Color* textColor = GetTextColorN(textFontStyle, buttonStatus); + + //create text element + TextElement* pTextElement = new (std::nothrow) TextElement(); + pTextElement->Construct(buttonText); + pTextElement->SetTextColor(*textColor); + pTextElement->SetFont(*font); + delete textColor; + + //get dimensions of the text + Dimension textDimension; + font->GetTextExtent(buttonText, buttonText.GetLength(), textDimension); + if(textFontStyle != FONT_KEYPAD_NUMBER) + { + textDimension.height += font->GetDescender(); + } + + //create enriched text + EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText(); + pEnrichedText->Construct(textDimension); + pEnrichedText->Add(*pTextElement); + + //set the position of the text in canvas + Point textPos(0, 0); + switch (pos) + { + case POSITION_LEFT: + { + //Margin 13, rectangle for left text (13,0,77, height of canvas), center aligned + textPos.SetPosition(X_DIALER_BTN_TXT + ((W_DIALER_BTN_NUM_TXT - pEnrichedText->GetWidth()) / 2), (pCanvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_RIGHT: + { + //rectangle for right text (13+77,0, 121, height of canvas), center aligned + textPos.SetPosition(X_DIALER_BTN_TXT + W_DIALER_BTN_NUM_TXT + ((121 - pEnrichedText->GetWidth()) / 2), (pCanvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_CENTER: + { + //rectangle for image : entire canvas, center aligned + textPos.SetPosition((pCanvas.GetBounds().width - pEnrichedText->GetWidth()) / 2, (pCanvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_TOP_LEFT: + { + textPos.SetPosition(10, (pCanvas.GetBounds().height / 2 - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_TOP_CENTER: + { + textPos.SetPosition((pCanvas.GetBounds().width - pEnrichedText->GetWidth()) / 2, (pCanvas.GetBounds().height / 2 - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_BOTTOM_LEFT: + { + textPos.SetPosition(10, pCanvas.GetBounds().height / 2 + ((pCanvas.GetBounds().height / 2 - pEnrichedText->GetHeight()) / 2)); + } + break; + + case POSITION_BOTTOM_CENTER: + { + int width = pEnrichedText->GetWidth(); + if(width > W_ENRICHED_TEXT) + { + textPos.SetPosition(X_ENRICHED_TEXT, pCanvas.GetBounds().height / 2 + ((pCanvas.GetBounds().height / 2 - pEnrichedText->GetHeight()) / 2)); + } + else + { + textPos.SetPosition(10 + ((pCanvas.GetBounds().width - pEnrichedText->GetWidth()) / 2), pCanvas.GetBounds().height / 2 + ((pCanvas.GetBounds().height / 2 - pEnrichedText->GetHeight()) / 2)); + } + + } + break; + } + + //Draw EnrichedText to canvas + pCanvas.DrawText(textPos, *pEnrichedText); + + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + delete font; + + AppLogDebug("EXIT"); + return; +} + +void +DialUtil::DrawCanvasToButton(Canvas* pCanvasNormal, Canvas* pCanvasPressed, Button* pButton) +{ + Bitmap* pNormalBgBmp = new (std::nothrow) Bitmap(); + pNormalBgBmp->Construct(*pCanvasNormal, pCanvasNormal->GetBounds()); + + pButton->SetNormalBackgroundBitmap(*pNormalBgBmp); + + if (pCanvasPressed != null) + { + Bitmap* pPressedBgBmp = new (std::nothrow) Bitmap(); + pPressedBgBmp->Construct(*pCanvasPressed, pCanvasPressed->GetBounds()); + pButton->SetPressedBackgroundBitmap(*pPressedBgBmp); + delete pPressedBgBmp; + pPressedBgBmp = null; + } + else + { + pButton->SetPressedBackgroundBitmap(*pNormalBgBmp); + } + + pButton->SetDisabledBitmap(Point(0, 0), *pNormalBgBmp); + pButton->Invalidate(true); + delete pNormalBgBmp; + pNormalBgBmp = null; + + return; +} + +String +DialUtil::ConvertDialedNumberToString(int dialNumber) +{ + switch (dialNumber) + { + case NUM_KEY1: + { + return L"1"; + } + case NUM_KEY2: + { + return L"2"; + } + case NUM_KEY3: + { + return L"3"; + } + case NUM_KEY4: + { + return L"4"; + } + case NUM_KEY5: + { + return L"5"; + } + case NUM_KEY6: + { + return L"6"; + } + case NUM_KEY7: + { + return L"7"; + } + case NUM_KEY8: + { + return L"8"; + } + case NUM_KEY9: + { + return L"9"; + } + break; + case NUM_KEY0: + { + return L"0"; + } + break; + } + return null; +} + +IList* +DialUtil::FetchPossibleNamesListN(const String& prevSearchStr, int nextDigit) +{ + //Fetch matching names for mapping char for digit, e.g. 2->ABC, 3->DEF. + ArrayList* pNamesList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pNamesList->Construct(8); + + if(nextDigit >=2 && nextDigit <= 9) + { + switch(nextDigit) + { + case 2: + { + pNamesList->Add((new String(prevSearchStr+L"a"))); + pNamesList->Add((new String(prevSearchStr+L"b"))); + pNamesList->Add((new String(prevSearchStr+L"c"))); + pNamesList->Add((new String(prevSearchStr+L"A"))); + pNamesList->Add((new String(prevSearchStr+L"B"))); + pNamesList->Add((new String(prevSearchStr+L"C"))); + } + break; + + case 3: + { + pNamesList->Add((new String(prevSearchStr+L"d"))); + pNamesList->Add((new String(prevSearchStr+L"e"))); + pNamesList->Add((new String(prevSearchStr+L"f"))); + pNamesList->Add((new String(prevSearchStr+L"D"))); + pNamesList->Add((new String(prevSearchStr+L"E"))); + pNamesList->Add((new String(prevSearchStr+L"F"))); + } + break; + + case 4: + { + pNamesList->Add((new String(prevSearchStr+L"g"))); + pNamesList->Add((new String(prevSearchStr+L"h"))); + pNamesList->Add((new String(prevSearchStr+L"i"))); + pNamesList->Add((new String(prevSearchStr+L"G"))); + pNamesList->Add((new String(prevSearchStr+L"H"))); + pNamesList->Add((new String(prevSearchStr+L"I"))); + } + break; + + case 5: + { + pNamesList->Add((new String(prevSearchStr+L"j"))); + pNamesList->Add((new String(prevSearchStr+L"k"))); + pNamesList->Add((new String(prevSearchStr+L"l"))); + pNamesList->Add((new String(prevSearchStr+L"J"))); + pNamesList->Add((new String(prevSearchStr+L"K"))); + pNamesList->Add((new String(prevSearchStr+L"L"))); + } + break; + + case 6: + { + pNamesList->Add((new String(prevSearchStr+L"m"))); + pNamesList->Add((new String(prevSearchStr+L"n"))); + pNamesList->Add((new String(prevSearchStr+L"o"))); + pNamesList->Add((new String(prevSearchStr+L"M"))); + pNamesList->Add((new String(prevSearchStr+L"N"))); + pNamesList->Add((new String(prevSearchStr+L"O"))); + } + break; + + case 7: + { + pNamesList->Add((new String(prevSearchStr+L"p"))); + pNamesList->Add((new String(prevSearchStr+L"q"))); + pNamesList->Add((new String(prevSearchStr+L"r"))); + pNamesList->Add((new String(prevSearchStr+L"s"))); + pNamesList->Add((new String(prevSearchStr+L"P"))); + pNamesList->Add((new String(prevSearchStr+L"Q"))); + pNamesList->Add((new String(prevSearchStr+L"R"))); + pNamesList->Add((new String(prevSearchStr+L"S"))); + } + break; + + case 8: + { + pNamesList->Add((new String(prevSearchStr+L"t"))); + pNamesList->Add((new String(prevSearchStr+L"u"))); + pNamesList->Add((new String(prevSearchStr+L"v"))); + pNamesList->Add((new String(prevSearchStr+L"T"))); + pNamesList->Add((new String(prevSearchStr+L"U"))); + pNamesList->Add((new String(prevSearchStr+L"V"))); + } + break; + + case 9: + { + pNamesList->Add((new String(prevSearchStr+L"w"))); + pNamesList->Add((new String(prevSearchStr+L"x"))); + pNamesList->Add((new String(prevSearchStr+L"y"))); + pNamesList->Add((new String(prevSearchStr+L"z"))); + pNamesList->Add((new String(prevSearchStr+L"W"))); + pNamesList->Add((new String(prevSearchStr+L"X"))); + pNamesList->Add((new String(prevSearchStr+L"Y"))); + pNamesList->Add((new String(prevSearchStr+L"Z"))); + } + break; + + } + } + return pNamesList; +} + +void +DialUtil::ConvertNameToNumericKeys(String& subContactName, String& possibleKeysTyped) +{ + for(int charPos=0;charPos < subContactName.GetLength();charPos++) + { + wchar_t nextChar; + subContactName.GetCharAt(charPos,nextChar); + switch(nextChar) + { + case 'a':case 'A': + case 'b':case 'B': + case 'c':case 'C': + possibleKeysTyped.Append(2); + break; + + case 'd':case 'D': + case 'e':case 'E': + case 'f':case 'F': + possibleKeysTyped.Append(3); + break; + + case 'g':case 'G': + case 'h':case 'H': + case 'i':case 'I': + possibleKeysTyped.Append(4); + break; + + case 'j':case 'J': + case 'k':case 'K': + case 'l':case 'L': + possibleKeysTyped.Append(5); + break; + + case 'm':case 'M': + case 'n':case 'N': + case 'o':case 'O': + possibleKeysTyped.Append(6); + break; + + case 'p':case 'P': + case 'q':case 'Q': + case 'r':case 'R': + case 's':case 'S': + possibleKeysTyped.Append(7); + break; + + case 't':case 'T': + case 'u':case 'U': + case 'v':case 'V': + possibleKeysTyped.Append(8); + break; + + case 'w':case 'W': + case 'x':case 'X': + case 'y':case 'Y': + case 'z':case 'Z': + possibleKeysTyped.Append(9); + break; + + default: + break; + } + } +} diff --git a/src/PhnConfCallerListForm.cpp b/src/PhnConfCallerListForm.cpp new file mode 100644 index 0000000..a991ea2 --- /dev/null +++ b/src/PhnConfCallerListForm.cpp @@ -0,0 +1,731 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnConfCallerListForm.cpp + * @brief Conference caller list form + */ +#include +#include "PhnConfCallerListForm.h" +#include "PhnAppUtility.h" +#include "PhnCallPresentationModel.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//Constants +const int W_HOLD_BITMAP = 78; +const int H_HOLD_BITMAP = 78; +const int W_BACK_BITMAP = 56; +const int H_BACK_BITMAP = 56; +const int X_BACK_BITMAP = 8; +const int Y_BACK_BITMAP = 8; +const int W_SPLIT_BITMAP = 66; +const int H_SPLIT_BITMAP = 68; +const int W_END_BITMAP = 80; +const int H_END_BITMAP = 74; +const int IDI_MAX_SECONDS = 60; +const int IDI_MAX_MINS = 60; + +static const wchar_t* IDL_CONFCALL_LIST_FORM = L"IDL_CONFCALL_LIST_FORM"; +static const wchar_t* IDC_CALL_TIME_LABEL = L"IDC_CALL_TIME_LABEL"; +static const wchar_t* IDB_BACK_BUTTON_ICON = L"C01-1_btn_back.png"; +static const wchar_t* IDB_SPLIT_NORMAL_BUTTON_ICON = L"C01-1_conference_split.png"; +static const wchar_t* IDB_SPLIT_PRESS_BUTTON_ICON = L"C01-1_conference_split_press.png"; +static const wchar_t* IDB_END_NORMAL_BUTTON_ICON = L"C01-1_conference_end.png"; +static const wchar_t* IDB_END_PRESS_BUTTON_ICON = L"C01-1_conference_end_press.png"; +static const wchar_t* IDC_END_CONFCALL_BUTTON = L"IDC_END_CONFCALL_BUTTON"; +static const wchar_t* IDC_HOLD_CONFCALL_BUTTON = L"IDC_HOLD_CONFCALL_BUTTON"; +static const wchar_t* IDC_BACK_BUTTON = L"IDC_BACK_BUTTON"; +static const wchar_t* IDC_CALLER1_PANEL = L"IDC_CALLER1_PANEL"; +static const wchar_t* IDC__LINE_LABEL1 = L"IDC__LINE_LABEL1"; +static const wchar_t* IDC_CALLER2_PANEL = L"IDC_CALLER2_PANEL"; +static const wchar_t* IDC__LINE_LABEL2 = L"IDC__LINE_LABEL2"; +static const wchar_t* IDC_CALLER3_PANEL = L"IDC_CALLER3_PANEL"; +static const wchar_t* IDC__LINE_LABEL3 = L"IDC__LINE_LABEL3"; +static const wchar_t* IDC_CALLER4_PANEL = L"IDC_CALLER4_PANEL"; +static const wchar_t* IDC__LINE_LABEL4 = L"IDC__LINE_LABEL4"; +static const wchar_t* IDC_CALLER5_PANEL = L"IDC_CALLER5_PANEL"; +static const wchar_t* IDC__LINE_LABEL5 = L"IDC__LINE_LABEL5"; +static const wchar_t* IDC_END_CALLER1 = L"IDC_END_CALLER1"; +static const wchar_t* IDC_SPLIT_CALLER1 = L"IDC_SPLIT_CALLER1"; +static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL"; +static const wchar_t* IDC_END_CALLER2 = L"IDC_END_CALLER2"; +static const wchar_t* IDC_SPLIT_CALLER2 = L"IDC_SPLIT_CALLER2"; +static const wchar_t* IDC_CALLER2_LABEL = L"IDC_CALLER2_LABEL"; +static const wchar_t* IDC_END_CALLER3 = L"IDC_END_CALLER3"; +static const wchar_t* IDC_SPLIT_CALLER3 = L"IDC_SPLIT_CALLER3"; +static const wchar_t* IDC_CALLER3_LABEL = L"IDC_CALLER3_LABEL"; +static const wchar_t* IDC_END_CALLER4 = L"IDC_END_CALLER4"; +static const wchar_t* IDC_SPLIT_CALLER4 = L"IDC_SPLIT_CALLER4"; +static const wchar_t* IDC_CALLER4_LABEL = L"IDC_CALLER4_LABEL"; +static const wchar_t* IDC_END_CALLER5 = L"IDC_END_CALLER5"; +static const wchar_t* IDC_SPLIT_CALLER5 = L"IDC_SPLIT_CALLER5"; +static const wchar_t* IDC_CALLER5_LABEL = L"IDC_CALLER5_LABEL"; + +ConfCallerListForm::ConfCallerListForm(void) +: BaseForm(FORMTYPE_CONFCALLLIST) +{ + __pConfCallInfo = null; + __pConfCallTimer = null; +} + +ConfCallerListForm::~ConfCallerListForm(void) +{ + if (__pConfCallTimer != null) + { + __pConfCallTimer->Cancel(); + delete __pConfCallTimer; + } +} + +void +ConfCallerListForm::Initialize(void) +{ + Construct(IDL_CONFCALL_LIST_FORM); +} + +result +ConfCallerListForm::OnInitializing(void) +{ + result r = E_SUCCESS; + Bitmap* pRejectMessageBitmap = null; + AppResource* pAppResource = null; + Button* pButtonKeypad = null; + + //Add action listener to buttons + AddActionListener(IDC_END_CONFCALL_BUTTON, IDA_END_CONF_CALL); + AddActionListener(IDC_HOLD_CONFCALL_BUTTON, IDA_HOLD_CONF_CALL); + + pAppResource = AppResource::GetInstance(); + pButtonKeypad = static_cast(GetControl(IDC_BACK_BUTTON)); + + if (pButtonKeypad != null) + { + pButtonKeypad->SetActionId(IDA_BACK_EVENT); + pButtonKeypad->AddActionEventListener(*this); + pRejectMessageBitmap = pAppResource->GetBitmapN(IDB_BACK_BUTTON_ICON); + pRejectMessageBitmap->Scale(Dimension(W_BACK_BITMAP, H_BACK_BITMAP)); + pButtonKeypad->SetNormalBitmap(Point(X_BACK_BITMAP, X_BACK_BITMAP), *pRejectMessageBitmap); + delete pRejectMessageBitmap; + pRejectMessageBitmap = null; + } + + __pCallPresentor = CallPresentationModel::GetInstance(); + return r; +} + +void +ConfCallerListForm::AddActionListener(const String& keyName, CommandIds cmdId) +{ + Button* pButtonKeypad = static_cast(GetControl(keyName)); + if (pButtonKeypad != null) + { + pButtonKeypad->SetActionId(cmdId); + pButtonKeypad->AddActionEventListener(*this); + } +} + +result +ConfCallerListForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pCallPresentor != null) + { + __pCallPresentor = null; + } + + if (__pConfCallInfo != null) + { + delete __pConfCallInfo; + __pConfCallInfo = null; + } + + RemoveAllControls(); + return r; +} + +void +ConfCallerListForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch (actionId) + { + case IDA_END_CONF_CALL: + { + bool success = __pCallPresentor->EndConferenceCall(); + if (success == true) + { + delete __pConfCallInfo; + __pConfCallInfo = null; + } + } + break; + + case IDA_HOLD_CONF_CALL: + { + // User has pressed end conference call and we are waiting for TAPI response + if(__pConfCallInfo == null) + { + return; + } + bool success = true; + bool isCallOnHold = __pConfCallInfo->IsOnHold(); + if (isCallOnHold == false) + { + success = __pCallPresentor->HoldConferenceCall(); + } + else + { + success = __pCallPresentor->ActivateConferenceCall(); + } + + //Check if request to Hold / UnHold call is successful. + if(success == true) + { + //If success, then invert the Hold status in conference call + isCallOnHold = !(isCallOnHold); + __pConfCallInfo->SetOnHold(isCallOnHold); + //update panels and Hold button status + ActivatePanels(); + SetHoldButtonStatus(isCallOnHold); + } + } + break; + + case IDA_BACK_EVENT: + { + ArrayListT* pCallList = static_cast*>(__pCallPresentor->GetCallListN()); + int noOfCalls = pCallList->GetCount(); + + //Ownership - To be deleted in 'OnSceneActivatedN' of next form + ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallInfoList->Construct(noOfCalls); + + for (int index = 0; index < noOfCalls; index++) + { + //fetch call info and add to list + CallInfo callInfo; + result r = pCallList->GetAt(index, callInfo); + if (r == E_SUCCESS) + { + //copy call information to new instance + CallInfo* pCaller = new (std::nothrow) CallInfo(); + *pCaller = callInfo; + pCallInfoList->Add(pCaller); + } + } + + if (noOfCalls == 1) + { + //single active call - goto active call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList); + } + else + { + //goto multiple active call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList); + } + pCallList->RemoveAll(); + delete pCallList; + } + break; + + case IDA_SPLIT_CALLER1: + case IDA_SPLIT_CALLER2: + case IDA_SPLIT_CALLER3: + case IDA_SPLIT_CALLER4: + case IDA_SPLIT_CALLER5: + { + // User has pressed end conference call and we are waiting for TAPI response + if(__pConfCallInfo == null) + { + break; + } + __pCallPresentor->SplitFromConference(SplitConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList()); + } + break; + + case IDA_END_CALLER1: + case IDA_END_CALLER2: + case IDA_END_CALLER3: + case IDA_END_CALLER4: + case IDA_END_CALLER5: + { + // User has pressed end conference call and we are waiting for TAPI response + if(__pConfCallInfo == null) + { + break; + } + __pCallPresentor->EndCallFromConference(EndConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList()); + } + break; + + default: + break; + } +} + +void +ConfCallerListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + //set itself as listener + __pCallPresentor->SetTelEventListener(this); + + DisableAllControls(); + if (__pConfCallInfo != null) + { + delete __pConfCallInfo; + __pConfCallInfo = null; + } + //show 1st caller's info. + //Fetch Conference call info from telephony manager + __pConfCallInfo = __pCallPresentor->GetConferenceCallInfoN(); + + //show active call timer + ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetCallConnectTime()); + + //Set the correct bitmap to the "hold" button based on the current state of the call + SetHoldButtonStatus(__pConfCallInfo->IsOnHold()); + //disable Hold Button, if 2 active calls are present,Else enable it. + Button* pButtonHold = static_cast(GetControl(IDC_HOLD_CONFCALL_BUTTON)); + if(pButtonHold != null) + { + if (__pCallPresentor->GetCurrentCallCount() == IDI_MAX_ACTIVE_CALLS) + { + pButtonHold->SetShowState(false); + } + else + { + pButtonHold->SetShowState(true); + } + pButtonHold->Invalidate(true); + } + + ActivatePanels(); +} + +void +ConfCallerListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if (__pConfCallInfo != null) + { + delete __pConfCallInfo; + __pConfCallInfo = null; + } + if (__pConfCallTimer != null) + { + __pConfCallTimer->Cancel(); + delete __pConfCallTimer; + __pConfCallTimer = null; + } +} + +result +ConfCallerListForm::OnDraw(void) +{ + return E_SUCCESS; +} + +void +ConfCallerListForm::SetHoldButtonStatus(bool isCallOnHold) +{ + Button* pButtonHold = static_cast(GetControl(IDC_HOLD_CONFCALL_BUTTON)); + if(pButtonHold != null) + { + Bitmap* pNormalBitmapToBeDrawn = null; + Bitmap* pPressBitmapToBeDrawn = null; + + if (isCallOnHold == true) + { + pNormalBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_NORMAL_BUTTON_ICON, + W_HOLD_BITMAP, W_HOLD_BITMAP); + pPressBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_PRESS_BUTTON_ICON, + W_HOLD_BITMAP, W_HOLD_BITMAP); + } + else + { + pNormalBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_NORMAL_BUTTON_ICON, + W_HOLD_BITMAP, W_HOLD_BITMAP); + pPressBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_PRESS_BUTTON_ICON, + W_HOLD_BITMAP, W_HOLD_BITMAP); + } + + if (pNormalBitmapToBeDrawn) + { + pButtonHold->SetNormalBitmap(Point(0, 0), *pNormalBitmapToBeDrawn); + } + if (pPressBitmapToBeDrawn) + { + pButtonHold->SetPressedBitmap(Point(0, 0), *pPressBitmapToBeDrawn); + } + + pButtonHold->Invalidate(true); + delete pNormalBitmapToBeDrawn; + pNormalBitmapToBeDrawn = null; + delete pPressBitmapToBeDrawn; + pPressBitmapToBeDrawn = null; + } +} + +void +ConfCallerListForm::HandleCallChange(void) +{ + CallInfo* pCallInfo = __pCallPresentor->GetConferenceCallInfoN(); + if (pCallInfo == null) + { + return; + } + if (__pConfCallInfo != null) + { + delete __pConfCallInfo; + __pConfCallInfo = null; + } + __pConfCallInfo = new (std::nothrow) CallInfo(); + *__pConfCallInfo = *pCallInfo; + //Disable all key panels and redraw with new caller list + DisableAllControls(); + ActivatePanels(); +} + +void +ConfCallerListForm::DisableAllControls(void) +{ + Panel* pKeysPanel = static_cast(GetControl(IDC_CALLER1_PANEL)); + if (pKeysPanel != null) + { + pKeysPanel->SetShowState(false); + Label* pLineLabel1 = static_cast(GetControl(IDC__LINE_LABEL1)); + pLineLabel1->SetShowState(false); + pKeysPanel = null; + } + pKeysPanel = static_cast(GetControl(IDC_CALLER2_PANEL)); + if (pKeysPanel != null) + { + pKeysPanel->SetShowState(false); + Label* pLineLabel1 = static_cast(GetControl(IDC__LINE_LABEL2)); + pLineLabel1->SetShowState(false); + pKeysPanel = null; + } + pKeysPanel = static_cast(GetControl(IDC_CALLER3_PANEL)); + if (pKeysPanel != null) + { + pKeysPanel->SetShowState(false); + Label* pLineLabel1 = static_cast(GetControl(IDC__LINE_LABEL3)); + pLineLabel1->SetShowState(false); + pKeysPanel = null; + } + pKeysPanel = static_cast(GetControl(IDC_CALLER4_PANEL)); + if (pKeysPanel != null) + { + pKeysPanel->SetShowState(false); + Label* pLineLabel1 = static_cast(GetControl(IDC__LINE_LABEL4)); + pLineLabel1->SetShowState(false); + pKeysPanel = null; + } + pKeysPanel = static_cast(GetControl(IDC_CALLER5_PANEL)); + if (pKeysPanel != null) + { + pKeysPanel->SetShowState(false); + Label* pLineLabel1 = static_cast(GetControl(IDC__LINE_LABEL5)); + pLineLabel1->SetShowState(false); + pKeysPanel = null; + } +} + +void +ConfCallerListForm::ActivatePanels(void) +{ + IListT* pCallList = __pConfCallInfo->GetCallerList(); + int confCallCount = pCallList->GetCount(); + + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + String pContactNo; + result r = pCallList->GetAt(index, callInfo); + + pContactNo.Append(callInfo.GetContactNumber()); + //fetch contact details based on phone number + String* pDisplayName = callInfo.FetchCallerNameN(); + + if ((pDisplayName->IsEmpty()) || r != E_SUCCESS) + { + pDisplayName->Append(pContactNo); + } + + switch (index) + { + case 0: + { + ActivatePanelAndAddActionListener(IDC_CALLER1_PANEL,IDC__LINE_LABEL1,IDC_SPLIT_CALLER1,IDC_END_CALLER1 + ,IDC_CALLER1_LABEL,IDA_SPLIT_CALLER1,IDA_END_CALLER1,*pDisplayName); + } + break; + + case 1: + { + ActivatePanelAndAddActionListener(IDC_CALLER2_PANEL,IDC__LINE_LABEL2,IDC_SPLIT_CALLER2,IDC_END_CALLER2 + ,IDC_CALLER2_LABEL,IDA_SPLIT_CALLER2,IDA_END_CALLER2,*pDisplayName); + } + break; + + case 2: + { + ActivatePanelAndAddActionListener(IDC_CALLER3_PANEL,IDC__LINE_LABEL3,IDC_SPLIT_CALLER3,IDC_END_CALLER3 + ,IDC_CALLER3_LABEL,IDA_SPLIT_CALLER3,IDA_END_CALLER3,*pDisplayName); + } + break; + + case 3: + { + ActivatePanelAndAddActionListener(IDC_CALLER4_PANEL,IDC__LINE_LABEL4,IDC_SPLIT_CALLER4,IDC_END_CALLER4 + ,IDC_CALLER4_LABEL,IDA_SPLIT_CALLER4,IDA_END_CALLER4,*pDisplayName); + } + break; + + case 4: + { + ActivatePanelAndAddActionListener(IDC_CALLER5_PANEL,IDC__LINE_LABEL5,IDC_SPLIT_CALLER5,IDC_END_CALLER5 + ,IDC_CALLER5_LABEL,IDA_SPLIT_CALLER5,IDA_END_CALLER5,*pDisplayName); + } + break; + + default: + break; + } + + delete pDisplayName; + pDisplayName = null; + } +} + +void +ConfCallerListForm::ActivatePanelAndAddActionListener( const String& panelName, const String& lineLabelName, const String& splitButtonName, + const String& endButtonName, const String& callerLabelName, SplitConfCallerCmdIds splitCmdId, + EndConfCallerCmdIds EndCmdId, const String& displayName) +{ + Bitmap* pNormalSplitBitmap = null; + Bitmap* pPressSplitBitmap = null; + Bitmap* pNormalEndBitmap = null; + Bitmap* pPressEndBitmap = null; + + pNormalSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_NORMAL_BUTTON_ICON, + W_SPLIT_BITMAP, H_SPLIT_BITMAP); + pPressSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_PRESS_BUTTON_ICON, + W_SPLIT_BITMAP, H_SPLIT_BITMAP); + pNormalEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_NORMAL_BUTTON_ICON, + W_END_BITMAP, H_END_BITMAP); + pPressEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_PRESS_BUTTON_ICON, + W_END_BITMAP, H_END_BITMAP); + + bool isSplitAllowed = true; + if ((__pCallPresentor->IsSplitAllowed() == false) || (__pConfCallInfo->IsOnHold() == true)) + { + isSplitAllowed = false; + } + + Panel* pKeysPanel = static_cast(GetControl(panelName)); + if (pKeysPanel != null) + { + Button* pButtonSplit = static_cast(pKeysPanel->GetControl(splitButtonName)); + if (pButtonSplit != null) + { + pButtonSplit->SetActionId(splitCmdId); + pButtonSplit->AddActionEventListener(*this); + pButtonSplit->SetNormalBitmap(Point(0, 0), *pNormalSplitBitmap); + pButtonSplit->SetPressedBitmap(Point(0, 0), *pPressSplitBitmap); + } + Button* pButtonEnd = static_cast(pKeysPanel->GetControl(endButtonName)); + if (pButtonEnd != null) + { + pButtonEnd->SetActionId(EndCmdId); + pButtonEnd->AddActionEventListener(*this); + pButtonEnd->SetNormalBitmap(Point(0, 0), *pNormalEndBitmap); + pButtonEnd->SetPressedBitmap(Point(0, 0), *pPressEndBitmap); + } + Label* pNameLabel = static_cast(pKeysPanel->GetControl(callerLabelName)); + if (pButtonSplit != null) + { + if (isSplitAllowed == false) + { + pButtonSplit->SetShowState(false); + pNameLabel->SetBounds(pButtonSplit->GetBounds().x, pNameLabel->GetBounds().y, + pNameLabel->GetBounds().width, pNameLabel->GetBounds().height); + } + else + { + pButtonSplit->SetShowState(true); + pNameLabel->SetBounds((pButtonSplit->GetBounds().x + pButtonSplit->GetBounds().width), pNameLabel->GetBounds().y, + pNameLabel->GetBounds().width, pNameLabel->GetBounds().height); + } + } + pNameLabel->SetText(displayName); + + pKeysPanel->SetShowState(true); + Label* pLineLabel1 = static_cast(GetControl(lineLabelName)); + pLineLabel1->SetShowState(true); + + pKeysPanel->Draw(true); + pKeysPanel->Show(); + } + + delete pNormalEndBitmap; + pNormalEndBitmap = null; + delete pPressEndBitmap; + pPressEndBitmap = null; + delete pNormalSplitBitmap; + pNormalSplitBitmap = null; + delete pPressSplitBitmap; + pPressSplitBitmap = null; +} + +void +ConfCallerListForm::ShowTimerInfo(const String& timerLblName, long long startTime) +{ + Label* pTimerLbl = static_cast(GetControl(timerLblName)); + + if (__pConfCallTimer == null) + { + __pConfCallTimer = new (std::nothrow) Timer(); + __pConfCallTimer->Construct(*this); + } + + if (pTimerLbl != null) + { + //current system time + long long currTime = 0; + SystemTime::GetTicks(currTime); + //Set call duration + TimeSpan diffSpan(abs(startTime - currTime)); + + String activeCallTime(L""); + + long long hr = diffSpan.GetHours(); + if (hr <= 9) { + activeCallTime.Append("0"); + } + activeCallTime.Append(hr); + activeCallTime.Append(L":"); + + long long min = diffSpan.GetMinutes(); + if (min <= 9) { + activeCallTime.Append("0"); + } + activeCallTime.Append(min); + activeCallTime.Append(L":"); + + long long sec = diffSpan.GetSeconds(); + if (sec <= 9) { + activeCallTime.Append("0"); + } + activeCallTime.Append(sec); + + pTimerLbl->SetText(activeCallTime); + __pConfCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND); + + } +} + +void +ConfCallerListForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + //Call default implementation of "Object.Equals()" + //returns true, if they are pointing to same address. + if (__pConfCallTimer->Equals(timer)) + { + Label* pTimerLbl = static_cast(GetControl(IDC_CALL_TIME_LABEL)); + if (pTimerLbl) + { + String activeCallTime = pTimerLbl->GetText(); + // Create a StringTokenizer instance + StringTokenizer strTokens(activeCallTime, L":"); + + int count = strTokens.GetTokenCount(); // count == 3 + String token; + int sec = 0; + int min = 0; + int hr = 0; + for (int index = 0; index < count; index++) + { + switch (index) + { + case 0: + strTokens.GetNextToken(token); + Integer::Parse(token, hr); + break; + + case 1: + strTokens.GetNextToken(token); + Integer::Parse(token, min); + break; + + case 2: + strTokens.GetNextToken(token); + Integer::Parse(token, sec); + break; + } + } + //update all values + sec = sec + 1; + if (sec == IDI_MAX_SECONDS) + { + sec = 0; + min = min + 1; + } + if (min == IDI_MAX_MINS) + { + min = 0; + hr = hr + 1; + } + + //replace string + activeCallTime.Clear(); + if (hr <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(hr); + activeCallTime.Append(":"); + if (min <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(min); + activeCallTime.Append(":"); + if (sec <= 9) + { + activeCallTime.Append("0"); + } + activeCallTime.Append(sec); + //update timer label + pTimerLbl->SetText(activeCallTime); + pTimerLbl->Invalidate(true); + } + } +} diff --git a/src/PhnCustomItemBgElement.cpp b/src/PhnCustomItemBgElement.cpp new file mode 100644 index 0000000..f2e35f0 --- /dev/null +++ b/src/PhnCustomItemBgElement.cpp @@ -0,0 +1,46 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnCustomItemBgElement.cpp + * @brief Custom Background element class + */ +#include "PhnCustomItemBgElement.h" +#include "PhnSettingsConstants.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +CustomItemBgElement::CustomItemBgElement(void) +{ +} + +CustomItemBgElement::~CustomItemBgElement(void) +{ +} + +bool +CustomItemBgElement::OnDraw(Canvas& canvas, const Rectangle& rect, ListItemDrawingStatus itemStatus) +{ + //drawing boundary for all items. + canvas.SetBackgroundColor(Color(142,154,163)); + canvas.DrawRectangle(rect); + + //draw blue bg color + Rectangle blueHeaderRect(0,0,W_LEFT_HEADER_EXPAND_ITEMS,rect.height); + canvas.FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + return true; +} diff --git a/src/PhnDialAppForm.cpp b/src/PhnDialAppForm.cpp new file mode 100644 index 0000000..ddc02f9 --- /dev/null +++ b/src/PhnDialAppForm.cpp @@ -0,0 +1,128 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file DlAppForm.cpp + * @brief The Dial application form + */ + +#include +#include "PhnBaseForm.h" +#include "PhnCommonUtils.h" +#include "PhnCallPresentationModel.h" +#include "PhnDialAppForm.h" +#include "PhnPhoneApp.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::Base; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +const int DialAppForm::ID_HEADER_DIALER = 101; +const int DialAppForm::ID_HEADER_LOGS = 103; +static const wchar_t* IDL_DIAL_FORM = L"IDL_DIAL_FORM"; + +DialAppForm::DialAppForm(void) +{ +} + +DialAppForm::~DialAppForm(void) +{ +} + +bool +DialAppForm::Initialize(void) +{ + Construct(IDL_DIAL_FORM); + + return true; +} + +result +DialAppForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + pHeader->AddActionEventListener(*this); +/* __pFormFooter = GetFooter(); + __pFormFooter->AddActionEventListener(*this);*/ + // Setup back event listener + SetFormBackEventListener(this); + + return r; +} + +result +DialAppForm::OnTerminating(void) +{ + return E_SUCCESS; +} + +void +DialAppForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + switch (actionId) + { + case ID_HEADER_DIALER: + { + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + pPhoneApp->SetInitialScene(IDSCN_DIALER); + } + break; + + case ID_HEADER_LOGS: + { + + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + pPhoneApp->SetInitialScene(IDSCN_CALL_LOG); + + } + break; + + default: + break; + } +} + +void +DialAppForm::OnFormBackRequested(Form& source) +{ + //if this is add call senario, if there is no active call only then allow user to access call log + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + if(pCallPresentor->GetCurrentCallCount() == 0) + { + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); + } + else + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + pPhoneApp->SetInitialScene(IDSCN_DIALER); + } +} diff --git a/src/PhnDialContactInfo.cpp b/src/PhnDialContactInfo.cpp new file mode 100644 index 0000000..76d1087 --- /dev/null +++ b/src/PhnDialContactInfo.cpp @@ -0,0 +1,235 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialContactInfo.cpp + * @brief Dial Contact Info class + */ +#include "PhnDialContactInfo.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Base::Collection; + +DialContactInfo::DialContactInfo(void) { + __pDisplayName = null; + __pPhoneNumber = null; + __pThumbnail = null; + __pSearchKeyList = null; + //By default, value is '0' - indicates it is not fetched from call logs + __callLogDbId = 0; +} + +DialContactInfo* +DialContactInfo::CloneN(void) +{ + //Used to create new 'DialContactInfo' object which is clone of 'this' object. + //We cant use Copy Contructor, since we will need 2-phase constructor in this case. + + result r = E_SUCCESS; + DialContactInfo* cloneObj = new (std::nothrow) DialContactInfo(); + cloneObj->__pDisplayName = new (std::nothrow) String(*this->__pDisplayName); + cloneObj->__pPhoneNumber = new (std::nothrow) String(*this->__pPhoneNumber); + + //Thumbnail + if(this->__pThumbnail != null) + { + Bitmap& pSrcTn = *(this->__pThumbnail); + cloneObj->__pThumbnail = new (std::nothrow) Bitmap(); + r = cloneObj->__pThumbnail->Construct( pSrcTn, Rectangle(0, 0, pSrcTn.GetWidth(), pSrcTn.GetHeight())); + } + TryCatch(r == E_SUCCESS,,"Object Cloning failed"); + + //list of search key. + if(this->__pSearchKeyList != null && this->__pSearchKeyList->GetCount() > 0) + { + cloneObj->__pSearchKeyList = new (std::nothrow) ArrayList(SingleObjectDeleter); + r = cloneObj->__pSearchKeyList->Construct(); + TryCatch(r == E_SUCCESS,,"Object Cloning failed"); + + for (int index = 0; index < this->__pSearchKeyList->GetCount(); index++) + { + String* key = static_cast(this->__pSearchKeyList->GetAt(index)); + r = cloneObj->__pSearchKeyList->Add(new (std::nothrow) String(*key)); + TryCatch(r == E_SUCCESS,,"Object Cloning failed"); + } + } + + return cloneObj; + CATCH: + //failed + delete cloneObj; + cloneObj = null; + return cloneObj; +} + +DialContactInfo::~DialContactInfo(void) { + if(__pDisplayName != null) + { + delete __pDisplayName; + } + if(__pPhoneNumber != null) + { + delete __pPhoneNumber; + } + if(__pSearchKeyList != null) + { + __pSearchKeyList->RemoveAll(); + delete __pSearchKeyList; + } + if(__pThumbnail != null) + { + delete __pThumbnail; + } +} + +bool +DialContactInfo::Equals(const Object& obj) const +{ + DialContactInfo* objInfo = dynamic_cast(const_cast(&obj)); + if(objInfo != null && __pPhoneNumber->Equals(objInfo->GetPhoneNumber())) + { + return true; + } + return false; +} + +void +DialContactInfo::AddSearchKey(String& pSearchString) +{ + if(__pSearchKeyList == null) + { + __pSearchKeyList = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pSearchKeyList->Construct(); + } + __pSearchKeyList->Add(new (std::nothrow) String(pSearchString)); +} + +void +DialContactInfo::RemoveSearchKey(int index) +{ + if(__pSearchKeyList != null && index >= 0 && index < __pSearchKeyList->GetCount()) + { + __pSearchKeyList->RemoveAt(index); + } +} + +void +DialContactInfo::ReplaceSearchKey(int index, String& pSearchString) +{ + if(__pSearchKeyList != null && (index >= 0 && index < __pSearchKeyList->GetCount())) + { + __pSearchKeyList->RemoveAt(index); + __pSearchKeyList->InsertAt(new String(pSearchString),index); + } +} + +IList* +DialContactInfo::GetSearchKeyList(void) +{ + return __pSearchKeyList; +} + +String* +DialContactInfo::GetSearchKey(void) +{ + if(__pSearchKeyList != null && __pSearchKeyList->GetCount() > 0) + { + return (static_cast(__pSearchKeyList->GetAt(0))); + } + return null; +} + +void +DialContactInfo::SetDisplayName(String& pDisplayName) +{ + if(__pDisplayName != null) + { + delete __pDisplayName; + } + __pDisplayName = new (std::nothrow) String(pDisplayName); +} + +String& +DialContactInfo::GetDisplayName(void) const +{ + return *__pDisplayName; +} + +void +DialContactInfo::SetPhoneNumber(String& pPhoneNumber) +{ + if(__pPhoneNumber != null) + { + delete __pPhoneNumber; + } + __pPhoneNumber = new (std::nothrow) String(pPhoneNumber); +} + +String& +DialContactInfo::GetPhoneNumber(void) const +{ + return *__pPhoneNumber; +} + +void +DialContactInfo::SetThumbnail(Bitmap* pBitmap) +{ + if(__pThumbnail != null) + { + delete __pThumbnail; + __pThumbnail = null; + } + + if(pBitmap != null) + { + __pThumbnail = pBitmap; + __pThumbnail->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + __pThumbnail->Scale(Dimension(96, 96)); + } +} + +Bitmap* +DialContactInfo::GetThumbnailN(void) const +{ + Bitmap* pThumbnail = null; + result r = E_FAILURE; + if(__pThumbnail != null) + { + pThumbnail = new (std::nothrow) Bitmap(); + r = pThumbnail->Construct( *__pThumbnail, Rectangle(0, 0, __pThumbnail->GetWidth(), + __pThumbnail->GetHeight())); + TryCatch(r == E_SUCCESS,,"[%s] Thumbnail contruction failed", GetErrorMessage(r)); + } + return pThumbnail; + +CATCH: + delete pThumbnail; + return null; +} + +void +DialContactInfo::SetCallLogDbId(int callLogDbId) +{ + __callLogDbId = callLogDbId; +} + +int +DialContactInfo::GetCallLogDbId(void) +{ + return __callLogDbId; +} diff --git a/src/PhnDialPresentationModel.cpp b/src/PhnDialPresentationModel.cpp new file mode 100644 index 0000000..f21d5f0 --- /dev/null +++ b/src/PhnDialPresentationModel.cpp @@ -0,0 +1,296 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialPresentationModel.cpp + * @brief Dial presentation model class + */ +#include +#include "PhnAppUtility.h" +#include "PhnCalllogManager.h" +#include "PhnCommonUtils.h" +#include "PhnDialContactInfo.h" +#include "PhnDialPresentationModel.h" +#include "PhnPhoneApp.h" +#include "PhnSettingsManager.h" +#include "PhnTabDialer.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Social; + +DialPresentationModel::DialPresentationModel(DialTabDialer& pParentPanel) : __pParentPanel(pParentPanel) +{ + AppLogDebug("ENTER"); + __pNumberSuggestionList = null; + __pSearchString = null; + __pSettingsManager = null; + __pAsyncSearchTask = null; + __pSearchThread = null; + __mutex.Create(); + AppLogDebug("EXIT"); +} + +DialPresentationModel::~DialPresentationModel() +{ + AppLogDebug("ENTER"); + ClearSearchResults(); + AppLogDebug("EXIT"); +} + +void +DialPresentationModel::ClearSearchResults(void) +{ + if(__pNumberSuggestionList != null) + { + __mutex.Acquire(); + __pNumberSuggestionList->RemoveAll(); + delete __pNumberSuggestionList; + __pNumberSuggestionList = null; + __mutex.Release(); + } + if(__pSearchString != null) + { + delete __pSearchString; + __pSearchString = null; + } +} + +bool +DialPresentationModel::FetchSuggestionList(const String& searchString) +{ + bool newSearch = false; + if (__pSearchThread != null) + { + //Wait until the previous thread finished execution. + //otherwise "start_thread()" crashes. + __pSearchThread->Join(); + delete __pSearchThread; + __pSearchThread = null; + delete __pAsyncSearchTask; + __pAsyncSearchTask = null; + } + + result r = E_SUCCESS; + __pAsyncSearchTask = new (std::nothrow) RetrieveContactsListTask( *this); + //check if this search string is subset of previous search string + if(__pSearchString != null && searchString.StartsWith(*__pSearchString,0)) + { + newSearch = false; + __pSearchString->Clear(); + __pSearchString->Append(searchString); + __mutex.Acquire(); + r = __pAsyncSearchTask->Construct(*__pSearchString, __pNumberSuggestionList); + __mutex.Release(); + } + else + { + newSearch = true; + __pSearchString = new (std::nothrow) String(searchString); + r = __pAsyncSearchTask->Construct(*__pSearchString, null); + } + TryCatch(r == E_SUCCESS,,"Async Task construction failed"); + + //Start Async Task to search for contacts, call logs, Speed dial. + __pSearchThread = new (std::nothrow) Thread(); + r = __pSearchThread->Construct(*__pAsyncSearchTask); + TryCatch(r == E_SUCCESS,,"Thread construction failed"); + r = __pSearchThread->Start(); + TryCatch(r == E_SUCCESS,,"Failed to start Thread"); + + return newSearch; + +CATCH: + //clear previous search results + ClearSearchResults(); + delete __pAsyncSearchTask; + __pAsyncSearchTask = null; + delete __pSearchThread; + __pSearchThread = null; + return true; +} + +void +DialPresentationModel::HandleContactsRetrievalCompleted(IList* pContactsList) +{ + __mutex.Acquire(); + if(__pNumberSuggestionList != null) + { + __pNumberSuggestionList->RemoveAll(); + delete __pNumberSuggestionList; + __pNumberSuggestionList = null; + } + + if(pContactsList != null && pContactsList->GetCount() > 0) + { + //Taking Ownership of List. + __pNumberSuggestionList = static_cast(pContactsList); + + //inform Tab Dialer to update view. + DialContactInfo* pDialInfo = null; + //Fetch the contact's info at a given index + if (__pNumberSuggestionList != null && __pNumberSuggestionList->GetCount() > 0) + { + pDialInfo = static_cast(__pNumberSuggestionList->GetAt(0)); + } + + if(pDialInfo != null) + { + + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(); + + //display name, mobile number + String* argDisplayName = new (std::nothrow) String(); + argDisplayName->Append(pDialInfo->GetDisplayName()); + pArgs->Add(argDisplayName); + + String* argMobilNum = new (std::nothrow) String(); + argMobilNum->Append(pDialInfo->GetPhoneNumber()); + pArgs->Add(argMobilNum); + + //fetch total no. of results + String* argResCount = new (std::nothrow) String(); + argResCount->Append(__pNumberSuggestionList->GetCount()); + pArgs->Add(argResCount); + __pParentPanel.SendUserEvent(REQUEST_SHOW_SUGGESTION,pArgs); + } + } + else + { + //remove old search key + if(__pSearchString != null) + { + delete __pSearchString; + __pSearchString = null; + } + //Show "Add to contact" + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(); + __pParentPanel.SendUserEvent(REQUEST_SHOW_ADD_TO_CONTACTS,pArgs); + //empty list + delete pContactsList; + pContactsList = null; + } + __mutex.Release(); +} + +DialContactInfo* +DialPresentationModel::GetSuggestionAtIndex(int index) +{ + DialContactInfo* pDialInfo = null; + __mutex.Acquire(); + //Fetch the contact's info at a given index + if (__pNumberSuggestionList != null + && __pNumberSuggestionList->GetCount() > 0 + && (index >= 0 && index < __pNumberSuggestionList->GetCount())) + { + pDialInfo = static_cast(__pNumberSuggestionList->GetAt(index)); + } + __mutex.Release(); + return pDialInfo; +} + +int +DialPresentationModel::GetNumberOfSuggestions(void) +{ + int resultCount = 0; + if(__pNumberSuggestionList != null) + { + __mutex.Acquire(); + resultCount = __pNumberSuggestionList->GetCount(); + __mutex.Release(); + } + return resultCount; +} + +String* +DialPresentationModel::FetchSpeedDialNumberN(int rowId) +{ + if(__pSettingsManager == null) + { + __pSettingsManager = SettingsManager::GetInstance(); + } + return __pSettingsManager->GetMappedSpeedDialNumberN(rowId); +} + +String* +DialPresentationModel::FetchLatestNumberFromLogsN(void) +{ + String* pRetString = CallLogManager::GetInstance()->GetLatestCallLogFromDbN(); + return pRetString; +} + +void +DialPresentationModel::AddContactsToAddressBook(String& contactNumber) +{ + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(INPUT_TYPE_PHONE), new (std::nothrow) String(contactNumber)); + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_ADD); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + delete pAc; + } + + extraData.RemoveAll(true); +} + +void +DialPresentationModel::OpenMessagingAppControl(String& contactNumber) +{ + //launch message + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE)); + extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(contactNumber)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + delete pAc; + } + extraData.RemoveAll(true); +} + +void +DialPresentationModel::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId, AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData) +{ + if (appId.Equals(String(PROVIDER_ID_CONTACTS)) && operationId.Equals(String(OPERATION_ID_ADD))) + { + if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) + { + //delete search string to start new search + if(__pSearchString != null) + { + delete __pSearchString; + __pSearchString = null; + } + //Fetch latest added contact and show in suggestion list. + __pParentPanel.UpdateSearchResults(); + } + } + +} diff --git a/src/PhnDialerKeypad.cpp b/src/PhnDialerKeypad.cpp new file mode 100644 index 0000000..9dea3b6 --- /dev/null +++ b/src/PhnDialerKeypad.cpp @@ -0,0 +1,475 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDialerKeypad.cpp + * @brief Dial Contact Info class + */ +#include "PhnDialerKeypad.h" +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" +#include "PhnPhoneApp.h" +#include "PhnTabDialer.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Collection; + +//Constants +const wchar_t* IDI_CANCEL_KEY_TXT = L"Cancel"; +const wchar_t* IDC_VIDEOCALL_KEY_NAME = L"IDC_BUTTON13"; +const wchar_t* IDC_CALL_KEY_NAME = L"IDC_BUTTON14"; +const wchar_t* IDC_BUTTON_NAME = L"IDC_BUTTON"; +static const wchar_t* IDC_PANEL_DISPLAY_DATA = L"IDC_PANEL_DISPLAY_DATA"; +const int W_VOICEMAIL_ICON = 75; +const int H_VOICEMAIL_ICON = 75; +const int W_STAR_ICON = 75; +const int H_STAR_ICON = 75; +const int W_MUTE_ICON = 64; +const int H_MUTE_ICON = 64; +const int W_VIDEOCALL_ICON = 76; +const int H_VIDEOCALL_ICON = 76; +const int W_CALL_ICON = 76; +const int H_CALL_ICON = 76; +const int W_CLEAR_ICON = 76; +const int H_CLEAR_ICON = 44; +const int X_CALL_KEY = 12; +const int MAX_SLIDEDOWN_PIXELS = 110; + +DialerKeypad::DialerKeypad(DialerState openedState) : Panel() +{ + __openedState = openedState; + __pParentActionListener = null; + __pParentLongTapListener = null; + __pLongPressDetectors = null; +} + +DialerKeypad::~DialerKeypad(void) +{ + if(__pLongPressDetectors != null) + { + __pLongPressDetectors->RemoveAll(); + delete __pLongPressDetectors; + } + //remove all child controls + RemoveAllControls(); +} + +bool +DialerKeypad::ConstructPanel(IActionEventListener* pActionListener, ITouchLongPressGestureEventListener* pLongTapListener) +{ + result r = E_FAILURE; + TryCatch(pActionListener != null,,"pActionListener is null"); + TryCatch(pLongTapListener != null,,"pLongTapListener is null"); + + //set parent panel which acts as action listener + __pParentActionListener = pActionListener; + __pParentLongTapListener = pLongTapListener; + + r = Construct(IDL_DIALER_KEYPAD_PANEL); + TryCatch(r == E_SUCCESS, , "Panel::Construct() failed"); + + if(__openedState == DIALER_STATE_EMERGENCY_APPCONTROL) + { + //no video call or cancel button is shown for Emergency Screen + Button* pVideoCallButton = static_cast(GetControl(IDC_VIDEOCALL_KEY_NAME, true)); + if (pVideoCallButton != null) + { + RemoveControl(*pVideoCallButton); + pVideoCallButton = null; + } + } + //Add action listener and long press gesture listeners. + AddListenersToButtons(); + + return true; +CATCH: + return false; +} + +result +DialerKeypad::OnInitializing(void) +{ + result r = E_SUCCESS; + if(__openedState == DIALER_STATE_EMERGENCY_APPCONTROL) + { + //reset size and position for emergency dial form + Rectangle rect = GetBounds(); + rect.y = rect.y + MAX_SLIDEDOWN_PIXELS; + r = SetBounds(rect); + //reset position and size for call button + Button* pCallButton = static_cast(GetControl(IDC_CALL_KEY_NAME, true)); + Rectangle callRect = pCallButton->GetBounds(); + callRect.x = X_CALL_KEY; + callRect.width += pCallButton->GetBounds().width + X_CALL_KEY; + r = pCallButton->SetBounds(callRect); + } + + RelativeLayout* pRelativeLayout = dynamic_cast(GetParent()->GetLandscapeLayoutN()); + Panel* pDisplayPanel = static_cast(GetParent()->GetControl(IDC_PANEL_DISPLAY_DATA, true)); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetRelation(*this, *pDisplayPanel, RECT_EDGE_RELATION_TOP_TO_BOTTOM); + pRelativeLayout->SetRelation(*this, *GetParent(), RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + delete pRelativeLayout; + } + + pRelativeLayout = dynamic_cast(GetParent()->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetRelation(*this, *pDisplayPanel, RECT_EDGE_RELATION_TOP_TO_BOTTOM); + pRelativeLayout->SetRelation(*this, *GetParent(), RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + delete pRelativeLayout; + } + + //initialize buttons + SetBitmapToKeypadButtons(); + Draw(true); + Show(); + return r; +} + +void +DialerKeypad::AddListenersToButtons(void) +{ + //Construct array to store LongPress touch detectors + __pLongPressDetectors = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pLongPressDetectors->Construct(14); + for (int i = 1; i <= 15; i++) + { + //initialize buttons and add action listener + String buttonName(IDC_BUTTON_NAME); + buttonName.Append(i); + Button* pButton = static_cast(GetControl(buttonName, true)); + if(pButton == null) + { + continue; + } + //check if cancel button is shown instead of video call button + if((i == VIDEOCALL_KEY) && (IsShowCancelButton() == true)) + { + pButton->SetActionId(CANCEL_KEY); + } + else + { + pButton->SetActionId(i); + } + SetControlAlwaysOnTop(*pButton,true); + + //Add Listeners + if(__pParentActionListener != null) + { + pButton->AddActionEventListener(*__pParentActionListener); + } + + if(__pParentLongTapListener != null) + { + //If __openedState is Emergency Call AppControl then add LongPress detector for only 'CLEAR_KEY'. + if ( (i == NUM_KEY1 && (IsShowVoiceMailIcon() == true)) + || ((i >= NUM_KEY2 && i <= HASH_KEY) && (__openedState != DIALER_STATE_EMERGENCY_APPCONTROL)) + || (i == CLEAR_KEY) ) + { + //Construct and Add gesture detector to "0-9,P,#,Clear" buttons + TouchLongPressGestureDetector* pLongPressDetector = new (std::nothrow) TouchLongPressGestureDetector(); + pLongPressDetector->Construct(); + pLongPressDetector->SetCancelTouchEventOnSuccessEnabled(true); + pLongPressDetector->AddLongPressGestureEventListener(*__pParentLongTapListener); + pButton->AddGestureDetector(*pLongPressDetector); + //stored in an array list + __pLongPressDetectors->Add(pLongPressDetector); + } + } + } +} + +void +DialerKeypad::SetBitmapToKeypadButtons(void) +{ + AppLogDebug("ENTER"); + //Create the buttons of the keypad + for (int i = 1; i <= 15; i++) + { + //initialize buttons and add action listener + String buttonName(IDC_BUTTON_NAME); + buttonName.Append(i); + Button* pButton = static_cast(GetControl(buttonName, true)); + if(pButton == null) + { + continue; + } + + //Draw text/image and background in a canvas and add it to the button + Rectangle canvasRect(0, 0, pButton->GetBounds().width, pButton->GetBounds().height); + Canvas* pCanvasNormal = new (std::nothrow) Canvas(); + pCanvasNormal->Construct(canvasRect); + Canvas* pCanvasPressed = new (std::nothrow) Canvas(); + pCanvasPressed->Construct(canvasRect); + + String number(DialUtil::ConvertDialedNumberToString(pButton->GetActionId())); + switch (pButton->GetActionId()) + { + case NUM_KEY1: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + //Set canvas for pressed state of the button + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + if(IsShowVoiceMailIcon() == true) + { + DialUtil::DrawImageToCanvas(IDB_VOICEMAIL_BTN_ICON, Dimension(W_VOICEMAIL_ICON, H_VOICEMAIL_ICON), *pCanvasNormal, POSITION_RIGHT); + DialUtil::DrawImageToCanvas(IDB_VOICEMAIL_BTN_PRESS_ICON, Dimension(W_VOICEMAIL_ICON, H_VOICEMAIL_ICON), *pCanvasPressed, POSITION_RIGHT); + } + } + break; + + case NUM_KEY2: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY2_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY2_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY3: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY3_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY3_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY4: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE2_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY4_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY4_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY5: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE2_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY5_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY5_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY6: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE2_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY6_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY6_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY7: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE3_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY7_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY7_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY8: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE3_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY8_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY8_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY9: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE3_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_KEY9_TXT, FONT_KEYPAD_TEXT, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(IDI_KEY9_TXT, FONT_KEYPAD_TEXT, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case PAUSE_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE4_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_STAR_ICON, Dimension(W_STAR_ICON, H_STAR_ICON), *pCanvasNormal, POSITION_LEFT); + DialUtil::DrawTextToCanvas(L"P", FONT_KEYPAD_P, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_STAR_ICON, Dimension(W_STAR_ICON, H_STAR_ICON), *pCanvasPressed, POSITION_LEFT); + DialUtil::DrawTextToCanvas(L"P", FONT_KEYPAD_P, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY0: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE4_ICON); + DialUtil::DrawTextToCanvas(L"0", FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(L"+", FONT_KEYPAD_PLUS, *pCanvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(L"0", FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawTextToCanvas(L"+", FONT_KEYPAD_PLUS, *pCanvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case HASH_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE4_ICON); + DialUtil::DrawTextToCanvas(L"#", FONT_KEYPAD_NUMBER, *pCanvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawImageToCanvas(IDB_DIALER_MUTE_ICON, Dimension(W_MUTE_ICON, H_MUTE_ICON), *pCanvasNormal, POSITION_RIGHT); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(L"#", FONT_KEYPAD_NUMBER, *pCanvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DialUtil::DrawImageToCanvas(IDB_DIALER_MUTE_ICON, Dimension(W_MUTE_ICON, H_MUTE_ICON), *pCanvasPressed, POSITION_RIGHT); + } + break; + + case VIDEOCALL_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE5_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_VIDEOCALL_ICON, Dimension(W_VIDEOCALL_ICON, H_VIDEOCALL_ICON), *pCanvasNormal, POSITION_CENTER); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_VIDEOCALL_ICON, Dimension(W_VIDEOCALL_ICON, H_VIDEOCALL_ICON), *pCanvasPressed, POSITION_CENTER); + } + break; + + case CANCEL_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE5_ICON); + DialUtil::DrawTextToCanvas(IDI_CANCEL_KEY_TXT, FONT_KEYPAD_CANCEL, *pCanvasNormal, POSITION_CENTER, BUTTON_STATUS_NORMAL); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawTextToCanvas(IDI_CANCEL_KEY_TXT, FONT_KEYPAD_CANCEL, *pCanvasPressed, POSITION_CENTER, BUTTON_STATUS_NORMAL); + } + break; + + case CALL_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_CALL_BG_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_CALL_ICON, Dimension(W_CALL_ICON, H_CALL_ICON), *pCanvasNormal, POSITION_CENTER); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_CALL_ICON, Dimension(W_CALL_ICON, H_CALL_ICON), *pCanvasPressed, POSITION_CENTER); + } + break; + + case CLEAR_KEY: + { + DialUtil::Draw9PatchToCanvas(*pCanvasNormal, IDB_DIALER_BTN_LINE5_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_CLEAR_ICON, Dimension(W_CLEAR_ICON, H_CLEAR_ICON), *pCanvasNormal, POSITION_CENTER); + + DialUtil::Draw9PatchToCanvas(*pCanvasPressed, IDB_DIALER_BTN_PRESS_ICON); + DialUtil::DrawImageToCanvas(IDB_DIALER_CLEAR_ICON, Dimension(W_CLEAR_ICON, H_CLEAR_ICON), *pCanvasPressed, POSITION_CENTER); + } + break; + } + + //Set the final Bitmap to Button + DialUtil::DrawCanvasToButton(pCanvasNormal, pCanvasPressed, pButton); + delete pCanvasNormal; + pCanvasNormal = null; + delete pCanvasPressed; + pCanvasPressed = null; + } + AppLogDebug("EXIT"); + return; +} + +bool +DialerKeypad::IsShowCancelButton(void) +{ + //'Cancel' is shown instead of 'Video Call' when opened in 'DIALER_STATE_ADD_CALL'. + bool isShowCancel = false; + if (__openedState == DIALER_STATE_ADD_CALL) + { + isShowCancel = true; + } + return isShowCancel; +} + +bool +DialerKeypad::IsShowVoiceMailIcon(void) +{ + //voice mail icon is not shown when opened from any APPCONTROL or from DIALER_STATE_ADD_CALL. + bool isShowVoiceMail = false; + if (__openedState == DIALER_STATE_FIRST_SCENE) + { + isShowVoiceMail = true; + } + return isShowVoiceMail; +} + +bool +DialerKeypad::IsShowVideoCallButton(void) +{ + //video call button is shown in 'DIALER_STATE_FIRST_SCENE' , 'DIALER_STATE_NORMAL_APPCONTROL'. + bool isShowVideoCall = true; + if ((__openedState == DIALER_STATE_EMERGENCY_APPCONTROL) || (__openedState == DIALER_STATE_ADD_CALL)) + { + isShowVideoCall = false; + } + return isShowVideoCall; +} + +result +DialerKeypad::OnTerminating(void) +{ + for (int index = 0; index < __pLongPressDetectors->GetCount(); index++) + { + TouchLongPressGestureDetector* pLongPressDetector = static_cast(__pLongPressDetectors->GetAt(index)); + Button* pButton = static_cast(pLongPressDetector->GetControl()); + pButton->RemoveGestureDetector(*pLongPressDetector); + } + return E_SUCCESS; +} diff --git a/src/PhnDtmfKeypadPanel.cpp b/src/PhnDtmfKeypadPanel.cpp new file mode 100644 index 0000000..4452428 --- /dev/null +++ b/src/PhnDtmfKeypadPanel.cpp @@ -0,0 +1,535 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnDtmfKeypadPanel.cpp + * @brief Dtmf keypad implementation class + */ +#include +#include +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" +#include "PhnDtmfKeypadPanel.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +const int W_VOICE_CALL_ICON = 70; +const int H_VOICE_CALL_ICON = 36; +const int INITIAL_X_OFFSET = 13; +const int LEFT_X_OFFSET = 77; +const int RIGHT_X_OFFSET = 121; +const int INITIAL_TEXT_X_OFFSET = 24; +const int LEFT_TEXT_X_OFFSET = 64; +const int LEFT_TEXT_X_MARGIN = 18; +const int RIGHT_TEXT_X_OFFSET = 94; +const Color COLOR_KEYPAD_BG(0, 0, 0, 100); +const wchar_t* IDC_TEXTBOX = L"IDC_TEXTBOX"; +const wchar_t* IDC_BUTTON = L"IDC_BUTTON"; + +DtmfKeyPadPanel::DtmfKeyPadPanel(void) +{ + __pActionListener = null; +} + +DtmfKeyPadPanel::~DtmfKeyPadPanel(void) +{ +} + +bool +DtmfKeyPadPanel::Initialize(IActionEventListener* pEventListener, Rectangle& boundsRect) +{ + result r = Construct(IDL_DTMF_PANEL); + if (IsFailed(r)) + { + return false; + } + r = SetBounds(boundsRect); + if (IsFailed(r)) + { + return false; + } + __pActionListener = pEventListener; + //Add action listener. + AddListenersToButtons(); + return true; +} + +result +DtmfKeyPadPanel::OnInitializing(void) +{ + result r = SetBackgroundtoButton(); + return r; +} + +void +DtmfKeyPadPanel::AddListenersToButtons() +{ + for (int i = NUM_KEY1; i <= HASH_KEY; ++i) + { + String buttonName(IDC_BUTTON); + buttonName.Append(i); + Button* pButton = static_cast(GetControl(buttonName, true)); + if(pButton == null) + { + continue; + } + pButton->SetActionId(i); + SetControlAlwaysOnTop(*pButton,true); + //Add Listeners + if(__pActionListener != null) + { + pButton->AddActionEventListener(*__pActionListener); + } + } +} + +result +DtmfKeyPadPanel::SetBackgroundtoButton() +{ + AppLogDebug("ENTER"); + result r = E_FAILURE; + for (int i = 1; i <= 12; i++) + { + String buttonName(IDC_BUTTON); + buttonName.Append(i); + Button* pButton = static_cast(GetControl(buttonName,true)); + if(pButton == null) + { + continue; + } + + Rectangle canvasRect(0, 0, pButton->GetBounds().width, pButton->GetBounds().height); + Canvas canvasNormal; + canvasNormal.Construct(canvasRect); + Canvas canvasPressed; + canvasPressed.Construct(canvasRect); + + String number(DialUtil::ConvertDialedNumberToString(pButton->GetActionId())); + switch (pButton->GetActionId()) + { + case NUM_KEY1: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawImageToCanvas(IDB_KEYPAD_NUM1_ICON, Dimension(W_VOICE_CALL_ICON, H_VOICE_CALL_ICON), canvasNormal, POSITION_RIGHT); + + //Set canvas for pressed state of the button + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawImageToCanvas(IDB_KEYPAD_NUM1_ICON, Dimension(W_VOICE_CALL_ICON, H_VOICE_CALL_ICON), canvasPressed, POSITION_RIGHT); + } + break; + + case NUM_KEY2: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY2_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + //Set canvas for pressed state of the button + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY2_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY3: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY3_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY3_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY4: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY4_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY4_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY5: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY5_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY5_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY6: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY6_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY6_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY7: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY7_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY7_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY8: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY8_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY8_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY9: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(IDI_KEY9_TXT, FONT_KEYPAD_TEXT, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(number, FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(IDI_KEY9_TXT, FONT_KEYPAD_TEXT, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case PAUSE_KEY: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawImageToCanvas(IDB_DIALER_STAR_ICON, Dimension(75, 36), canvasNormal, POSITION_LEFT); + DrawTextToCanvas(L"P", FONT_KEYPAD_P, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawImageToCanvas(IDB_DIALER_STAR_ICON, Dimension(75, 36), canvasPressed, POSITION_LEFT); + DrawTextToCanvas(L"P", FONT_KEYPAD_P, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case NUM_KEY0: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(L"0", FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + DrawTextToCanvas(L"+", FONT_KEYPAD_PLUS, canvasNormal, POSITION_RIGHT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(L"0", FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + DrawTextToCanvas(L"+", FONT_KEYPAD_PLUS, canvasPressed, POSITION_RIGHT, BUTTON_STATUS_PRESSED); + } + break; + + case HASH_KEY: + { + r = ConstructButtonCanvas(canvasNormal, pButton, IDB_KEYPAD_BUTTON_NORMAL, BUTTON_STATUS_NORMAL); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(L"#", FONT_KEYPAD_NUMBER, canvasNormal, POSITION_LEFT, BUTTON_STATUS_NORMAL); + + r = ConstructButtonCanvas(canvasPressed, pButton, IDB_KEYPAD_BUTTON_PRESS, BUTTON_STATUS_PRESSED); + TryCatch(r == E_SUCCESS,,"DtmfKeyPadPanel::AddButtonsToKeypad() ConstructButtonCanvas failed"); + DrawTextToCanvas(L"#", FONT_KEYPAD_NUMBER, canvasPressed, POSITION_LEFT, BUTTON_STATUS_PRESSED); + } + + break; + } + //Set the final Bitmap to Button + DialUtil::DrawCanvasToButton(&canvasNormal, &canvasPressed, pButton); + } + + AppLogDebug("EXIT"); + return E_SUCCESS; + +CATCH: + RemoveAllControls(); + return r; +} + +result +DtmfKeyPadPanel::ConstructButtonCanvas(Canvas& canvas, Button* pButton, const String& bgImg, int buttonStatus) +{ + if (pButton == null) + { + return E_FAILURE; + } + + //Construct a canvas + AppResource* pAppResource = AppResource::GetInstance(); + Bitmap* pBitmap = pAppResource->GetBitmapN(bgImg); + if (pBitmap == null) + { + return E_FAILURE; + } + + if (pBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(canvas.GetBounds(), *pBitmap); + } + else + { + if (buttonStatus == BUTTON_STATUS_NORMAL) + { + pButton->SetNormalBackgroundBitmap(*pBitmap); + } + else + { + pButton->SetPressedBackgroundBitmap(*pBitmap); + } + } + delete pBitmap; + return E_SUCCESS; +} + +void +DtmfKeyPadPanel::DrawImageToCanvas(const String& image, Dimension imageDimention, Canvas& canvas, int pos) +{ + //create and scale bitmap + AppResource* pAppResource = AppResource::GetInstance(); + Bitmap* pBitmap = pAppResource->GetBitmapN(image); + pBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pBitmap->Scale(imageDimention); + + //Find position to draw bitmap + Point bitmapPos(0, 0); + switch (pos) + { + case POSITION_LEFT: + { + bitmapPos.SetPosition(INITIAL_X_OFFSET + (LEFT_X_OFFSET - pBitmap->GetWidth()) / 2, (canvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + + case POSITION_RIGHT: + { + bitmapPos.SetPosition(INITIAL_X_OFFSET + LEFT_X_OFFSET + ((RIGHT_X_OFFSET - pBitmap->GetWidth()) / 2), (canvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + + case POSITION_CENTER: + { + bitmapPos.SetPosition((canvas.GetBounds().width - pBitmap->GetWidth()) / 2, (canvas.GetBounds().height - pBitmap->GetHeight()) / 2); + } + break; + } + + //draw bitmap + canvas.DrawBitmap(Rectangle(bitmapPos, Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap); + delete pBitmap; + pBitmap = null; +} + +void +DtmfKeyPadPanel::DrawTextToCanvas(const String& buttonText, int textFontStyle, Canvas& canvas, int pos, int buttonStatus) +{ + if (buttonText == null) + { + return; + } + + //get text font + Font* font = GetTextFontN(textFontStyle); + + //get text color + Color* textColor = GetTextColorN(textFontStyle, buttonStatus); + + //create text element + TextElement* pTextElement = new (std::nothrow) TextElement(); + pTextElement->Construct(buttonText); + pTextElement->SetTextColor(*textColor); + pTextElement->SetFont(*font); + + //get dimensions of the text + Dimension textDimension; + font->GetTextExtent(buttonText, buttonText.GetLength(), textDimension); + textDimension.height = textDimension.height + font->GetDescender(); + //create enriched text + EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText(); + pEnrichedText->Construct(textDimension); + pEnrichedText->Add(*pTextElement); + + //set the position of the text in canvas + Point textPos(0, 0); + switch (pos) + { + case POSITION_LEFT: + { + textPos.SetPosition(INITIAL_TEXT_X_OFFSET + ((LEFT_TEXT_X_OFFSET - pEnrichedText->GetWidth()) / 2), (canvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_RIGHT: + { + textPos.SetPosition(INITIAL_TEXT_X_OFFSET + LEFT_TEXT_X_OFFSET + LEFT_TEXT_X_MARGIN + ((RIGHT_TEXT_X_OFFSET - pEnrichedText->GetWidth()) / 2), (canvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + + case POSITION_CENTER: + { + textPos.SetPosition((canvas.GetBounds().width - pEnrichedText->GetWidth()) / 2, (canvas.GetBounds().height - pEnrichedText->GetHeight()) / 2); + } + break; + } + + //Draw EnrichedText to canvas + canvas.DrawText(textPos, *pEnrichedText); + + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + delete textColor; + delete font; +} + +Font* +DtmfKeyPadPanel::GetTextFontN(int textFontStyle) +{ + Font* font = new (std::nothrow) Font(); + + switch (textFontStyle) + { + case FONT_CALLING_TEXT: + { + font->Construct(FONT_STYLE_PLAIN, 94); + } + break; + + case FONT_KEYPAD_NUMBER: + { + font->Construct(FONT_STYLE_PLAIN, 112); + } + break; + + case FONT_KEYPAD_TEXT: + { + font->Construct(FONT_STYLE_PLAIN, 32); + } + break; + + case FONT_KEYPAD_P: + case FONT_KEYPAD_PLUS: + { + font->Construct(FONT_STYLE_PLAIN, 64); + } + break; + + case FONT_KEYPAD_CANCEL: + { + font->Construct(FONT_STYLE_PLAIN, 34); + } + break; + } + return font; +} + +Color* +DtmfKeyPadPanel::GetTextColorN(int textColor, int buttonStatus) +{ + Color* color = new (std::nothrow) Color(); + + if (buttonStatus == BUTTON_STATUS_PRESSED) + { + color->SetColorComponents(249, 249, 249); + return color; + } + + switch (textColor) + { + case FONT_CALLING_TEXT: + { + color->SetColorComponents(0, 0, 0); + } + break; + + case FONT_KEYPAD_NUMBER: + { + color->SetColorComponents(255, 255, 255); + } + break; + + case FONT_KEYPAD_TEXT: + case FONT_KEYPAD_P: + case FONT_KEYPAD_PLUS: + { + color->SetColorComponents(148, 177, 200); + } + break; + + case FONT_KEYPAD_CANCEL: + { + color->SetColorComponents(255, 255, 255); + } + break; + } + return color; +} + +result +DtmfKeyPadPanel::OnTerminating(void) +{ + result r = E_SUCCESS; + RemoveAllControls(); + return r; +} diff --git a/src/PhnEmergencyDialForm.cpp b/src/PhnEmergencyDialForm.cpp new file mode 100644 index 0000000..814353f --- /dev/null +++ b/src/PhnEmergencyDialForm.cpp @@ -0,0 +1,346 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnEmergencyDialForm.cpp + * @brief Base class for all Call forms + */ +#include +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" +#include "PhnCallPresentationModel.h" +#include "PhnDialerKeypad.h" +#include "PhnErrorMsgPopup.h" +#include "PhnEmergencyDialForm.h" +#include "PhnPhoneApp.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; + +//resources +const wchar_t* IDL_EMERGENCY_DIAL_FORM = L"IDL_EMERGENCY_DIAL_FORM"; +const wchar_t* IDC_LABEL_EMERGENCY = L"IDC_LABEL_EMERGENCY"; +const wchar_t* IDC_PANEL_EMERGENCY_DISPLAY_DATA = L"IDC_PANEL_EMERGENCY_DISPLAY_DATA"; +const wchar_t* IDC_EDITFIELD_NUMBER = L"IDC_EDITFIELD_NUMBER"; +//color +const unsigned int COLOR_LABEL_BG = Color32<43, 107, 144>::Value; +const int MAX_NUMBER_WITH_SEPERATOR = 11; +const int MIN_NUMBER_WITH_TWO_SEPERATOR = 7; +const int MIN_NUMBER_WITH_ONE_SEPERATOR = 3; +const int MAX_TXT_LENGTH_WITH_SEPERATOR = 12; +const int MAX_VISIBLE_TXT_WITH_MIN_FONT = 18; +const int IDI_DELTA_FONT_SIZE = 5; +const int IDI_MAX_TXT_FONT = 94; +const int IDI_MIN_TXT_FONT = 67; +const int IDI_MAX_LIMIT_LENGTH = 18; + +EmergencyDialForm::EmergencyDialForm(void) +{ + __pDialKeypad = null; + __pErrorMsgPopup = null; +} + +EmergencyDialForm::~EmergencyDialForm(void) +{ + if(__pDialKeypad != null) + { + //RemoveControl() also deletes the child control. + RemoveControl(*__pDialKeypad); + __pDialKeypad = null; + } +} + +bool +EmergencyDialForm::Initialize(void) +{ + Construct(IDL_EMERGENCY_DIAL_FORM); + return true; +} + +result +EmergencyDialForm::OnInitializing(void) +{ + result r = E_SUCCESS; + ConstructKeypad(); + return r; +} + +void +EmergencyDialForm::ConstructKeypad(void) +{ + AppLogDebug("ENTER"); + //Construct Alpha numeric Keypad + if(__pDialKeypad == null) + { + __pDialKeypad = new (std::nothrow) DialerKeypad(DialerKeypad::DIALER_STATE_EMERGENCY_APPCONTROL); + __pDialKeypad->ConstructPanel(this, this); + AddControl(*__pDialKeypad); + } + AppLogDebug("EXIT"); + return; +} + +void +EmergencyDialForm::ShowFormattedText(EditField* pEditField, int actionId) +{ + AppLogDebug("ENTER"); + String contactNumber = pEditField->GetText(); + contactNumber.Replace(L"-",L""); + if(actionId == CLEAR_KEY) + { + contactNumber.Remove(contactNumber.GetLength() - 1, 1); + } + else + { + contactNumber.Append(DialUtil::ConvertDialedNumberToString(actionId)); + } + + int textLength = contactNumber.GetLength(); + if(textLength == 0) + { + pEditField->Clear(); + AppLogDebug("EXIT"); + return; + } + //Insert separator if required + if(textLength < MAX_NUMBER_WITH_SEPERATOR) + { + if(textLength > MIN_NUMBER_WITH_TWO_SEPERATOR) + { + contactNumber.Insert(L"-",MIN_NUMBER_WITH_TWO_SEPERATOR); + } + if(textLength > MIN_NUMBER_WITH_ONE_SEPERATOR) + { + contactNumber.Insert(L"-",MIN_NUMBER_WITH_ONE_SEPERATOR); + } + } + //update text length + textLength = contactNumber.GetLength(); + //need to change font to fit inside text box + //With size 94 -> 12 chars, 67 -> 18 chars + int fontSize = pEditField->GetTextSize(); + if((actionId == CLEAR_KEY) && (textLength <= MAX_VISIBLE_TXT_WITH_MIN_FONT)) + { + //clearing + fontSize += IDI_DELTA_FONT_SIZE; + } + else if(textLength > MAX_TXT_LENGTH_WITH_SEPERATOR) + { + //appending + fontSize -= IDI_DELTA_FONT_SIZE; + } + + if(fontSize > IDI_MAX_TXT_FONT) + { + fontSize = IDI_MAX_TXT_FONT; + } + if(fontSize < IDI_MIN_TXT_FONT) + { + fontSize = IDI_MIN_TXT_FONT; + } + pEditField->SetTextSize(fontSize); + //set text to edit field + pEditField->SetText(contactNumber); + + AppLogDebug("EXIT"); + return; +} + +void +EmergencyDialForm::OnActionPerformed(const Control& source, int actionId) +{ + EditField* pEditField = static_cast(GetControl(IDC_EDITFIELD_NUMBER, true)); + if (pEditField == null) + { + return; + } + + switch (actionId) + { + case NUM_KEY1: + case NUM_KEY2: + case NUM_KEY3: + case NUM_KEY4: + case NUM_KEY5: + case NUM_KEY6: + case NUM_KEY7: + case NUM_KEY8: + case NUM_KEY9: + case NUM_KEY0: + case CLEAR_KEY: + { + if(pEditField->GetTextLength() >= IDI_MAX_LIMIT_LENGTH && actionId != CLEAR_KEY) + { + //Maximum capacity reached, Don't append any more numbers. + AppLogDebug("EXIT"); + return; + } + //append / clear last character to contact + ShowFormattedText(pEditField, actionId); + } + break; + + case CALL_KEY: + { + if (pEditField->GetTextLength() > 0) + { + String contactNo = pEditField->GetText(); + contactNo.Replace(L"-",L""); + SwitchToOutgoingCallScreen(contactNo); + return; + } + } + break; + + case PAUSE_KEY: + { + pEditField->AppendText(L"*"); + } + break; + + case HASH_KEY: + { + pEditField->AppendText(L"#"); + } + break; + + case VIDEOCALL_KEY: + { + //Not yet Supported + } + break; + + case CANCEL_KEY: + { + PhoneApp* pApp = static_cast(UiApp::GetInstance()); + pApp->Terminate(); + } + break; + + default: + break; + } + pEditField->Invalidate(false); + + return; +} + +void +EmergencyDialForm::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector) +{ + if (gestureDetector.GetControl() != null) + { + Button* pButton = static_cast(gestureDetector.GetControl()); + int actionId = pButton->GetActionId(); + switch(actionId) + { + case CLEAR_KEY: + { + EditField* pEditField = static_cast(GetControl(IDC_EDITFIELD_NUMBER, true)); + if (pEditField != null && pEditField->GetTextLength() > 0) + { + pEditField->Clear(); + pEditField->SetTextSize(IDI_MAX_TXT_FONT); + pEditField->Invalidate(false); + } + } + break; + } + } +} + +result +EmergencyDialForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +EmergencyDialForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ +} + +void +EmergencyDialForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +void +EmergencyDialForm::SwitchToOutgoingCallScreen(const String& contactNumber) +{ + AppLogDebug("ENTER"); + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + //Check if dialing a call is possible + bool isSimInitialized = pCallPresentor->CheckSimInitializationIsCompleted(); + if (isSimInitialized) + { + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(contactNumber); + //switch to dialing outgoing call form + ArrayList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter); + pContact->Construct(1); + pContact->Add(contactTxt); + //Check if dialing an emergency call + bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true); + if (isEmergencyCall) + { + pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact); + } + else + { + //Show error message Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(ERROR_NOT_EMERGENCY_NUM); + } + } + else + { + //TODO: check what to do for SOS calls + //Show error message Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(ERROR_CODE_SIM_INITIALIZATION_FAILED); + } + AppLogDebug("EXIT"); + return; +} + +void +EmergencyDialForm::HandlePopupClosed(void) +{ + EditField* pEditField = static_cast(GetControl(IDC_EDITFIELD_NUMBER, true)); + //clear text + pEditField->Clear(); + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + return; +} diff --git a/src/PhnEndCallForm.cpp b/src/PhnEndCallForm.cpp new file mode 100644 index 0000000..303f7ec --- /dev/null +++ b/src/PhnEndCallForm.cpp @@ -0,0 +1,507 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnEndCallForm.cpp + * @brief End Call form implementation + */ +#include +#include +#include +#include "PhnPhoneApp.h" +#include "PhnAppUtility.h" +#include "PhnEndCallForm.h" +#include "PhnCallButtonsPanel.h" +#include "PhnCallPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int IDI_APP_END_TIMER = 3000; +const int W_PHOTO_LABEL = 720; +const int H_PHOTO_LABEL = 720; +const int X_PHOTO_LBL = 166; +const int Y_PHOTO_LBL = 232; +const int W_PHOTO_LBL = 388; +const int H_PHOTO_LBL = 388; +static const wchar_t* IDL_END_CALL_FORM = L"IDL_END_CALL_FORM"; +static const wchar_t* IDC_ADD_TO_CONTACT_BUTTON = L"IDC_ADD_TO_CONTACT_BUTTON"; +static const wchar_t* IDC_NUMBER1_LABEL = L"IDC_NUMBER1_LABEL"; +static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL"; +static const wchar_t* IDC_CALLER1_BIGPHOTO_LABEL = L"IDC_CALLER1_BIGPHOTO_LABEL"; +static const wchar_t* IDB_END_CALL_DEFAULT_ICON = L"C01-1_end call_default_caller ID_720x720.png"; + +EndCallForm::EndCallForm(void) +: BaseForm(FORMTYPE_ENDCALL) +{ + __pCallButtonsPanel = null; + __pContactNumber = null; + __pEndCallEventTimer = null; + __pSmallPhotoLabel = null; + __isMsgAppControlLaunched = false; + __isContactAppControlLaunched = false; +} + +EndCallForm::~EndCallForm(void) +{ + if (__pEndCallEventTimer != null) + { + __pEndCallEventTimer->Cancel(); + delete __pEndCallEventTimer; + __pEndCallEventTimer = null; + } + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } +} + +void +EndCallForm::Initialize(void) +{ + Construct(IDL_END_CALL_FORM); + //initialize keypad and buttons + InitializeCallButtonsPanel(); + //set initial show state to false. Correct state set on OnSceneActivatedN + SetContactButtonState(false); +} + +result +EndCallForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + AddKeyPadActionListener(IDC_ADD_TO_CONTACT_BUTTON, IDA_ADD_TO_CONTACTS); + + __pEndCallEventTimer = new (std::nothrow) Tizen::Base::Runtime::Timer(); + r = __pEndCallEventTimer->Construct(*this); + + __pCallPresentor = CallPresentationModel::GetInstance(); + return r; +} + +void +EndCallForm::InitializeCallButtonsPanel(void) +{ + __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel(); + __pCallButtonsPanel->ConstructPanel(this, FORMTYPE_ENDCALL); + AddControl(*__pCallButtonsPanel); +} + +void +EndCallForm::AddKeyPadActionListener(const String& keyName, CommandIds cmdId) +{ + Button* pButton = static_cast(GetControl(keyName)); + if (pButton != null) + { + pButton->SetActionId(cmdId); + pButton->AddActionEventListener(*this); + } +} + +result +EndCallForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pCallPresentor) + { + __pCallPresentor = null; + } + return r; +} + +void +EndCallForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch (actionId) + { + case IDA_VOICE_CALL: + { + //check if EndCallTimer is running, then cancel it + if(__pEndCallEventTimer != null) + { + __pEndCallEventTimer->Cancel(); + } + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(*__pContactNumber); + //switch to dialing outgoing call form + ArrayList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter); + pContact->Construct(); + pContact->Add(contactTxt); + + //Check if dialing a call is possible + bool isSimInitialized = __pCallPresentor->CheckSimInitializationIsCompleted(); + if (isSimInitialized) + { + //Check if dialing an emergency call + bool isEmergencyCall = __pCallPresentor->IsEmergencyNumber(*contactTxt, true); + if (isEmergencyCall) + { + pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact); + } + else + { + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact); + } + } + else + { + //Show error message Popup + HandleTelephonyError(ERROR_CODE_SIM_INITIALIZATION_FAILED); + } + } + break; + + case IDA_VIDEO_CALL: + //Make Video Call + break; + + case IDA_MESSAGE: + { + if (__isMsgAppControlLaunched == true) + { + //AppControl already launched. + return; + } + //launch message AppControl + __isMsgAppControlLaunched = true; + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE)); + extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(*__pContactNumber)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + if(r != E_SUCCESS) + { + //AppControl request failed, reset flag. + __isMsgAppControlLaunched = false; + } + else if (r == E_SUCCESS && __pEndCallEventTimer != null) + { + //cancel EndCallTimer, if AppControl request was successful. + __pEndCallEventTimer->Cancel(); + } + delete pAc; + } + + extraData.RemoveAll(true); + } + break; + + case IDA_ADD_TO_CONTACTS: + { + if(__isContactAppControlLaunched == true) + { + //AppControl already launched. + return; + } + //Launch Contact AppControl + __isContactAppControlLaunched = true; + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(INPUT_TYPE_PHONE), new (std::nothrow) String(*__pContactNumber)); + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_ADD); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + if(r != E_SUCCESS) + { + //AppControl request failed, reset flag. + __isContactAppControlLaunched = false; + } + else if (r == E_SUCCESS && __pEndCallEventTimer != null) + { + //cancel EndCallTimer, if AppControl request was success. + __pEndCallEventTimer->Cancel(); + + //NOTE:- goto next scene if present and is either Call log or Dialer, + // Else forcefully goto Dialer scene. + //Because we do not get any Appcontrol Completed response from Contacts in this case. + SceneId nextScene = (static_cast(UiApp::GetInstance()))->GetInitialScene(); + if(nextScene != IDSCN_CALL_LOG) + { + nextScene = IDSCN_DIALER; + } + pSceneManager->GoForward( ForwardSceneTransition(nextScene, + SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + delete pAc; + } + extraData.RemoveAll(true); + } + break; + + default: + break; + } +} + +void +EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + //set itself as listener + __pCallPresentor->SetTelEventListener(this); + //listen to Foreground events + PhoneApp* pPhoneApp = static_cast(PhoneApp::GetInstance()); + pPhoneApp->AddAppStateChangeListener(*this); + __isMsgAppControlLaunched = false; + __isContactAppControlLaunched = false; + + switch (__formType) + { + case FORMTYPE_ENDCALL: + { + //fetch ended call details + CallInfo* pEndCall = static_cast(pArgs->GetAt(0)); + + //contact number + __pContactNumber = new (std::nothrow) String(); + __pContactNumber->Append(pEndCall->GetContactNumber()); + + //Fetch & show contact person details + ShowPersonDetails(*__pContactNumber, IDC_CALLER1_LABEL, IDC_CALLER1_BIGPHOTO_LABEL,pEndCall); + //If call is hidden means no contact number is present, + //or if call is from known number, Then do NOT show "Add to Contact" button. + if (pEndCall->IsNumberPresent() == true || pEndCall->GetContactNumber().IsEmpty() == true) + { + SetContactButtonState(false); + } + else + { + SetContactButtonState(true); + } + + //Check if call is Emergency call or Hidden call, + //then disable all button in Call button panel. + if (pEndCall->IsEmergency() == true || pEndCall->GetContactNumber().IsEmpty() == true) + { + __pCallButtonsPanel->SetEndCallPanelState(false); + } + else + { + __pCallButtonsPanel->SetEndCallPanelState(true); + } + } + break; + + default: + break; + } + + if (__pEndCallEventTimer) + { + __pEndCallEventTimer->Start(IDI_APP_END_TIMER); + } + + if (pArgs) + { + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +EndCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if (__pContactNumber) + { + delete __pContactNumber; + __pContactNumber = null; + } + if (__pSmallPhotoLabel != null) + { + __pSmallPhotoLabel->SetShowState(false); + } + //remove itself as listener + PhoneApp* pPhoneApp = static_cast(PhoneApp::GetInstance()); + pPhoneApp->RemoveAppStateChangeListener(*this); +} + +result +EndCallForm::OnDraw(void) +{ + return E_SUCCESS; +} + +void +EndCallForm::SetContactButtonState(bool showState) +{ + Button* pButton = static_cast(GetControl(IDC_ADD_TO_CONTACT_BUTTON)); + if (pButton != null) + { + pButton->SetShowState(showState); + } +} + +void +EndCallForm::ShowPhoneNumber(const String& phoneNumber, const String& lblName) +{ + String formattedNumber = phoneNumber; + Label* pContactLbl = static_cast(GetControl(lblName)); + pContactLbl->SetText(formattedNumber); +} + +void +EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblName, const String& photoLblName, CallInfo* pCallInfo) +{ + //show phone number + ShowPhoneNumber(phoneNumber, IDC_NUMBER1_LABEL); + + Label* pNameLbl = static_cast(GetControl(nameLblName)); + Label* pPhotoLbl = static_cast(GetControl(photoLblName)); + + //fetch contact details based on phone number + String* pDisplayName = pCallInfo->FetchCallerNameN(); + Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN(); + + //passing an empty string to SetText fails in label, + //if previously valid text has been set + if (pDisplayName != null && pDisplayName->IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false) + { + pDisplayName->Append(L" "); + } + + // show display name on name Label + if (pDisplayName != null) + { + pNameLbl->SetText(*pDisplayName); + } + + // If record not found or no photo id present for user, + //fetch default bitmap. + if (pPhotoBitmap != null) + { + // show Thumbnail bitmap on photo Label + pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap); + pPhotoLbl->Invalidate(true); + delete pPhotoBitmap; + } + else + { + //Set Default Photo + Bitmap* pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_END_CALL_DEFAULT_ICON,W_PHOTO_LABEL,H_PHOTO_LABEL); + if (pDefaultPhoto != null) + { + pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto); + pPhotoLbl->Invalidate(true); + delete pDefaultPhoto; + } + } + RequestRedraw(true); + //free resources + if (pDisplayName) + { + delete pDisplayName; + pDisplayName = null; + } +} + +void +EndCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId) +{ + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } + //Draw Small Photo and show on small photo label + __pSmallPhotoLabel = new (std::nothrow) Label();//static_cast(GetControl(IDC_SMALL_PHOTO_LABEL)); + __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L""); + __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0)); + __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId); + // Add a Label to the Form + AddControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel->Invalidate(true); +} + +void +EndCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + //goto initial scene or close application, since this was last active call. + HandleLastCallCompletion(); +} + +void +EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + if (__isMsgAppControlLaunched == true) + { + //Message AppControl request completed. + __isMsgAppControlLaunched = false; + } + //AppControl completed, goto initial scene if present + //else exit. + HandleLastCallCompletion(); +} + +void +EndCallForm::HandleLastCallCompletion(void) +{ + //switch back to Dialer tab, based on starting state of call. + SceneManager* pSceneManager = SceneManager::GetInstance(); + PhoneApp* pPhoneApp = (static_cast(UiApp::GetInstance())); + SceneId nextSceneId = pPhoneApp->GetInitialScene(); + if (pSceneManager->GetCurrentScene()->GetSceneId() == IDSCN_SCENE_ENDCALL) + { + if(nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG) + { + pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + else + { + pPhoneApp->Terminate(); + } + } +} + +void +EndCallForm::OnForeground(void) +{ + AppLogDebug("Enter"); + //If Contact app control was launched + //as we do not know if it success or failed. + __isContactAppControlLaunched = false; +} + +void +EndCallForm::OnBackground(void) +{ + AppLogDebug("Enter"); +} diff --git a/src/PhnErrorMsgPopup.cpp b/src/PhnErrorMsgPopup.cpp new file mode 100644 index 0000000..06cd943 --- /dev/null +++ b/src/PhnErrorMsgPopup.cpp @@ -0,0 +1,236 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnErrorMsgPopup.cpp + * @brief Error message pop class + */ +#include +#include "PhnAppUtility.h" +#include "PhnErrorMsgPopup.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Runtime; + +const int IDI_VERTICAL_LINE_SPACING = 20; +const int W_ERROR_MSG_POPUP = 720; +const int IDI_VERTICAL_MARGIN = 39; +static const wchar_t* IDL_ERROR_MSG_POPUP = L"IDL_ERROR_MSG_POPUP"; +static const wchar_t* IDC_MSG_TEXTBOX = L"IDC_MSG_TEXTBOX"; +static const wchar_t* IDS_DIAL_ERROR_MSG = L"IDS_DIAL_ERROR_MSG"; +static const wchar_t* IDS_JOIN_FAILED_ERROR_MSG = L"IDS_JOIN_FAILED_ERROR_MSG"; +static const wchar_t* IDS_REJECT_FAILED_ERROR_MSG = L"IDS_REJECT_FAILED_ERROR_MSG"; +static const wchar_t* IDS_CALL_SWAP_ERROR_MSG = L"IDS_CALL_SWAP_ERROR_MSG"; +static const wchar_t* IDS_END_PARTICIPANT_ERROR_MSG = L"IDS_END_PARTICIPANT_ERROR_MSG"; +static const wchar_t* IDS_SPLIT_PARTICIPANT_ERROR_MSG = L"IDS_SPLIT_PARTICIPANT_ERROR_MSG"; +static const wchar_t* IDS_SIM_INIT_ERROR_MSG = L"IDS_SIM_INIT_ERROR_MSG"; +static const wchar_t* IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG = L"IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG"; +static const wchar_t* IDS_INVALID_ARGS_ERROR_MSG = L"IDS_INVALID_ARGS_ERROR_MSG"; +static const wchar_t* IDS_TAPI_INIT_ERROR_MSG = L"IDS_TAPI_INIT_ERROR_MSG"; +static const wchar_t* IDS_GENERAL_TAPI_ERROR_MSG = L"IDS_GENERAL_TAPI_ERROR_MSG"; +static const wchar_t* IDS_LONG_BARRING_PWD_ERROR_MSG = L"IDS_LONG_BARRING_PWD_ERROR_MSG"; +static const wchar_t* IDS_INVALID_NUMBER_ERROR_MSG = L"IDS_INVALID_NUMBER_ERROR_MSG"; +static const wchar_t* IDS_GENERAL_ERROR_MSG = L"IDS_GENERAL_ERROR_MSG"; + +ErrorMsgPopup::ErrorMsgPopup(IPopupClosedEventListener* pEventListener) +: __pEventListener(pEventListener) +{ + __pTimer = null; +} + +ErrorMsgPopup::~ErrorMsgPopup(void) +{ + if (__pTimer) + { + __pTimer->Cancel(); + delete __pTimer; + __pTimer = null; + } +} + +void +ErrorMsgPopup::ConstructPopup(int errorCode) +{ + Construct(IDL_ERROR_MSG_POPUP); + //Fetch error message + String msg = FetchErrorMessage(errorCode); + + //Set text to Message box + TextBox* pMsgTxtBox = static_cast(GetControl(IDC_MSG_TEXTBOX)); + pMsgTxtBox->SetLineSpacing(1,1); + pMsgTxtBox->SetText(msg); + pMsgTxtBox->SetEnabled(false); + pMsgTxtBox->SetTextAlignment(ALIGNMENT_CENTER); + + Rectangle msgTxtBoxRect = pMsgTxtBox->GetBounds(); + //get no. of lines to show message + int noOfLines = pMsgTxtBox->GetLineCount(); + pMsgTxtBox->SetSize(msgTxtBoxRect.width,((noOfLines * msgTxtBoxRect.height) + IDI_VERTICAL_LINE_SPACING)); + + Dimension popUpDimen = pMsgTxtBox->GetSize(); + popUpDimen.width = W_ERROR_MSG_POPUP; + popUpDimen.height += (2 * IDI_VERTICAL_MARGIN); + SetSize(popUpDimen); + + SetControlAlwaysOnTop(*pMsgTxtBox,true); + RelativeLayout* relPopUpLayout = static_cast(GetLayoutN()); + if(relPopUpLayout != null) + { + // Set Relations between msgtextbox and Popup + relPopUpLayout->SetCenterAligned(*pMsgTxtBox, CENTER_ALIGN_HORIZONTAL); + relPopUpLayout->SetCenterAligned(*pMsgTxtBox, CENTER_ALIGN_VERTICAL); + } + //construct timer + __pTimer = new (std::nothrow) Timer(); + __pTimer->Construct(*this); +} + +void +ErrorMsgPopup::ShowErrorMsgPopupN(int errorCode) +{ + //Construct the message popup + ConstructPopup(errorCode); + //Show popup message + ShowPopup(); +} + +void +ErrorMsgPopup::ShowPopup(void) +{ + __popupModalResult = 0; + //start timer to show popup + __pTimer->Start(2000); + SetShowState(true); + Show(); +} + +void +ErrorMsgPopup::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + //Call default implementation of "Object.Equals()" + //returns true, if they are pointing to same address. + if (__pTimer->Equals(timer)) + { + SetShowState(false); + //notify the listener + __pEventListener->HandlePopupClosed(); + } +} + +String +ErrorMsgPopup::FetchErrorMessage(int errorCode) +{ + String msg(L""); + switch (errorCode) + { + case ERROR_NONE: + break; + + case ERROR_DIAL_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_DIAL_ERROR_MSG)); + } + break; + + case ERROR_JOIN_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_JOIN_FAILED_ERROR_MSG)); + } + break; + + case ERROR_REJECT_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_REJECT_FAILED_ERROR_MSG)); + } + break; + + case ERROR_SWAP_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_CALL_SWAP_ERROR_MSG)); + } + break; + + case ERROR_END_FROM_CONFERENCE_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_END_PARTICIPANT_ERROR_MSG)); + } + break; + + case ERROR_SPLIT_FROM_CONFERENCE_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_SPLIT_PARTICIPANT_ERROR_MSG)); + } + break; + + case ERROR_CODE_SIM_INITIALIZATION_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_SIM_INIT_ERROR_MSG)); + } + break; + + case ERROR_NOT_EMERGENCY_NUM: + { + msg.Append(AppUtility::GetResourceString(IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG)); + } + break; + + case ERROR_INVALID_INPUT: + { + msg.Append(AppUtility::GetResourceString(IDS_INVALID_ARGS_ERROR_MSG)); + } + break; + + case ERROR_TAPI_INIT_FAILED: + { + msg.Append(AppUtility::GetResourceString(IDS_TAPI_INIT_ERROR_MSG)); + } + break; + + case ERROR_TAPI_ERROR: + { + msg.Append(AppUtility::GetResourceString(IDS_GENERAL_TAPI_ERROR_MSG)); + } + break; + + case ERROR_BARRING_PWD_TOO_LONG: + { + msg.Append(AppUtility::GetResourceString(IDS_LONG_BARRING_PWD_ERROR_MSG)); + } + break; + + case ERROR_INVALID_NUMBER: + { + msg.Append(AppUtility::GetResourceString(IDS_INVALID_NUMBER_ERROR_MSG)); + } + break; + + case ERROR_GENERAL: + default: + { + msg.Append(AppUtility::GetResourceString(IDS_GENERAL_ERROR_MSG)); + } + break; + } + + return msg; +} + + diff --git a/src/PhnIncomingCallForm.cpp b/src/PhnIncomingCallForm.cpp new file mode 100644 index 0000000..0c305e0 --- /dev/null +++ b/src/PhnIncomingCallForm.cpp @@ -0,0 +1,1615 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnIncomingCallForm.cpp + * @brief Incoming Call form implementation + */ +#include +#include +#include "PhnIncomingCallForm.h" +#include "PhnAppUtility.h" +#include "PhnSettingsManager.h" +#include "PhnCallPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Messaging; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//Constants +const int W_DIAL_BITMAP = 102; +const int H_DIAL_BITMAP = 102; +const int W_CREATE_BITMAP = 56; +const int H_CREATE_BITMAP = 56; +const int X_CREATE_BITMAP = 8; +const int Y_CREATE_BITMAP = 8; +const int W_MESSAGE_BG_BITMAP = 720; +const int H_MESSAGE_BG_BITMAP = 92; +const int W_ARROW_BITMAP = 18; +const int H_ARROW_BITMAP = 12; +const int W_MESSAGE_BITMAP = 50; +const int H_MESSAGE_BITMAP = 50; +const int X_MESSAGE_BITMAP = 148; +const int Y_MESSAGE_BITMAP = 28; +const int MESSAGE_TEXT_X_MARGIN = 20; +const int MESSAGE_TEXT_Y_MARGIN = 7; +const int SEND_TEXT_X_MARGIN = 78; +const int SEND_TEXT_Y_MARGIN = 20; +const int SEND_BUTTON_ROUND_DIMENSION = 5; +const int W_DIAL_LABEL = 158; +const int H_DIAL_LABEL = 158; +const int DIAL_ICON_X_OFFSET = 23; +const int DIAL_ICON_Y_OFFSET = 23; +const int REJECT_LABEL_X_OFFSET = 542; +const int X_CALL_PANEL = 0; +const int Y_CALL_PANEL = 190; +const int H_CALL_PANEL = 158; +const int Y_ARROW_LABEL = 79; +const int W_ARROW_LABEL = 20; +const int H_ARROW_LABEL = 32; +const int VALID_TOUCH_X_OFFSET = 158; +const int VALID_TOUCH_Y_OFFSET = 158; +const int X_ARROW_LABEL_STARTPOS = 198; +const int ARROW_LABEL_X_MARGIN = 48; +const int ACCEPT_LABEL_RELATIVE_POS = -384; //relative pos of accept labels right to reject labels left +const int MAX_LIST_HEIGHT = 678; +const int H_REJECT_VIEW_FOOTER = 114; +const int X_LIST_TEXT_ITEM = 16; +const int W_LIST_TEXT_ITEM = 452; +const int H_LIST_TEXT_ITEM = 111; +const int X_SEND_TEXT_ITEM = 484; +const int Y_SEND_TEXT_ITEM = 20; +const int W_SEND_TEXT_ITEM = 220; +const int H_SEND_TEXT_ITEM = 72; +const int X_PHOTO_LBL = 166; +const int Y_PHOTO_LBL = 232; +const int W_PHOTO_LBL = 388; +const int H_PHOTO_LBL = 388; +const int W_PHOTO_LABEL = 720; +const int H_PHOTO_LABEL = 720; + +const unsigned int COLOR_SEND_BUTTON_PRESSED = Color32<130, 142, 150>::Value; +const unsigned int COLOR_SEND_BUTTON_NORMAL = Color32<64, 156, 211>::Value; +const unsigned int COLOR_SWIPE_PANEL = Color32<0, 0, 0, 255>::Value; +const unsigned int COLOR_LIST_TEXT_NORMAL = Color32<0, 0, 0>::Value; +const unsigned int COLOR_LIST_TEXT_PRESSED = Color32<249, 249, 249>::Value; + +const int FONT_SIZE_MSG_TXT = 32; + +static const wchar_t* IDL_INCOMING_CALL_FORM = L"IDL_INCOMING_CALL_FORM"; +static const wchar_t* IDB_REJECT_MESSAGE_BG = L"C01-1_Reject_message_bg.png"; +static const wchar_t* IDB_REJECT_MESSAGE_UP_ARROW = L"C01-1_Reject_message_arrow_01.png"; +static const wchar_t* IDB_REJECT_MESSAGE_DOWN_ARROW = L"C01-1_Reject_message_arrow_02.png"; +static const wchar_t* IDB_REJECT_MESSAGE_ICON = L"C01-1_icon_Reject_with_Message.png"; +static const wchar_t* IDB_ACCEPT_CIRCLE_ICON = L"C01-1_accept_left.png"; +static const wchar_t* IDB_REJECT_CIRCLE_ICON = L"C01-1_reject_right.png"; +static const wchar_t* IDB_CALL_ACCEPT_ICON = L"C01-1_accept_left_dial_answer.png"; +static const wchar_t* IDB_CALL_REJECT_ICON = L"C01-1_reject_right_dial_decline.png"; +static const wchar_t* IDB_ACCEPT_ARROW_ICON = L"C01-1_arrow_g.png"; +static const wchar_t* IDB_REJECT_ARROW_ICON = L"C01-1_arrow_r.png"; +static const wchar_t* IDB_CALL_BG = L"C01-1_calling_BG_01.png"; +static const wchar_t* IDB_CREATE_BUTTON_ICON = L"C01-1_btn_create.png"; +static const wchar_t* IDB_BACK_BUTTON_ICON = L"C01-1_btn_back.png"; +static const wchar_t* IDC_REJECT_MESSAGE_BUTTON = L"IDC_REJECT_MESSAGE_BUTTON"; +static const wchar_t* IDC_REJECT_PANEL = L"IDC_REJECT_PANEL"; +static const wchar_t* IDC_BACK_BUTTON = L"IDC_BACK_BUTTON"; +static const wchar_t* IDC_CREATE_BUTTON = L"IDC_CREATE_BUTTON"; +static const wchar_t* IDC_REJECT_MESSAGE_CANCEL_BUTTON = L"IDC_REJECT_MESSAGE_CANCEL_BUTTON"; +static const wchar_t* IDC_LIST_SCROLLPANEL = L"IDC_LIST_SCROLLPANEL"; +static const wchar_t* IDC_MSG_TABLEVIEW = L"IDC_MSG_TABLEVIEW"; +static const wchar_t* IDC_CALLER_LABEL = L"IDC_CALLER_LABEL"; +static const wchar_t* IDC_NUMBER_LABEL = L"IDC_NUMBER_LABEL"; +static const wchar_t* IDC_BIG_PHOTO_LABEL = L"IDC_BIG_PHOTO_LABEL"; +const wchar_t* IDS_REJECT_MESSAGE_BTN = L"IDS_REJECT_MESSAGE_BTN"; +const wchar_t* IDS_LIST_SEND_BUTTON = L"IDS_LIST_SEND_BUTTON"; +const wchar_t* IDS_NO_MESSAGE_STR = L"IDS_NO_MESSAGE_STR"; + +const int ID_MULTI_PARTY_CALL = 505; +const int ID_SECOND_INCOMING_CALL = 503; + +const wchar_t* IDI_FORM_VISUAL_ELE_NAME = L"FormVisEle"; +const wchar_t* IDI_PANEL_VISUAL_ELE_NAME = L"PanelVisEle"; +const wchar_t* IDI_ACCEPT_VISUAL_ELE_NAME = L"AcceptVisEle"; +const wchar_t* IDI_REJECT_VISUAL_ELE_NAME = L"RejectVisEle"; +const wchar_t* IDI_ACCEPT_ARROW_VISUAL_ELE_NAME = L"AcceptArrowVisEle"; +const wchar_t* IDI_REJECT_ARROW_VISUAL_ELE_NAME = L"RejectArrowVisEle"; +const wchar_t* IDI_REJECT_FINAL_VISUAL_ELE_NAME = L"RejectFinalVisEle"; +const wchar_t* IDI_ACCEPT_FINAL_VISUAL_ELE_NAME = L"AcceptFinalVisEle"; + +class SmsListener + : public Object + , public ISmsListener +{ +public: + void OnSmsMessageSent(result r) + { + } +}; + +IncomingCallForm::IncomingCallForm(void) + : BaseForm(FORMTYPE_INCOMINGCALL) +{ + __pActiveContactNo = null; + __pRejectMessageList = null; + __incomingCallHandle = -1; + __isAnswerCallStarted = false; + __isRejectCallStarted = false; + __pAcceptArrowLabelsList = null; + __pRejectArrowLabelsList = null; + __pRejectCircle = null; + __pAcceptCircle = null; + __pAcceptDial = null; + __pRejectDial = null; + __pAcceptArrow = null; + __pRejectArrow = null; + __pAcceptLabel = null; + __pRejectLabel = null; + __pAcceptArrowLabel = null; + __pRejectArrowLabel = null; + __pCallHandlePanel = null; + __pAcceptVisElem = null; + __pRejectVisElem = null; + __pRejectFinalVisElem = null; + __pAcceptFinalVisElem = null; + __pAcceptArrowVisElem = null; + __pRejectArrowVisElem = null; + __pCallPresentor = null; + __pOptionPopup = null; + __pSmallPhotoLabel = null; +} + +IncomingCallForm::~IncomingCallForm(void) +{ +} + +void +IncomingCallForm::Initialize(void) +{ + Construct(IDL_INCOMING_CALL_FORM); +} + +result +IncomingCallForm::OnInitializing(void) +{ + result r = E_SUCCESS; + Canvas* pCanvas = null; + + VisualElement* pFormVisElem = new (std::nothrow) VisualElement(); + r = pFormVisElem->Construct(); + pFormVisElem->SetBounds(FloatRectangle(GetClientAreaBounds().x, GetClientAreaBounds().y, GetClientAreaBounds().width, GetClientAreaBounds().height)); + pFormVisElem->SetShowState(true); + pFormVisElem->SetOpacity(1.0f); + pFormVisElem->SetName(IDI_FORM_VISUAL_ELE_NAME); + GetVisualElement()->AttachChild(*pFormVisElem); + pCanvas = pFormVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(GetClientAreaBounds().x, GetClientAreaBounds().y, GetClientAreaBounds().width, GetClientAreaBounds().height)); + delete pCanvas; + pCanvas = null; + } + HideRejectPanel(); + + Button* pButtonRejectMessage = static_cast(GetControl(IDC_REJECT_MESSAGE_BUTTON)); + if (pButtonRejectMessage) + { + SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG, + IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false); + SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG, + IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true); + pButtonRejectMessage->SetActionId(IDA_SHOW_REJECT_CALL_MESSAGE_PANEL); + pButtonRejectMessage->AddActionEventListener(*this); + } + + //Get Reject list from Settings Manager + IMapT* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN(); + if(pMsgMap != null) + { + __pRejectMessageList = pMsgMap->GetValuesN(); + delete pMsgMap; + pMsgMap = null; + } + InitializeTableView(); + + __pAcceptCircle = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL); + __pRejectCircle = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL); + __pAcceptDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_ACCEPT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP); + __pRejectDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_REJECT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP); + __pAcceptArrow = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL); + __pRejectArrow = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL); + + + //Panel for showing accept and reject call buttons. + Label* pPhotoLbl = static_cast(GetControl(IDC_BIG_PHOTO_LABEL, true)); + int yPos = pPhotoLbl->GetX()+pPhotoLbl->GetHeight()+ Y_CALL_PANEL; + + __pCallHandlePanel = new (std::nothrow) Panel(); + r = __pCallHandlePanel->Construct(Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL), GROUP_STYLE_NONE); + __pCallHandlePanel->AddTouchEventListener(*this); + AddControl(*__pCallHandlePanel); + __pCallHandlePanel->SetBackgroundColor(COLOR_SWIPE_PANEL); + VisualElement* pCallPanelVisElem = new (std::nothrow) VisualElement(); + r = pCallPanelVisElem->Construct(); + pCallPanelVisElem->SetBounds(FloatRectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL)); + pCallPanelVisElem->SetShowState(true); + pCallPanelVisElem->SetOpacity(1.0f); + pCallPanelVisElem->SetName(IDI_PANEL_VISUAL_ELE_NAME); + __pCallHandlePanel->GetVisualElement()->AttachChild(*pCallPanelVisElem); + pCanvas = pCallPanelVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL)); + delete pCanvas; + pCanvas = null; + } + //Lock Label for animation + __pAcceptLabel = new (std::nothrow) Label(); + r = __pAcceptLabel->Construct(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), L""); + __pAcceptLabel->SetBackgroundColor(COLOR_SWIPE_PANEL); + __pAcceptLabel->AddTouchEventListener(*this); + __pCallHandlePanel->AddControl(*__pAcceptLabel); + //left dial icon + __pAcceptVisElem = new (std::nothrow) VisualElement(); + r = __pAcceptVisElem->Construct(); + __pAcceptVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + __pAcceptVisElem->SetShowState(true); + __pAcceptVisElem->SetOpacity(1.0f); + __pAcceptVisElem->SetName(IDI_ACCEPT_VISUAL_ELE_NAME); + __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem); + pCanvas = __pAcceptVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pAcceptCircle); + pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial); + delete pCanvas; + pCanvas = null; + } + //UnLock Label for animation + __pRejectLabel = new (std::nothrow) Label(); + r = __pRejectLabel->Construct(Rectangle(REJECT_LABEL_X_OFFSET, 0, W_DIAL_LABEL, H_DIAL_LABEL), L""); + __pRejectLabel->AddTouchEventListener(*this); + __pCallHandlePanel->AddControl(*__pRejectLabel); + __pRejectLabel->SetBackgroundColor(COLOR_SWIPE_PANEL); + SetControlAlwaysAtBottom(*__pCallHandlePanel, true); + + //Right reject icon + __pRejectVisElem = new (std::nothrow) VisualElement(); + r = __pRejectVisElem->Construct(); + __pRejectVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + __pRejectVisElem->SetShowState(true); + __pRejectVisElem->SetOpacity(1.00f); + __pRejectVisElem->SetName(IDI_REJECT_VISUAL_ELE_NAME); + __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem); + pCanvas = __pRejectVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial); + pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle); + delete pCanvas; + pCanvas = null; + } + + //! Constructs an array list to store the unlock labels + __pAcceptArrowLabelsList = new (std::nothrow) ArrayList(); + r = __pAcceptArrowLabelsList->Construct(); + + //! Constructs the Unlock Labels with the bitmap as background, adds the touch event Listener and adds them to the panel. + int x = X_ARROW_LABEL_STARTPOS; + for (int index = 0; index < 7; index++) + { + __pAcceptArrowLabel = new (std::nothrow) Label(); + r = __pAcceptArrowLabel->Construct(Rectangle(x, Y_ARROW_LABEL, W_ARROW_LABEL, H_ARROW_LABEL), L""); + __pAcceptArrowLabel->AddTouchEventListener(*this); + __pCallHandlePanel->AddControl(*__pAcceptArrowLabel); + __pAcceptArrowLabelsList->Add(*__pAcceptArrowLabel); + __pAcceptArrowVisElem = new (std::nothrow) VisualElement(); + r = __pAcceptArrowVisElem->Construct(); + __pAcceptArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL)); + __pAcceptArrowVisElem->SetShowState(true); + __pAcceptArrowVisElem->SetOpacity(0.0f); + String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pAcceptArrowVisElem->SetName(VisualEleName); + __pAcceptArrowLabel->GetVisualElement()->AttachChild(*__pAcceptArrowVisElem); + pCanvas = __pAcceptArrowVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->DrawRectangle(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL)); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL)); + pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pAcceptArrow); + delete pCanvas; + pCanvas = null; + } + x += ARROW_LABEL_X_MARGIN; + } + //! Constructs an array list to store the unlock labels + __pRejectArrowLabelsList = new (std::nothrow) ArrayList(); + r = __pRejectArrowLabelsList->Construct(); + + x = X_ARROW_LABEL_STARTPOS; + for (int index = 0; index < 7; index++) + { + __pRejectArrowLabel = new (std::nothrow) Label(); + r = __pRejectArrowLabel->Construct(Rectangle(x, Y_ARROW_LABEL, W_ARROW_LABEL, H_ARROW_LABEL), L""); + __pRejectArrowLabel->AddTouchEventListener(*this); + __pCallHandlePanel->AddControl(*__pRejectArrowLabel); + __pRejectArrowLabelsList->Add(*__pRejectArrowLabel); + __pRejectArrowVisElem = new (std::nothrow) VisualElement(); + r = __pRejectArrowVisElem->Construct(); + __pRejectArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL)); + __pRejectArrowVisElem->SetShowState(true); + __pRejectArrowVisElem->SetOpacity(0.0f); + String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pRejectArrowVisElem->SetName(VisualEleName); + __pRejectArrowLabel->GetVisualElement()->AttachChild(*__pRejectArrowVisElem); + pCanvas = __pRejectArrowVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->Clear(); + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL)); + pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pRejectArrow); + delete pCanvas; + pCanvas = null; + } + x += ARROW_LABEL_X_MARGIN; + } + + return r; +} + +result +IncomingCallForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pRejectMessageList != null) + { + delete __pRejectMessageList; + __pRejectMessageList = null; + } + if (__pActiveContactNo != null) + { + delete __pActiveContactNo; + __pActiveContactNo = null; + } + __incomingCallHandle = -1; + __pCallPresentor = null; + + /* Deleting fails in A4RC* SDK. Remove if not necessary + if (__pAcceptVisElem != null) + { + __pAcceptVisElem->Destroy(); + __pAcceptVisElem = null; + } + + if (__pRejectVisElem != null) + { + __pRejectVisElem->Destroy(); + __pRejectVisElem = null; + } + + if (__pRejectFinalVisElem != null) + { + __pRejectFinalVisElem->Destroy(); + __pRejectFinalVisElem = null; + } + + if (__pAcceptFinalVisElem != null) + { + __pAcceptFinalVisElem->Destroy(); + __pAcceptFinalVisElem = null; + } + + for (int i = 0; i < 7; i++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(i)); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement(); + if (__pRejectArrowVisElem != null) + { + __pRejectArrowVisElem->Destroy(); + __pRejectArrowVisElem = null; + } + + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(i)); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement(); + if (__pAcceptArrowVisElem != null) + { + __pAcceptArrowVisElem->Destroy(); + __pAcceptArrowVisElem = null; + } + } + + if (__pAcceptArrowVisElem != null) + { + __pAcceptArrowVisElem = null; + } + + if (__pRejectArrowVisElem != null) + { + __pRejectArrowVisElem = null; + } +*/ + if (__pAcceptArrowLabelsList != null) + { + __pAcceptArrowLabelsList->RemoveAll(false); + delete __pAcceptArrowLabelsList; + __pAcceptArrowLabelsList = null; + } + + if (__pRejectArrowLabelsList != null) + { + __pRejectArrowLabelsList->RemoveAll(false); + delete __pRejectArrowLabelsList; + __pRejectArrowLabelsList = null; + } + + if (__pRejectCircle != null) + { + delete __pRejectCircle; + __pRejectCircle = null; + } + + if (__pAcceptCircle != null) + { + delete __pAcceptCircle; + __pAcceptCircle = null; + } + + if (__pAcceptDial != null) + { + delete __pAcceptDial; + __pAcceptDial = null; + } + + if (__pRejectDial != null) + { + delete __pRejectDial; + __pRejectDial = null; + } + + if (__pAcceptArrow != null) + { + delete __pAcceptArrow; + __pAcceptArrow = null; + } + + if (__pRejectArrow != null) + { + delete __pRejectArrow; + __pRejectArrow = null; + } + __pCallHandlePanel->RemoveTouchEventListener(*this); + __pAcceptLabel->RemoveTouchEventListener(*this); + __pRejectLabel->RemoveTouchEventListener(*this); + __pAcceptArrowLabel->RemoveTouchEventListener(*this); + __pRejectArrowLabel->RemoveTouchEventListener(*this); + __pAcceptLabel = null; + __pRejectLabel = null; + __pAcceptArrowLabel = null; + __pRejectArrowLabel = null; + __pCallHandlePanel = null; + return r; +} + +void +IncomingCallForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case IDA_SHOW_REJECT_CALL_MESSAGE_PANEL: // applicable in all form states + { + Panel* pKeysPanel = static_cast(GetControl(IDC_REJECT_PANEL)); + if (pKeysPanel) + { + pKeysPanel->SetShowState(true); + ScrollPanel* pScrollPanel = static_cast(pKeysPanel->GetControl(IDC_LIST_SCROLLPANEL)); + TableView* pMessageList = static_cast(pScrollPanel->GetControl(IDC_MSG_TABLEVIEW)); + Rectangle tmpRect = pMessageList->GetBounds(); + SetControlAlwaysOnTop(*pKeysPanel,true); + + //Set Height to Reject Message Panel + int listHeight = H_LIST_NORMAL_MENU_ITEM; //If no messages + if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0) + { + listHeight = H_LIST_NORMAL_MENU_ITEM * (__pRejectMessageList->GetCount()); //multiply by number of items + } + if (listHeight > MAX_LIST_HEIGHT) + { + listHeight = MAX_LIST_HEIGHT; + } + + pMessageList->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight); + tmpRect = pScrollPanel->GetBounds(); + pScrollPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight); + tmpRect = pKeysPanel->GetBounds(); + pKeysPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, H_MESSAGE_BG_BITMAP + H_REJECT_VIEW_FOOTER + listHeight); + + Button* pButtonReject = static_cast(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON)); + pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL); + pButtonReject->AddActionEventListener(*this); + pButtonReject->SetEnabled(true); + pButtonReject->SetFocus(); + + pButtonReject = static_cast(pKeysPanel->GetControl(IDC_BACK_BUTTON)); + pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL); + pButtonReject->AddActionEventListener(*this); + pButtonReject->SetEnabled(true); + pButtonReject->SetFocus(); + + Button* pButtonCreate = static_cast(pKeysPanel->GetControl(IDC_CREATE_BUTTON)); + pButtonCreate->SetActionId(IDA_CREATE_REJECT_CALL_MESSAGE); + pButtonCreate->AddActionEventListener(*this); + pButtonCreate->SetEnabled(true); + pButtonCreate->SetFocus(); + + pKeysPanel->SetFocus(); + pKeysPanel->Draw(); + } + Button* pButtonRejectMessage = static_cast(GetControl(IDC_REJECT_MESSAGE_BUTTON)); + if (pButtonRejectMessage) + { + pButtonRejectMessage->SetShowState(false); + pButtonRejectMessage->Invalidate(true); + pButtonRejectMessage->Draw(); + } + } + break; + + case IDA_CREATE_REJECT_CALL_MESSAGE: + { + __pCallPresentor->RejectCall(__incomingCallHandle, true,*__pActiveContactNo); + ArrayListT* pCallList = static_cast*>(__pCallPresentor->GetCallListN()); + if(pCallList != null && pCallList->GetCount() > 0) + { + __pCallPresentor->HandleCallConnected(*pCallList); + } + pCallList = null; + } + break; + + case IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL: + { + HideRejectPanel(); + SetFocus(); + Button* pButtonRejectMessage = static_cast(GetControl(IDC_REJECT_MESSAGE_BUTTON)); + if (pButtonRejectMessage) + { + pButtonRejectMessage->SetShowState(true); + pButtonRejectMessage->Invalidate(true); + pButtonRejectMessage->Draw(); + } + RequestRedraw(true); + } + break; + + case IDA_SEND_REJECT_MSG1: + case IDA_SEND_REJECT_MSG2: + case IDA_SEND_REJECT_MSG3: + case IDA_SEND_REJECT_MSG4: + case IDA_SEND_REJECT_MSG5: + case IDA_SEND_REJECT_MSG6: + { + __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo); + SmsListener* pSmsListener = new (std::nothrow) SmsListener(); + SmsManager* pSmsManager = new (std::nothrow) SmsManager(); + result r = pSmsManager->Construct(*pSmsListener); + if (IsFailed(r) == false) + { + RecipientList recipient; + recipient.Add(RECIPIENT_TYPE_TO,*__pActiveContactNo); + SmsMessage smsMessage; + String textToBeSent; + //calculate msgIndex + int msgIndex = IDA_SEND_REJECT_MSG1; + msgIndex = actionId - msgIndex; + __pRejectMessageList->GetAt(msgIndex, textToBeSent); + r = smsMessage.SetText(textToBeSent); + if (IsFailed(r) == false) + { + r = pSmsManager->Send(smsMessage,recipient,true); + if (IsFailed(r) == true) + { + //todo: error message + } + } + else + { + //todo: error message + } + } + else + { + //todo: error message + } + delete pSmsListener; + delete pSmsManager; + /*ArrayListT* pCallList = static_cast*>(__pCallPresentor->GetCallListN()); + __pCallPresentor->HandleCallConnected(*pCallList); + pCallList = null;*/ + } + break; + + default: + break; + } +} + +void +IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + if(__pCallPresentor == null) + { + __pCallPresentor = CallPresentationModel::GetInstance(); + } + __pCallPresentor->SetTelEventListener(this); + HideRejectPanel(); + + if (__pRejectFinalVisElem != null) + { + __pRejectFinalVisElem->Destroy(); + __pRejectFinalVisElem = null; + } + + if (__pAcceptFinalVisElem != null) + { + __pAcceptFinalVisElem->Destroy(); + __pAcceptFinalVisElem = null; + } + if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null) + { + __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem); + } + if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null) + { + __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem); + } + + __pAcceptVisElem->SetOpacity(1.0f); + __pRejectVisElem->SetOpacity(1.00f); + for (int i = 0; i < 7; i++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(i)); + String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + RejectVisualEleName.Append(i); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true); + __pRejectArrowVisElem->SetOpacity(0.0f); + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(i)); + String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + AcceptVisualEleName.Append(i); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true); + __pAcceptArrowVisElem->SetOpacity(0.0f); + } + + + if (pArgs != null) + { + //get Call Info + CallInfo* pIncomingCall = static_cast(pArgs->GetAt(0)); + if (pIncomingCall != null) + { + //start alert with contact's custom ringtone + __pCallPresentor->StartAlert(*pIncomingCall); + //show contact number + String contactNo; + contactNo.Append(pIncomingCall->GetContactNumber()); + if (__pActiveContactNo) + { + delete __pActiveContactNo; + __pActiveContactNo = null; + } + __incomingCallHandle = pIncomingCall->GetCallHandle()->ToLong(); + __pActiveContactNo = new (std::nothrow) String(); + __pActiveContactNo->Append(contactNo); + //Show person details + ShowPersonDetails(*__pActiveContactNo, IDC_NUMBER_LABEL, IDC_CALLER_LABEL, pIncomingCall); + //Check if incoming call is hidden call, then do not show "Reject with Message" button + Button* pButtonRejectMessage = static_cast(GetControl(IDC_REJECT_MESSAGE_BUTTON)); + if (pButtonRejectMessage) + { + //for hidden call, contact number is not present + bool showRejectMsgButton = (pIncomingCall->GetContactNumber().IsEmpty() == false); + pButtonRejectMessage->SetShowState(showRejectMsgButton); + pButtonRejectMessage->Invalidate(true); + } + } + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if (__pSmallPhotoLabel != null) + { + RemoveControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel = null; + } + for (int i = 0; i < 7; i++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(i)); + String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + RejectVisualEleName.Append(i); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true); + __pRejectArrowVisElem->SetOpacity(0.0f); + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(i)); + String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + AcceptVisualEleName.Append(i); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true); + __pAcceptArrowVisElem->SetOpacity(0.0f); + } +} + +result +IncomingCallForm::OnDraw(void) +{ + Bitmap* pBackgroundWp = null; + // get a Canvas instance + Canvas* pCanvas = GetCanvasN(); + + pBackgroundWp = AppResource::GetInstance()->GetBitmapN(IDB_CALL_BG); + + if (pCanvas) + { + + if (pBackgroundWp) + { + pCanvas->DrawBitmap(pCanvas->GetBounds(), *pBackgroundWp); + } + } + + delete pBackgroundWp; + pBackgroundWp = null; + + delete pCanvas; + pCanvas = null; + + return E_SUCCESS; +} + +void +IncomingCallForm::HideRejectPanel(void) +{ + Bitmap* pRejectMessageBitmap = null; + AppResource* pAppResource = AppResource::GetInstance(); + Panel* pKeysPanel = static_cast(GetControl(IDC_REJECT_PANEL)); + if (pKeysPanel) + { + pKeysPanel->SetShowState(false); + Button* pButtonReject = static_cast(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON)); + pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL); + pButtonReject->AddActionEventListener(*this); + SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG, + IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false); + SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG, + IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true); + + pButtonReject = static_cast(pKeysPanel->GetControl(IDC_CREATE_BUTTON)); + pRejectMessageBitmap = pAppResource->GetBitmapN(IDB_CREATE_BUTTON_ICON); + pRejectMessageBitmap->Scale(Dimension(W_CREATE_BITMAP, H_CREATE_BITMAP)); + pButtonReject->SetNormalBitmap(Point(X_CREATE_BITMAP, Y_CREATE_BITMAP), *pRejectMessageBitmap); + delete pRejectMessageBitmap; + pRejectMessageBitmap = null; + + pButtonReject = static_cast(pKeysPanel->GetControl(IDC_BACK_BUTTON)); + pRejectMessageBitmap = pAppResource->GetBitmapN(IDB_BACK_BUTTON_ICON); + pRejectMessageBitmap->Scale(Dimension(W_CREATE_BITMAP, H_CREATE_BITMAP)); + pButtonReject->SetNormalBitmap(Point(X_CREATE_BITMAP, Y_CREATE_BITMAP), *pRejectMessageBitmap); + pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL); + pButtonReject->AddActionEventListener(*this); + delete pRejectMessageBitmap; + pRejectMessageBitmap = null; + + Button* pButtonCreate = static_cast(pKeysPanel->GetControl(IDC_CREATE_BUTTON)); + pButtonCreate->SetActionId(IDA_CREATE_REJECT_CALL_MESSAGE); + pButtonCreate->AddActionEventListener(*this); + + pKeysPanel->Invalidate(true); + } +} + +void +IncomingCallForm::InitializeTableView(void) +{ + Panel* pKeysPanel = static_cast(GetControl(IDC_REJECT_PANEL)); + ScrollPanel* pScrollPanel = static_cast(pKeysPanel->GetControl(IDC_LIST_SCROLLPANEL)); + + TableView* pMessageList = static_cast(pScrollPanel->GetControl(IDC_MSG_TABLEVIEW)); + pMessageList->SetItemProvider(this); + pMessageList->AddTableViewItemEventListener(*this); + pScrollPanel->AddControl(*pMessageList); +} + +/////////////////////////////////////////////////////////////////////////////// +///// Table View Functionality supporting functions ///// +////////////////////////////////////////////////////////////////////////////// +int +IncomingCallForm::GetItemCount(void) +{ + if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0) + { + return (__pRejectMessageList->GetCount()); + } + return 1; +} + +TableViewItem* +IncomingCallForm::CreateItem(int itemIndex, int itemWidth) +{ + //create a new item + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //Message text item rectangle + Rectangle itemRect(X_LIST_TEXT_ITEM, 0, W_LIST_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM); + + //Message + String itemName(L""); + bool isShowSendButton = true; + if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0) + { + __pRejectMessageList->GetAt(itemIndex, itemName); + } + else + { + itemName.Append(AppUtility::GetResourceString(IDS_NO_MESSAGE_STR)); + isShowSendButton = false; + } + + Label* pMsgLbl = new (std::nothrow) Label(); + pMsgLbl->Construct(itemRect, itemName); + pMsgLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL); + pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);//COLOR_LIST_TEXT_PRESSED + pItem->AddControl(*pMsgLbl); + + //Send Button + if(isShowSendButton == true) + { + String sendText = AppUtility::GetResourceString(IDS_LIST_SEND_BUTTON); + Button* pSendButton = new (std::nothrow) Button(); + pSendButton->Construct(Rectangle(X_SEND_TEXT_ITEM, Y_SEND_TEXT_ITEM, W_SEND_TEXT_ITEM, H_SEND_TEXT_ITEM), sendText); + pSendButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_SEND_BUTTON_PRESSED); + pSendButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_SEND_BUTTON_NORMAL); + //set action id and listener + int actionId = IDA_SEND_REJECT_MSG1; + switch(itemIndex) + { + case 0: + actionId = IDA_SEND_REJECT_MSG1; + break; + case 1: + actionId = IDA_SEND_REJECT_MSG2; + break; + case 2: + actionId = IDA_SEND_REJECT_MSG3; + break; + case 3: + actionId = IDA_SEND_REJECT_MSG4; + break; + case 4: + actionId = IDA_SEND_REJECT_MSG5; + break; + case 5: + actionId = IDA_SEND_REJECT_MSG6; + break; + } + pSendButton->SetActionId(actionId); + pSendButton->AddActionEventListener(*this); + pItem->AddControl(*pSendButton); + pItem->SetIndividualSelectionEnabled(pSendButton, true); + } + + return pItem; +} + +bool +IncomingCallForm::DeleteItem(int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +int +IncomingCallForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} + +void +IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, CallInfo* pCallInfo) +{ + //call individual methods to show contact number, caller name & photo + SetTextToLabel(phoneNumber, contactLblName); + + //fetch contact details based on phone number + String* pDisplayName = pCallInfo->FetchCallerNameN(); + Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN(); + ShowCallerPhoto(pPhotoBitmap); + + //free resources + if (pDisplayName) + { + SetTextToLabel(*pDisplayName, nameLblName); + delete pDisplayName; + pDisplayName = null; + } + + if (pPhotoBitmap) + { + delete pPhotoBitmap; + pPhotoBitmap = null; + } +} + +void +IncomingCallForm::SetTextToLabel(const String& textToBeSet, const String& lblName) +{ + Label* pContactLbl = static_cast(GetControl(lblName)); + //passing an empty string to SetText fails in label, + //if previously valid text has been set + if (textToBeSet.IsEmpty() == true && pContactLbl->GetText().IsEmpty() == false) + { + String stringToBeSet(L" "); + pContactLbl->SetText(stringToBeSet); + } + + else + { + pContactLbl->SetText(textToBeSet); + } +} + +void +IncomingCallForm::ShowCallerPhoto(const Bitmap* pPhotoId) +{ + //show photo - for Big Photo Id, Animated Call Image + if (pPhotoId == null) + { + pPhotoId = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO); + } + + Label* pPhotoLbl = static_cast(GetControl(IDC_BIG_PHOTO_LABEL)); + if (pPhotoLbl != null && pPhotoId != null) + { + pPhotoLbl->SetBackgroundBitmap(*pPhotoId); + pPhotoLbl->Invalidate(true); + } +} + +void +IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId) +{ + //Draw Small Photo and show on small photo label + __pSmallPhotoLabel = new (std::nothrow) Label();//static_cast(GetControl(IDC_SMALL_PHOTO_LABEL)); + __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L""); + __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0)); + __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId); + // Add a Label to the Form + AddControl(*__pSmallPhotoLabel); + __pSmallPhotoLabel->Invalidate(true); +} + +void +IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed) +{ + Label* pTimerLbl = static_cast(GetControl(timerLblName)); + if (pTimerLbl != null) + { + pTimerLbl->SetText(textToBeDisplayed); + } +} + +void +IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap + , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap) +{ + + Button* pButton = null; + if (isButtonInPanel == false) + { + pButton = static_cast(GetControl(IDC_REJECT_MESSAGE_BUTTON)); + } + else + { + Panel* pKeysPanel = static_cast(GetControl(IDC_REJECT_PANEL)); + pButton = static_cast(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON)); + } + Bitmap* pHoldBmp = null; + Canvas* pCanvas = null; + pCanvas = new (std::nothrow) Canvas(); + pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height)); + //set bitmap to button + pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap); + if (pHoldBmp) + { + //scale bitmap to predefined size + pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pHoldBmp->Scale(Dimension(W_MESSAGE_BG_BITMAP, H_MESSAGE_BG_BITMAP)); + pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp); + } + delete pHoldBmp; + pHoldBmp = null; + pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap); + if (pHoldBmp) + { + //scale bitmap to predefined size + pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP)); + pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 6), 12), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp); + } + delete pHoldBmp; + pHoldBmp = null; + pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap); + if (pHoldBmp) + { + //scale bitmap to predefined size + pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP)); + pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp); + } + + //set button name + String holdBtnName = AppUtility::GetResourceString(btnName); + if (!holdBtnName.IsEmpty()) + { + Font font; + font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize()); + Dimension textDimension; + font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension); + textDimension.height = textDimension.height + font.GetDescender(); + TextElement* pTextElement = new (std::nothrow) TextElement(); + pTextElement->Construct(holdBtnName); + Color textColor(249, 249, 249); + if (setButtonPressBitmap) + { + textColor.SetAlpha(255); + } + else + { + textColor.SetAlpha(127); + } + + pTextElement->SetTextColor(textColor); + pTextElement->SetFont(font); + + EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText(); + pEnrichedText->Construct(textDimension); + pEnrichedText->Add(*pTextElement); + + if (pHoldBmp) + { + Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN); + pCanvas->DrawText(textPos, *pEnrichedText); + } + + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + } + + //set background bitmpa to button + Bitmap* pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds()); + if (setButtonPressBitmap) + { + pButton->SetPressedBackgroundBitmap(*pActualBgBmp); + } + else + { + pButton->SetNormalBackgroundBitmap(*pActualBgBmp); + } + delete pActualBgBmp; + delete pHoldBmp; + delete pCanvas; +} + +/*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation + */ +void +IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + __pCallPresentor->StopAlert(); + if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET) + { + Rectangle rect = source.GetBounds(); + if (source.Equals(*__pAcceptLabel)) + { + __isAnswerCallStarted = true; + __isRejectCallStarted = false; + } + else if (source.Equals(*__pRejectLabel)) + { + __isAnswerCallStarted = false; + __isRejectCallStarted = true; + } + else + { + // touch event between the 2 labels. So Do nothing + return; + } + + if (__isAnswerCallStarted) + { + for (int index = 0; index < 7; index++) + { + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(index)); + String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + switch (index) + { + case 0: + case 1: + { + __pAcceptArrowVisElem->SetOpacity(1.0f); + } + break; + + case 2: + case 3: + { + __pAcceptArrowVisElem->SetOpacity(0.8f); + } + break; + + case 4: + case 5: + case 6: + { + __pAcceptArrowVisElem->SetOpacity(0.6f); + } + break; + } + + } + } + else + { + for (int index = 0; index < 7; index++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(index)); + String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + switch (index) + { + case 0: + case 1: + { + __pRejectArrowVisElem->SetOpacity(0.6f); + } + break; + + case 2: + case 3: + { + __pRejectArrowVisElem->SetOpacity(0.8f); + } + break; + + case 4: + case 5: + case 6: + { + __pRejectArrowVisElem->SetOpacity(1.0f); + } + break; + } + + } + } + } +} + +// On Touch released, the animation and the visual elements disappear +void +IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + if (__isAnswerCallStarted == true) + { + if (currentPosition.x > REJECT_LABEL_X_OFFSET) + { + //Right reject icon + __pRejectFinalVisElem = new (std::nothrow) VisualElement(); + __pRejectFinalVisElem->Construct(); + __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + __pRejectFinalVisElem->SetShowState(true); + __pRejectFinalVisElem->SetOpacity(1.00f); + __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME); + __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem); + Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle); + pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial); + delete pCanvas; + } + + __pAcceptVisElem->SetOpacity(0.0f); + //fetch already active call list + ArrayListT* pCallList = static_cast*>(__pCallPresentor->GetCallListN()); + if (pCallList != null && pCallList->GetCount() > 0) + { + //then atleast 1 active call exist. + CallInfo phnCallInfo; + pCallList->GetAt(0,phnCallInfo); + //Check if only 1 call exist and it is on Hold + if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold()) + { + //directly accept call + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle); + } + else + { + //Either 1 call exist and not "on Hold". + //Or 2 calls exist. + if(__pOptionPopup != null) + { + delete __pOptionPopup; + __pOptionPopup = null; + } + __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor)); + __pOptionPopup->Initialize(); + __pOptionPopup->SetShowState(true); + __pOptionPopup->Draw(); + __pOptionPopup->Show(); + } + pCallList->RemoveAll(); + } + else + { + //no active call - Accept the incoming call + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle); + } + delete pCallList; + pCallList = null; + } + else + { + __pAcceptVisElem->SetOpacity(1.0f); + __pRejectVisElem->SetOpacity(1.00f); + for (int i = 0; i < 7; i++) + { + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(i)); + String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(i); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + __pAcceptArrowVisElem->SetOpacity(0.0f); + + } + } + } + else if (__isRejectCallStarted == true) + { + if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS) + { + //left dial icon + __pAcceptFinalVisElem = new (std::nothrow) VisualElement(); + __pAcceptFinalVisElem->Construct(); + __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + __pAcceptFinalVisElem->SetShowState(true); + __pAcceptFinalVisElem->SetOpacity(1.0f); + __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME); + __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem); + Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN(); + if(pCanvas != null) + { + pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL); + pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL)); + pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial); + pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle); + delete pCanvas; + } + __pRejectVisElem->SetOpacity(0.0f); + //Reject the call + __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo); + } + else + { + __pAcceptVisElem->SetOpacity(1.0f); + __pRejectVisElem->SetOpacity(1.00f); + for (int i = 0; i < 7; i++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(i)); + String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(i); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + __pRejectArrowVisElem->SetOpacity(0.0f); + + } + } + } + __isAnswerCallStarted = false; + __isRejectCallStarted = false; +} + +void +IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + if (__isAnswerCallStarted == true) + { + if (currentPosition.x > 170 && currentPosition.x < 578) + { + if (currentPosition.x > REJECT_LABEL_X_OFFSET) + { + __pRejectVisElem->SetOpacity(0.60f); + __pAcceptVisElem->SetOpacity(0.60f); + } + else + { + __pRejectVisElem->SetOpacity(1.0f); + __pAcceptVisElem->SetOpacity(1.0f); + } + for (int index = 0; index < 7; index++) + { + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(index)); + String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + switch (index) + { + case 0: + case 1: + { + if (currentPosition.x > 360) + { + __pAcceptArrowVisElem->SetOpacity(0.6f); + } + else + { + __pAcceptArrowVisElem->SetOpacity(1.0f); + } + } + break; + + case 2: + case 3: + { + __pAcceptArrowVisElem->SetOpacity(0.8f); + } + break; + + case 4: + case 5: + case 6: + { + if (currentPosition.x < 360) + { + __pAcceptArrowVisElem->SetOpacity(0.6f); + } + else + { + __pAcceptArrowVisElem->SetOpacity(1.0f); + } + } + break; + } + } + } + } + if (__isRejectCallStarted == true) + { + if (currentPosition.x < 0 && currentPosition.x > -522) + { + if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS) + { + __pRejectVisElem->SetOpacity(0.60f); + __pAcceptVisElem->SetOpacity(0.60f); + } + else + { + __pRejectVisElem->SetOpacity(1.0f); + __pAcceptVisElem->SetOpacity(1.0f); + } + for (int index = 0; index < 7; index++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(index)); + String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + VisualEleName.Append(index); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true); + switch (index) + { + case 0: + case 1: + { + if (currentPosition.x > -180) + { + __pRejectArrowVisElem->SetOpacity(0.6f); + } + else + { + __pRejectArrowVisElem->SetOpacity(1.0f); + } + } + break; + + case 2: + case 3: + { + __pRejectArrowVisElem->SetOpacity(0.8f); + } + break; + + case 4: + case 5: + case 6: + { + if (currentPosition.x < -180) + { + __pRejectArrowVisElem->SetOpacity(0.6f); + } + else + { + __pRejectArrowVisElem->SetOpacity(1.0f); + } + } + break; + } + } + } + } +} + +void +IncomingCallForm::OnItemSelected(int itemIndex) +{ + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(); + + //display name, mobile number + Integer* argIndex = new (std::nothrow) Integer(itemIndex); + pArgs->Add(argIndex); + SendUserEvent(REQUEST_ITEM_SELECTED,pArgs); +} + +void +IncomingCallForm::HandleMultipleCallSelection(int itemIndex) +{ + + if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null) + { + __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem); + } + if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null) + { + __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem); + } + + __pAcceptVisElem->SetOpacity(1.0f); + __pRejectVisElem->SetOpacity(1.00f); + + for (int i = 0; i < 7; i++) + { + __pRejectArrowLabel = static_cast(__pRejectArrowLabelsList->GetAt(i)); + String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME); + RejectVisualEleName.Append(i); + __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true); + __pRejectArrowVisElem->SetOpacity(0.0f); + __pAcceptArrowLabel = static_cast(__pAcceptArrowLabelsList->GetAt(i)); + String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME); + AcceptVisualEleName.Append(i); + __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true); + __pAcceptArrowVisElem->SetOpacity(0.0f); + } + if (__pRejectFinalVisElem != null) + { + __pRejectFinalVisElem->Destroy(); + __pRejectFinalVisElem = null; + } + + if (__pAcceptFinalVisElem != null) + { + __pAcceptFinalVisElem->Destroy(); + __pAcceptFinalVisElem = null; + } + if (__pOptionPopup) + { + delete __pOptionPopup; + __pOptionPopup = null; + } + switch (itemIndex) + { + case ID_SECOND_INCOMING_CALL: + { + //Accept call After putting on hold + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_HOLD_ACCEPT,__incomingCallHandle); + } + break; + case ID_SECOND_INCOMING_CALL + 1: + { + //Accept call After ending active call + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle); + } + break; + case ID_MULTI_PARTY_CALL: + { + //Accept call After ending active call + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle); + } + break; + case ID_MULTI_PARTY_CALL + 1: + { + //Accept call After ending held call + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_HELD_ACCEPT,__incomingCallHandle); + } + break; + case ID_MULTI_PARTY_CALL + 2: + { + //Accept call After ending all calls + __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ALL_ACCEPT,__incomingCallHandle); + } + break; + default: + break; + } +} + +void +IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs) +{ + switch(requestId) + { + case REQUEST_ITEM_SELECTED: + { + if(pArgs != null) + { + Integer *index = static_cast(pArgs->GetAt(0)); + if(index != null) + { + HandleMultipleCallSelection(index->ToInt()); + } + } + + } + break; + } + +} diff --git a/src/PhnLogsDetailForm.cpp b/src/PhnLogsDetailForm.cpp new file mode 100644 index 0000000..2a53c22 --- /dev/null +++ b/src/PhnLogsDetailForm.cpp @@ -0,0 +1,789 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnLogsDetailForm.cpp + * @brief Call log details form + */ +#include +#include +#include +#include +#include "PhnPhoneApp.h" +#include "PhnAppUtility.h" +#include "PhnLogsDetailForm.h" +#include "PhnSceneRegister.h" +#include "PhnCalllogManager.h" +#include "PhnCallPresentationModel.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +//resources +const wchar_t* IDL_CALL_LOG_DETAIL_FORM = L"IDL_CALL_LOG_DETAIL_FORM"; +const wchar_t* IDC_BUTTON_CONTACT_IMAGE = L"IDC_BUTTON_CONTACT_IMAGE"; +const wchar_t* IDC_LABEL_NAME = L"IDC_LABEL_NAME"; +const wchar_t* IDC_LABEL_NUMBER = L"IDC_LABEL_NUMBER"; +const wchar_t* IDC_LABEL_NUMBER_UNSAVED = L"IDC_LABEL_NUMBER_UNSAVED"; +const wchar_t* IDC_LABEL_BLOCKED = L"IDC_LABEL_BLOCKED"; +const wchar_t* IDC_BUTTON_MESSAGE = L"IDC_BUTTON_MESSAGE"; +const wchar_t* IDC_SELECTALL = L"IDC_SELECTALL"; +const wchar_t* IDC_BUTTON_CALL = L"IDC_BUTTON_CALL"; +const wchar_t* IDC_LABEL_DETAIL_SELECTED = L"IDC_LABEL_DETAIL_SELECTED"; + +const int IDA_CALL_LOG_CALL = 201; +const int IDA_CALL_LOG_MESSAGE = 202; +const int IDA_FOOTER_BUTTON_LEFT = 203; +const int IDA_FOOTER_BUTTON_RIGHT = 204; +const int IDA_SELECT_ALL_CHECKED = 205; +const int IDA_SELECT_ALL_UNCHECKED = 206; +const int W_BUTTON = 48; +const int H_BUTTON = 48; +const int W_BLOCKED_ICON = 56; +const int H_BLOCKED_ICON = 56; + +const wchar_t* FORMAT_STR = L"%ls (%d)"; + +static const unsigned int COLOR_DELAIL_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value; + + +DlLogsDetailForm::DlLogsDetailForm(void) +{ + __pDataProvider = new DlLogsDetailItemDataProvider(); + + __listHeight = 0; + __pButtonCall = null; + __pButtonMessage = null; + __pButtonContactImage = null; + __pLabelName = null; + __pLabelNumber = null; + __pFormFooter = null; + __pList = null; + __isEditMode = false; + __isSelectAll = false; + __isPresentInContacts = false; + __listItemCount = 0; + __selectedItemCount = 0; + __calllogListByNum = null; + __pCallMgr = null; + __calllogCount = 0; + __isMsgAppControlLaunched = false; +} + +DlLogsDetailForm::~DlLogsDetailForm(void) +{ + if (__pDataProvider != null) + { + delete __pDataProvider; + __pDataProvider = null; + } +} + +bool +DlLogsDetailForm::Initialize() +{ + result r = Construct(IDL_CALL_LOG_DETAIL_FORM); + TryCatch(r == E_SUCCESS, , "DlLogsDetailForm::Initialize Fail to initialize Call log detail form"); + return true; +CATCH: + return false; + +} + +result +DlLogsDetailForm::OnInitializing(void) +{ + AppLog(" OnInitializing SceneManager::AddSceneEventListener()"); + result r = E_SUCCESS; + Bitmap* pBitmap = null; + AppResource* pAppResource = App::GetInstance()->GetAppResource(); + + __pFormFooter = GetFooter(); + if (__pFormFooter != null) + { + __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + __pFormFooter->SetBackButton(); + __pFormFooter->AddActionEventListener(*this); + SetFormBackEventListener(this); + + __pFooterItemDelete.Construct(IDA_FOOTER_BUTTON_LEFT); + __pFooterItemDelete.SetText(AppUtility::GetResourceString(IDS_CALLLOG_DELETE_FOOTER)); + __pFormFooter->AddItem(__pFooterItemDelete); + + __pFooterItemCancel.Construct(IDA_FOOTER_BUTTON_RIGHT); + __pFooterItemCancel.SetText(AppUtility::GetResourceString(IDS_CALLLOG_CANCEL_FOOTER)); + } + + __pButtonContactImage = static_cast(GetControl(IDC_BUTTON_CONTACT_IMAGE)); + if (__pButtonContactImage != null) + { + //todo: set image & show if present in contacts + __pButtonContactImage->SetShowState(false); + } + + __pLabelName = static_cast(GetControl(IDC_LABEL_NAME)); + if (__pLabelName != null) + { + __pLabelName->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + __pLabelName->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD); + } + + __pLabelNumber = static_cast(GetControl(IDC_LABEL_NUMBER)); + if (__pLabelNumber != null) + { + __pLabelNumber->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + __pLabelNumber->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD); + __pLabelNumber->SetTextColor(Color::GetColor(COLOR_ID_GREY)); + } + + __pLabelNumberUnsaved = static_cast(GetControl(IDC_LABEL_NUMBER_UNSAVED)); + if (__pLabelNumberUnsaved != null) + { + __pLabelNumberUnsaved->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + __pLabelNumberUnsaved->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD); + } + + __pLabelBlocked = static_cast(GetControl(IDC_LABEL_BLOCKED)); + if (__pLabelBlocked != null) + { + __pLabelBlocked->SetShowState(false); + } + + pBitmap = pAppResource->GetBitmapN(IDB_LOG_DETAIL_CALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + pBitmap->Scale(Dimension(W_BUTTON, H_BUTTON)); + __pButtonCall = static_cast(GetControl(IDC_BUTTON_CALL)); + if (__pButtonCall != null) + { + __pButtonCall->SetActionId(IDA_CALL_LOG_CALL); + __pButtonCall->SetNormalBitmap(Point(__pButtonCall->GetBounds().width / 2 - W_BUTTON / 2, __pButtonCall->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working + __pButtonCall->SetPressedBitmap(Point(__pButtonCall->GetBounds().width / 2 - W_BUTTON / 2, __pButtonCall->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working + __pButtonCall->AddActionEventListener(*this); + delete pBitmap; + pBitmap = null; + } + + pBitmap = pAppResource->GetBitmapN(IDB_LOG_DETAIL_MSG_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + pBitmap->Scale(Dimension(W_BUTTON, H_BUTTON)); + + __pButtonMessage = static_cast(GetControl(IDC_BUTTON_MESSAGE)); + if (__pButtonMessage != null) + { + __pButtonMessage->SetActionId(IDA_CALL_LOG_MESSAGE); + __pButtonMessage->SetNormalBitmap(Point(__pButtonMessage->GetBounds().width / 2 - W_BUTTON / 2, __pButtonMessage->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working + __pButtonMessage->SetPressedBitmap(Point(__pButtonMessage->GetBounds().width / 2 - W_BUTTON / 2, __pButtonMessage->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working + __pButtonMessage->AddActionEventListener(*this); + + delete pBitmap; + pBitmap = null; + } + + __pSelectAll = static_cast(GetControl(IDC_SELECTALL)); + if(__pSelectAll != null) + { + __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED); + __pSelectAll->SetSize(GetClientAreaBounds().width, 112); + __pSelectAll->SetShowState(false); + __pSelectAll->AddActionEventListener(*this); + } + + __pList = new (std::nothrow) ListView(); + if (__pList != null) + { + __listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40; + int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40; + __pList->Construct(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight), true, SCROLL_STYLE_FADE_OUT); + + r = AddControl(*__pList); + TryCatch(r == E_SUCCESS, , "call log detail list control not added"); + } + + __pSelectedLabel = static_cast(GetControl(IDC_LABEL_DETAIL_SELECTED)); + if(__pSelectedLabel != null) + { + SetControlAlwaysOnTop(*__pSelectedLabel,true); + __pSelectedLabel->SetBackgroundColor(COLOR_DELAIL_LABEL_SELECTED); + __pSelectedLabel->SetShowState(false); + } + return r; +CATCH: + return r; +} + +result +DlLogsDetailForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + return r; +} + +bool +DlLogsDetailForm::DeleteSelectedCalllog(void) +{ + int checkedItemCount = 0; + CallLogDetails pCalllogInfo; + Tizen::Base::Collection::IListT* pCalllogByNumberList; + //pCalllogByNumberList = __calllogListByNum->GetValuesN(); + pCalllogByNumberList = __calllogListByNum->GetItemsN(0, __calllogListByNum->GetCount()); //to be verified + __calllogCount = pCalllogByNumberList->GetCount(); + for(int index = 0; index < __calllogCount; index++) + { + pCalllogByNumberList->GetAt(index,pCalllogInfo); + AppLog(" info from Map list %d %d %s", pCalllogInfo.GetCalllogType(), pCalllogInfo.GetDuration(), pCalllogInfo.GetPhoneNumber()); + if(__pList->IsItemChecked(index) == true ) + { + checkedItemCount++; + __pCallMgr->DeleteCalllogByDbId(pCalllogInfo.GetCalllogDbId()); + } + } + delete pCalllogByNumberList; + // return to call logs list if all items deleted + if (checkedItemCount == __calllogCount) + { + return true; + } + return false; +} + + +void +DlLogsDetailForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + + case IDA_CALL_LOG_CALL: + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(__number); + //switch to dialing outgoing call form + IList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter); + pContact->Add(contactTxt); + //Check if dialing an emergency call + bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true); + if (isEmergencyCall) + { + pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact); + } + else + { + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact); + } + } + break; + + case IDA_CALL_LOG_MESSAGE: + { + if(__isMsgAppControlLaunched == true) + { + //Message AppControl is already launched + return; + } + + //launch message + __isMsgAppControlLaunched = true; + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE)); + extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(__number)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + if(r != E_SUCCESS) + { + //AppControl failed. + __isMsgAppControlLaunched = false; + } + delete pAc; + } + extraData.RemoveAll(true); + } + break; + + case IDA_FOOTER_BUTTON_LEFT: + { + const wchar_t* pContact = __number.GetPointer(); + int len = __number.GetLength() + 1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + if (__isEditMode == false) + { + SetFormMode(true); + __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(pNumber); + __pList->UpdateList(); + __pList->Invalidate(false); + } + else + { + bool switchtoCallLogView = DeleteSelectedCalllog(); + if (switchtoCallLogView == false) + { + __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(pNumber); + UpdateForm(); + SetFormMode(false); + } + else + { + SetFormMode(false); + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); + } + } + delete[] pNumber; + pNumber = null; + } + break; + + case IDA_FOOTER_BUTTON_RIGHT: + { + SetFormMode(false); + } + break; + + case IDA_SELECT_ALL_UNCHECKED: + { + SetAllListItems(false); + __selectedItemCount = 0; + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + __pSelectedLabel->Invalidate(false); + } + break; + case IDA_SELECT_ALL_CHECKED: + { + SetAllListItems(true); + __selectedItemCount = __listItemCount; + String text; + String selItemStr = L""; + if(__selectedItemCount > 1) + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING); + } + else + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING); + } + text.Format(100, selItemStr.GetPointer(), __listItemCount); + __pSelectedLabel->SetText(text); + __pSelectedLabel->Invalidate(false); + } + break; + default: + break; + } +} + +void +DlLogsDetailForm::GetUpdatedListFromDatabase(char* number) +{ + if(__calllogListByNum != null) + { + AppLog(" list already present, UPDATE"); + __calllogListByNum->RemoveAll(); + delete __calllogListByNum; + } + + __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(number); + __calllogCount = __pCallMgr->GetCalllogCountByNumber(); +} + +void +DlLogsDetailForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + AppLog(" activated"); + __pCallMgr = CallLogManager::GetInstance(); + __isPresentInContacts = false; + __selectedItemCount =0; + __isMsgAppControlLaunched = false; + if(pArgs != null) + { + __number.Clear(); + String* pNumberStr = static_cast (pArgs->GetAt(0)); + __number.Append(*pNumberStr); + UpdateForm(); + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } + __pList->SetItemProvider(*__pDataProvider); + __pList->UpdateList(); + SetFormMode(false); +} + +void +DlLogsDetailForm::UpdateForm(void) +{ + SettingsPresentationModel* pSettingsPresentationModel = SettingsPresentationModel::GetInstance(); + bool isCallToBeRejected = pSettingsPresentationModel->IsCallToBeRejected(__number); + + const wchar_t* pContact = __number.GetPointer(); + int len = __number.GetLength() + 1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + + GetUpdatedListFromDatabase(pNumber); + delete[] pNumber; + + String contactName; + Bitmap* pBitmap = null; + Addressbook* pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN(); + if (pAddressBook != null) + { + IList* pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(__number); + if(pNumberContactsList != null) + { + Contact* pContact = static_cast(pNumberContactsList->GetAt(0)); + if(pContact != null) + { + IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + if (pPhoneNumberList != null) + { + IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN(); + while (E_SUCCESS == pEnum->MoveNext()) + { + PhoneNumber* pPhoneNumber = (PhoneNumber*) pEnum->GetCurrent(); + if(pPhoneNumber->GetPhoneNumber().Equals(__number) == true) + { + __isPresentInContacts = true; + break; + } + } + delete pEnum; + pPhoneNumberList->RemoveAll(true); + delete pPhoneNumberList; + } + + if(__isPresentInContacts == true) + { + __pLabelNumberUnsaved->SetShowState(false); + //fetch contact name + contactName.Clear(); + pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, contactName); + //fetch person's photo + pBitmap = pContact->GetThumbnailN(); + + String contactNameStr; + contactNameStr.Format(100, FORMAT_STR,contactName.GetPointer(), __calllogCount); + __pLabelName->SetText(contactNameStr); + __pLabelName->Invalidate(false); + __pLabelNumber->SetText(__number); + __pLabelNumber->Invalidate(false); + __pLabelNumberUnsaved->SetShowState(false); + __pLabelBlocked->SetShowState(false); + __pLabelName->SetShowState(true); + __pLabelNumber->SetShowState(true); + //todo: set the contact button image + Canvas* pCanvas = null; + pCanvas = new (std::nothrow) Canvas(); + pCanvas->Construct(Rectangle(0,0,__pButtonContactImage->GetBounds().width,__pButtonContactImage->GetBounds().height)); + //set bitmap to button + if (pBitmap == null) + { + pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-1_icon_contacts.png", W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM); + } + else + { + //scale bitmap to predefined size + pBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_MID); + pBitmap->Scale(Dimension(W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM)); + } + + pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap); + delete pBitmap; + pBitmap = null; + //TODO: chk whether the number is blocked and add icon in top right + if (isCallToBeRejected == true) + { + pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON); + pCanvas->DrawBitmap(Rectangle(Point(86, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap); + delete pBitmap; + pBitmap = null; + } + Bitmap* pActualBgBmp = new Bitmap(); + pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds()); + __pButtonContactImage->SetNormalBackgroundBitmap(*pActualBgBmp); + __pButtonContactImage->SetShowState(true); + __pButtonContactImage->Invalidate(false); + delete pCanvas; + delete pActualBgBmp; + } + } + pNumberContactsList->RemoveAll(true); + delete pNumberContactsList; + delete pAddressBook; + pAddressBook = null; + } + } + + if (__isPresentInContacts == false) + { + __isPresentInContacts = false; + //not in contacts rearrage the icons + String contactNameStr; + contactNameStr.Format(100, FORMAT_STR,__number.GetPointer(), __calllogCount); + __pLabelNumberUnsaved->SetText(contactNameStr); + __pLabelNumberUnsaved->Invalidate(false); + __pLabelNumberUnsaved->SetShowState(true); + __pLabelName->SetShowState(false); + __pLabelNumber->SetShowState(false); + __pButtonContactImage->SetShowState(false); + //todo set bitmap + if (isCallToBeRejected == true) + { + pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON); + __pLabelBlocked->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + pBitmap = null; + } + else + { + Canvas* pCanvas = null; + pCanvas = new (std::nothrow) Canvas(); + pCanvas->Construct(Rectangle(0,0,__pLabelBlocked->GetBounds().width,__pButtonContactImage->GetBounds().height)); + Bitmap* pActualBgBmp = new Bitmap(); + pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds()); + __pLabelBlocked->SetBackgroundBitmap(*pActualBgBmp); + delete pCanvas; + delete pActualBgBmp; + } + __pLabelBlocked->Invalidate(false); + __pLabelBlocked->SetShowState(true); + } + if (__pDataProvider != null) + { + __pDataProvider->ResetDetailsList(); + } + __pList->UpdateList(); + __pList->Invalidate(false); +} + +void +DlLogsDetailForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if (__pDataProvider != null) + { + __pDataProvider->ResetDetailsList(); + } + if (__pCallMgr != null) + { + __pCallMgr = null; + } +} + + +void +DlLogsDetailForm::SetFormMode(bool editMode) +{ + + if (editMode == false) + { + __isEditMode = false; + __pSelectAll->SetShowState(false); + __pDataProvider->SetViewMode(false); + __pFormFooter->RemoveItemAt(1); + __pFormFooter->SetBackButton(); + __pList->UpdateList(); + if (__isPresentInContacts == false) + { + __pLabelBlocked->SetShowState(true); + __pLabelNumberUnsaved->SetShowState(true); + __pLabelName->SetShowState(false); + __pLabelNumber->SetShowState(false); + __pButtonContactImage->SetShowState(false); + } + else + { + __pLabelNumberUnsaved->SetShowState(false); + __pLabelBlocked->SetShowState(false); + __pLabelName->SetShowState(true); + __pLabelNumber->SetShowState(true); + __pButtonContactImage->SetShowState(true); + } + __pButtonCall->SetShowState(true); + __pButtonMessage->SetShowState(true); + int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40; + __pList->SetBounds(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight)); + __listItemCount = __pList->GetItemCount(); + __pFormFooter->SetItemEnabled(0, true); + __pList->RemoveListViewItemEventListener(*this); + __pSelectAll->SetSelected(false); + __pSelectAll->Invalidate(false); + __pSelectedLabel->SetShowState(false); + __pSelectedLabel->Invalidate(false); + } + else + { + __isEditMode = true; + __pSelectAll->SetShowState(true); + __pDataProvider->SetViewMode(true); + __pFormFooter->AddItem(__pFooterItemCancel); + __pFormFooter->RemoveBackButton(); + __pList->AddListViewItemEventListener(*this); + __pList->UpdateList(); + UnCheckAllItems(); + if (__isPresentInContacts == false) + { + __pLabelBlocked->SetShowState(false); + __pLabelNumberUnsaved->SetShowState(false); + __pLabelName->SetShowState(false); + __pLabelNumber->SetShowState(false); + __pButtonContactImage->SetShowState(false); + } + else + { + __pLabelNumberUnsaved->SetShowState(false); + __pLabelBlocked->SetShowState(false); + __pLabelName->SetShowState(false); + __pLabelNumber->SetShowState(false); + __pButtonContactImage->SetShowState(false); + } + __pButtonCall->SetShowState(false); + __pButtonMessage->SetShowState(false); + __pList->SetBounds(GetClientAreaBounds().x, __pSelectAll->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - (__pSelectAll->GetHeight()+__pSelectedLabel->GetHeight())); + __listItemCount = __pList->GetItemCount(); + __pFormFooter->SetItemEnabled(0, false); + __selectedItemCount = 0; + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + __pSelectedLabel->SetShowState(true); + __pSelectedLabel->Invalidate(false); + } + __pSelectAll->Invalidate(true); + Draw(); +} + +void +DlLogsDetailForm::UnCheckAllItems(void) +{ + int i = 0; + for (; i <= __pList->GetItemCount(); i++) + { + __pList->SetItemChecked(i, 0); + } + __selectedItemCount = 0; +} +void +DlLogsDetailForm::SetAllListItems(bool checked) +{ + int i = 0; + __isSelectAll = checked; + for (; i <= __pList->GetItemCount(); i++) + { + __pList->SetItemChecked(i, checked); + } + __pList->UpdateList(); + __pFormFooter->SetItemEnabled(0, checked); + __pFormFooter->Invalidate(false); + __pFormFooter->Draw(); +} +void +DlLogsDetailForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY)); +} + + +void +DlLogsDetailForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus status) +{ + +} + +void +DlLogsDetailForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback) +{ + +} + +void +DlLogsDetailForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status) +{ + String text; + if (status == LIST_ITEM_STATUS_CHECKED) + { + __selectedItemCount++; + } + else if (status == LIST_ITEM_STATUS_UNCHECKED) + { + __selectedItemCount--; + } + + if (__selectedItemCount == __listItemCount) + { + __pSelectAll->SetSelected(true); + } + else + { + __pSelectAll->SetSelected(false); + } + __pSelectAll->Invalidate(false); + if (__selectedItemCount == 0) + { + __pFormFooter->SetItemEnabled(0, false); + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + } + else + { + __pFormFooter->SetItemEnabled(0, true); + String selItemStr = L""; + if(__selectedItemCount > 1) + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING); + } + else + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING); + } + text.Format(100, selItemStr.GetPointer(), __selectedItemCount); + __pSelectedLabel->SetText(text); + } + __pFormFooter->Draw(); + __pSelectedLabel->Invalidate(false); +} + +void +DlLogsDetailForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction) +{ + +} + +void +DlLogsDetailForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + if (__isMsgAppControlLaunched == true) + { + //Message AppControl request completed. + __isMsgAppControlLaunched = false; + } +} diff --git a/src/PhnLogsDetailItemProvider.cpp b/src/PhnLogsDetailItemProvider.cpp new file mode 100644 index 0000000..713c857 --- /dev/null +++ b/src/PhnLogsDetailItemProvider.cpp @@ -0,0 +1,254 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnLogsDetailItemProvider.cpp + * @brief Calllog detail item provider class + */ +#include +#include +#include +#include +#include +#include +#include "PhnAppUtility.h" +#include "PhnLogsDetailItemProvider.h" +#include "PhnCalllogManager.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Media; +using namespace Tizen::App; +const int DlLogsDetailItemDataProvider::ID_NAME_STRING = 100; +const int DlLogsDetailItemDataProvider::ID_NUMBER_STRING = 101; +const int DlLogsDetailItemDataProvider::ID_TIME_STRING = 102; +const int DlLogsDetailItemDataProvider::ID_CALLTYPE_BITMAP = 104; + +const int DlLogsDetailItemDataProvider::X_TEXT_LINE1_ITEM = 16; +const int DlLogsDetailItemDataProvider::Y_TEXT_LINE1_ITEM = 10; +const int DlLogsDetailItemDataProvider::H_TEXT_LINE1_ITEM = 60; +const int DlLogsDetailItemDataProvider::W_TEXT_LINE1_ITEM = 560; + +const int DlLogsDetailItemDataProvider::X_TEXT_LINE2_ITEM = 64; +const int DlLogsDetailItemDataProvider::Y_TEXT_LINE2_ITEM = 70; +const int DlLogsDetailItemDataProvider::H_TEXT_LINE2_ITEM = 48; +const int DlLogsDetailItemDataProvider::W_TEXT_LINE2_ITEM = 456; + +const int DlLogsDetailItemDataProvider::X_TEXT_TIME_ITEM = 536; +const int DlLogsDetailItemDataProvider::Y_TEXT_TIME_ITEM = 70; +const int DlLogsDetailItemDataProvider::H_TEXT_TIME_ITEM = 48; +const int DlLogsDetailItemDataProvider::W_TEXT_TIME_ITEM = 168; + + +const int DlLogsDetailItemDataProvider::X_CALLTYPE_BITMAP_ITEM = 16; +const int DlLogsDetailItemDataProvider::Y_CALLTYPE_BITMAP_ITEM = 70 + 8; +const int DlLogsDetailItemDataProvider::H_CALLTYPE_BITMAP_ITEM = 32; +const int DlLogsDetailItemDataProvider::W_CALLTYPE_BITMAP_ITEM = 32; + +static const int H_CALLLOGDETAIL_ITEM = 128; + +DlLogsDetailItemDataProvider::DlLogsDetailItemDataProvider(void) +{ + __isEditMode = false; + __pCalllogListByNumber = null; + __pCallMgr = CallLogManager::GetInstance(); +} + +DlLogsDetailItemDataProvider::~DlLogsDetailItemDataProvider(void) +{ + //empty implementation + if(__pCalllogListByNumber != null) + { + __pCalllogListByNumber->RemoveAll(); + delete __pCalllogListByNumber; + } + +} + +ListItemBase* +DlLogsDetailItemDataProvider::CreateItem(int index, int itemWidth) +{ + CallLogDetails calllogInfo; + DateTime t; + int duration = 0; + time_t tm; + struct tm* time = null; + char timeText[25]; + CallLogType type; + String durationText; + String typeText; + Bitmap* pBitmap = null; + AppResource* pAppResource = App::GetInstance()->GetAppResource(); + int hr, min, sec; + hr = min = sec = 0; + + if(__pCalllogListByNumber == null) + { + __pCalllogListByNumber=__pCallMgr->GetCalllogListByNumValues(); + } + + __pCalllogListByNumber->GetAt(index,calllogInfo); + //AppLog(" info from Map list from Mgr %d %d %d %s %d %d", key, pCalllogInfo.GetCalllogType(), pCalllogInfo.GetDuration(), pCalllogInfo.GetPhoneNumber(), pCalllogInfo.GetDuration(), pCalllogInfo.GetStartTime()); + duration = calllogInfo.GetDuration(); + type = calllogInfo.GetCalllogType(); + + + switch(type) + { + case CALL_LOG_TYPE_VOICE_INCOMING: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_RECEIVED)); + pBitmap = pAppResource->GetBitmapN(IDB_LOG_RECEIVEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + case CALL_LOG_TYPE_VOICE_OUTGOING: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_OUTGOING)); + pBitmap = pAppResource->GetBitmapN(IDB_LOG_DIALEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + case CALL_LOG_TYPE_VOICE_REJECTED: + case CALL_LOG_TYPE_VOICE_MISSED: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_MISSED)); + pBitmap = pAppResource->GetBitmapN(IDB_LOG_MISSEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + case CALL_LOG_TYPE_SMS_INCOMING: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_RECEIVED_MSG)); + } + break; + case CALL_LOG_TYPE_SMS_OUTGOING: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_SENT_MSG)); + } + break; + case CALL_LOG_TYPE_VOICE_BLOCKED: + { + typeText.Append(AppUtility::GetResourceString(IDS_CALLLOG_REJECTED)); + pBitmap = pAppResource->GetBitmapN(IDB_LOG_BLOCKEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + default: + { + typeText.Append(L" "); + } + break; + } + + tm = calllogInfo.GetStartTime(); + time = localtime(&tm); + if(time != null) + { + strftime(timeText,25,"%d %b %Y, %I:%M%p", time); + } + //AppLog(" dateTime %s", timeText); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + EnrichedText* text = new (std::nothrow) EnrichedText(); + TextElement* textElement = new (std::nothrow) TextElement(); + Font font; + String appPath = (Application::GetInstance())->GetAppRootPath(); + CustomItem* pItem = new (std::nothrow) CustomItem(); + if (__isEditMode == true) + { + style = LIST_ANNEX_STYLE_MARK; + } + pItem->Construct(Dimension(itemWidth, H_CALLLOGDETAIL_ITEM), style); + + /*if (__isEditMode == true && index == 0) + { + pItem->AddElement(Rectangle(16, 0, itemWidth - 76, 128), ID_NAME_STRING, L"Select All", false); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(215, 225, 232)); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, Color(215, 225, 232)); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, Color(215, 225, 232)); + return pItem; + }*/ + pItem->AddElement(Rectangle(X_TEXT_LINE1_ITEM, Y_TEXT_LINE1_ITEM, W_TEXT_LINE1_ITEM, H_TEXT_LINE1_ITEM), ID_NAME_STRING, timeText, false); + pItem->AddElement(Rectangle(X_TEXT_LINE2_ITEM, Y_TEXT_LINE2_ITEM, W_TEXT_LINE2_ITEM, H_TEXT_LINE2_ITEM), ID_NUMBER_STRING, typeText.GetPointer(), 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), false); + + if (__isEditMode == true) + { + pItem->AddElement(Rectangle(X_TEXT_LINE1_ITEM, Y_TEXT_LINE1_ITEM, W_TEXT_LINE1_ITEM - 76, H_TEXT_LINE1_ITEM), ID_NAME_STRING, timeText, false); + pItem->AddElement(Rectangle(X_TEXT_LINE2_ITEM, Y_TEXT_LINE2_ITEM, W_TEXT_LINE2_ITEM - 76, H_TEXT_LINE2_ITEM), ID_NUMBER_STRING, typeText.GetPointer(), 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), false); + } + text->Construct(Dimension(W_TEXT_TIME_ITEM, H_TEXT_TIME_ITEM)); + text->SetHorizontalAlignment(TEXT_ALIGNMENT_RIGHT); + text->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE); + hr = duration/3600; + sec = duration%3600; + min = duration/60; + sec = sec%60; + //AppLog(" time %02d:%02d:%02d", hr, min, sec); + durationText.Format(10,L"%02d:%02d:%02d", hr, min, sec); + textElement->Construct(durationText); + + font.Construct(FONT_STYLE_PLAIN, 32); + textElement->SetFont(font); + textElement->SetTextColor(Color::GetColor(COLOR_ID_GREY)); + text->Add(*textElement); + pItem->AddElement(Rectangle(X_TEXT_TIME_ITEM - 76, Y_TEXT_TIME_ITEM, W_TEXT_TIME_ITEM, H_TEXT_TIME_ITEM), ID_TIME_STRING, *text); + + Image* pImage = new (std::nothrow) Image(); + pImage->Construct(); + if (pBitmap != null) + { + pItem->AddElement(Rectangle(X_CALLTYPE_BITMAP_ITEM, Y_CALLTYPE_BITMAP_ITEM, W_CALLTYPE_BITMAP_ITEM, H_CALLTYPE_BITMAP_ITEM), ID_CALLTYPE_BITMAP, *pBitmap); + delete pBitmap; + pBitmap = null; + } + + //Background image for List items. Not woring in A3RC2 SDk.Henc ecommented + /*path.Clear(); + path = appPath + L"res/screen-density-xhigh/00_reorder_group_list_bg.png"; + pBitmap = pImage->DecodeN(path, BITMAP_PIXEL_FORMAT_RGB565); + pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL, pBitmap); + pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED, pBitmap); + pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, pBitmap);*/ + return pItem; +} + +bool +DlLogsDetailItemDataProvider::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + if (pItem != null) + { + delete pItem; + pItem = null; + } + return true; +} + +int +DlLogsDetailItemDataProvider::GetItemCount(void) +{ + int itemCount = CallLogManager::GetInstance()->GetCalllogCountByNumber(); + return itemCount; +} + +void +DlLogsDetailItemDataProvider::SetViewMode(bool mode) +{ + __isEditMode = mode; +} + +void +DlLogsDetailItemDataProvider::ResetDetailsList(void) +{ + delete __pCalllogListByNumber; + __pCalllogListByNumber = null; + +} diff --git a/src/PhnPanelFactory.cpp b/src/PhnPanelFactory.cpp new file mode 100644 index 0000000..891a2c1 --- /dev/null +++ b/src/PhnPanelFactory.cpp @@ -0,0 +1,64 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPanelFactory.cpp + * @brief The Panel factory for Dial application + */ + +#include "PhnPanelFactory.h" +#include "PhnTabDialer.h" +#include "PhnTabContacts.h" +#include "PhnTabLogs.h" +#include "PhnTabFavorites.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + + + +PanelFactory::PanelFactory(void) +{ +} + +PanelFactory::~PanelFactory(void) +{ +} + +Panel* +PanelFactory::CreatePanelN(const String& panelId, const SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + Panel* pNewPanel = null; + + if (panelId == PANEL_DIALER) + { + DialTabDialer* pPanel = new DialTabDialer(); + pPanel->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pPanel); + pNewPanel = pPanel; + } + else if (panelId == PANEL_LOGS) + { + DialTabLogs* pPanel = new DialTabLogs(); + pPanel->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pPanel); + pNewPanel = pPanel; + } + return pNewPanel; +} diff --git a/src/PhnPhoneApp.cpp b/src/PhnPhoneApp.cpp new file mode 100644 index 0000000..42ca85b --- /dev/null +++ b/src/PhnPhoneApp.cpp @@ -0,0 +1,471 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPhoneApp.cpp + * @brief Phone Application UiApp file + */ +#include +#include "PhnCallInfo.h" +#include "PhnCallPresentationModel.h" +#include "PhnPhoneAppFrame.h" +#include "PhnPhoneApp.h" +#include "PhnSceneRegister.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnTypes.h" +#include "PhnIAppStateChangeListner.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +PhoneApp::PhoneApp(void) : __isOpenAsAppControl(false), __pLaunchArgs(null) + , __initialSceneId(L"") +{ + __listenerList.Construct(); +} + +PhoneApp::~PhoneApp(void) +{ +} + +UiApp* +PhoneApp::CreateInstance(void) +{ + return new (std::nothrow) PhoneApp(); +} + +bool +PhoneApp::OnAppInitializing(AppRegistry& appRegistry) +{ + AppControlProviderManager* pProviderMgr = AppControlProviderManager::GetInstance(); + pProviderMgr->SetAppControlProviderEventListener(this); + return true; +} + +bool +PhoneApp::OnAppInitialized(void) +{ + AppLog("ENTER"); + result r = E_FAILURE; + //Check if PhoneApp is opened as AppControl + if(__isOpenAsAppControl == false) + { + //by default, initial scene is DIALER view + __initialSceneId = IDSCN_DIALER; + __pLaunchArgs = null; + } + + // Initialize Frame and App specific data. + PhoneAppFrame* pPhoneAppFrame = new (std::nothrow) PhoneAppFrame(); + pPhoneAppFrame->Construct(); + pPhoneAppFrame->SetName(L"Phone"); + r = AddFrame(*pPhoneAppFrame); + AppLog("EXIT"); + return (!IsFailed(r)); +} + +bool +PhoneApp::OnAppWillTerminate(void) +{ + return true; +} + +bool +PhoneApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +PhoneApp::OnForeground(void) +{ + IEnumerator* pEnum = __listenerList.GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + IAppStateChangeListener* pInterface = static_cast(pEnum->GetCurrent()); + if (pInterface == null) + { + delete pEnum; + + return; + } + pInterface->OnForeground(); + } + delete pEnum; +} + +void +PhoneApp::OnBackground(void) +{ + IEnumerator* pEnum = __listenerList.GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + IAppStateChangeListener* pInterface = static_cast(pEnum->GetCurrent()); + if (pInterface == null) + { + delete pEnum; + + return; + } + pInterface->OnBackground(); + } + delete pEnum; +} + +void +PhoneApp::OnLowMemory(void) +{ +} + +void +PhoneApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +void +PhoneApp::OnScreenOn(void) +{ +} + +void +PhoneApp::OnScreenOff(void) +{ +} + +bool +PhoneApp::IsOpenAsAppControl(void) +{ + return __isOpenAsAppControl; +} + +SceneId +PhoneApp::GetInitialScene(void) +{ + return __initialSceneId; +} + +void +PhoneApp::SetInitialScene(SceneId initialSceneId) +{ + __initialSceneId = initialSceneId; +} + +IList* +PhoneApp::GetAppLaunchArguments(void) +{ + return __pLaunchArgs; +} + +void +PhoneApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUriData, + const String* pMimeType, const IMap* pExtraData) +{ + AppLogDebug("ENTER"); + //process AppControl parameters + ProcessAppControlRequest(reqId, operationId, pExtraData); + AppLogDebug("EXIT"); +} + +void +PhoneApp::ProcessAppControlRequest(RequestId reqId, const String& operationId,const IMap* pArgsMap) +{ + __pLaunchArgs = null; + if(operationId.Equals(OPERATION_ID_CALL,true)) + { + __isOpenAsAppControl = true; + if(pArgsMap != null) + { + bool isIncomingCallRequest = false; + String* pKey = new (std::nothrow) String(LAUNCHTYPE); + if (pArgsMap->ContainsKey(*pKey) == true) + { + const String* pValue = static_cast(pArgsMap->GetValue(*pKey)); + if ((pValue != null) && (pValue->Equals(PARAM_ORIGIN_MT, true) == true)) + { + isIncomingCallRequest = true; + } + } + //Check if incoming call request or outgoing call request + if(isIncomingCallRequest == true) + { + HandleIncomingCallAppControlRequest(reqId, pArgsMap); + } + else + { + HandleDialCallAppControlRequest(reqId, pArgsMap); + } + } + } + else if(operationId.Equals(OPERATION_ID_DIAL,true)) + { + __isOpenAsAppControl = true; + HandleDialerAppControlRequest(reqId, pArgsMap); + } + else if (operationId.Equals(OPERATION_ID_CONFIGURE, true)) + { + __isOpenAsAppControl = true; + HandleSettingsAppControlRequest(reqId, pArgsMap); + } +} + +void +PhoneApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + //response message + AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED; + + //call handle + String callHandle(L""); + String* pKey = new (std::nothrow) String(CALL_HANDLE); + if (pArgsMap->ContainsKey(*pKey) == true) + { + const String* pValue = static_cast(pArgsMap->GetValue(*pKey)); + if (pValue != null) + { + callHandle.Append(*pValue); + } + } + delete pKey; + //contact number + String contactNumber(L""); + pKey = new (std::nothrow) String(CONTACT_NUMBER); + if (pArgsMap->ContainsKey(*pKey) == true) + { + const String* pContactValue = static_cast(pArgsMap->GetValue(*pKey)); + if (pContactValue != null) + { + contactNumber.Append(*pContactValue); + } + } + delete pKey; + pKey = null; + + //Fetch incoming call details + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + CallInfo* pIncomingCall = pCallPresentor->FetchIncomingCallDetailsN(callHandle, contactNumber); + if(pIncomingCall != null) + { + bool isCallRejected = pCallPresentor->CheckIncomingCallToBeRejected(pIncomingCall); + if(isCallRejected == false) + { + //save app launch argument list + __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pLaunchArgs->Construct(1); + __pLaunchArgs->Add(pIncomingCall); + if(__initialSceneId.IsEmpty() == true) + { + __initialSceneId = IDSCN_SCENE_INCOMINGCALL; + } + else + { + //App already initialized, goto incoming call form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), __pLaunchArgs); + __pLaunchArgs = null; + } + } + else + { + //Show messageBox showing automatic call rejection + MessageBox callRejectedInoMsgBox; + String msg(L"Call From "); + msg.Append(contactNumber); + msg.Append(L" Rejected."); + callRejectedInoMsgBox.Construct(L"Call Rejected", msg, MSGBOX_STYLE_NONE,1000); + int modalResult = 0; + // Calls ShowAndWait() : Draws and Shows itself and processes events + callRejectedInoMsgBox.ShowAndWait(modalResult); + + //go back to previous scene if App was already running, else exit application. + if(__initialSceneId.IsEmpty() == true) + { + //KEEP "__initialSceneId" as empty and return false from "OnAppInitialized()" + AppLog("Terminate Phone Application"); + } + else if (pCallPresentor->GetCurrentCallCount() == 0) + { + // NOTE: Let the user remain on whatever screen he/she is, + // but the framework will bring PhoneApp to foreground. + /*pSceneManager->GoForward(ForwardSceneTransition(__initialSceneId), null);*/ + } + } + //set success message + appControlResult = APP_CTRL_RESULT_SUCCEEDED; + } + else + { + __isOpenAsAppControl = false; + appControlResult = APP_CTRL_RESULT_FAILED; + } + AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null); +} + +void +PhoneApp::HandleDialerAppControlRequest(RequestId reqId,const IMap* pArgsMap) +{ + //start Dial Form + if (pArgsMap != null) + { + String* pKey = new (std::nothrow) String(PARAM_PHONE_NUMBER); + if (pArgsMap->ContainsKey(*pKey) == true) + { + const String* pPhoneValue = static_cast(pArgsMap->GetValue(*pKey)); + if (pPhoneValue != null) + { + String* tmpStr = new (std::nothrow) String(*pPhoneValue); + __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pLaunchArgs->Construct(); + __pLaunchArgs->Add(tmpStr); + } + } + delete pKey; + } + + //Check if app is already launched + if(__initialSceneId.IsEmpty() == true) + { + __initialSceneId = IDSCN_DIALER; + } + else + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY),__pLaunchArgs); + __pLaunchArgs = null; + } + //response message + AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, APP_CTRL_RESULT_SUCCEEDED, null); +} + +void +PhoneApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) +{ + //response message + AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED; + + if (pArgsMap != null) + { + String callType(L""); + String phoneNumber(L""); + //phone number + String* pKey = new (std::nothrow) String(PARAM_PHONE_NUMBER); + if(pArgsMap->ContainsKey(*pKey) == true) + { + const String* pPhoneValue = static_cast(pArgsMap->GetValue(*pKey)); + if(pPhoneValue != null) + { + phoneNumber.Append(*pPhoneValue); + } + } + delete pKey; + //call type + pKey = new (std::nothrow) String(PARAM_CALL_TYPE); + if(pArgsMap->ContainsKey(*pKey) == true) + { + const String* pCallTypeValue = static_cast(pArgsMap->GetValue(*pKey)); + if(pCallTypeValue != null) + { + callType.Append(*pCallTypeValue); + } + } + delete pKey; + pKey = null; + + //Fetch currently active call count + if (callType.IsEmpty() == false + && callType.Equals(PARAM_CALL_VALUE_VOICE, false) == true + && phoneNumber.IsEmpty() == false) + { + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + int currentActiveCallCount = pCallPresentor->GetCurrentCallCount(); + if(currentActiveCallCount <= 1) + { + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(phoneNumber); + __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pLaunchArgs->Construct(); + __pLaunchArgs->Add(contactTxt); + bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true); + + SceneId nextScene = IDSCN_SCENE_OUTCALL; + if (isEmergencyCall) + { + nextScene = IDSCN_SCENE_OUT_EMERGENCYCALL; + } + + //Check if app was already running + if(__initialSceneId.IsEmpty() == true) + { + //phone App is not already launched + __initialSceneId = nextScene; + } + else + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward( ForwardSceneTransition( nextScene), __pLaunchArgs); + } + appControlResult = APP_CTRL_RESULT_SUCCEEDED; + } + else + { + //already 2 active calls, 3rd call not allowed + appControlResult = APP_CTRL_RESULT_CANCELED; + } + } + else + { + appControlResult = APP_CTRL_RESULT_FAILED; + } + } + //send response message + AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null); +} + +void +PhoneApp::HandleSettingsAppControlRequest(RequestId reqId,const IMap* pArgsMap) +{ + if(__initialSceneId.IsEmpty() == true) + { + __initialSceneId = IDSCN_SCENE_MAIN_SETTING_MENU; + } + else + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MAIN_SETTING_MENU), null); + } + //send response message + AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, APP_CTRL_RESULT_SUCCEEDED, null); +} + +void +PhoneApp::AddAppStateChangeListener(const IAppStateChangeListener& listener) +{ + __listenerList.Add(listener); + +} +void +PhoneApp::RemoveAppStateChangeListener(const IAppStateChangeListener& listener) +{ + __listenerList.Remove(listener); +} + + diff --git a/src/PhnPhoneAppEntry.cpp b/src/PhnPhoneAppEntry.cpp new file mode 100644 index 0000000..b9724d8 --- /dev/null +++ b/src/PhnPhoneAppEntry.cpp @@ -0,0 +1,53 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnPhoneAppEntry.cpp + * @brief Phone Application Entry file + */ +#include "PhnPhoneApp.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// +// The entry function of Tizen application called by the operating system. +// +_EXPORT_ int +OspMain(int argc, char* pArgv[]) +{ + AppLog("Application started."); + ArrayList args(SingleObjectDeleter); + args.Construct(); + for (int i = 0; i < argc; i++) + { + args.Add(new (std::nothrow) String(pArgv[i])); + } + + result r = Tizen::App::UiApp::Execute(PhoneApp::CreateInstance, &args); + TryLog(r == E_SUCCESS, "[%s] Application execution failed", GetErrorMessage(r)); + AppLog("Application finished."); + + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/src/PhnPhoneAppFrame.cpp b/src/PhnPhoneAppFrame.cpp new file mode 100644 index 0000000..8159d46 --- /dev/null +++ b/src/PhnPhoneAppFrame.cpp @@ -0,0 +1,60 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhoneAppFrame.cpp + * @brief Phone Application Frame + */ +#include "PhnPhoneApp.h" +#include "PhnPhoneAppFrame.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Ui::Scenes; + +PhoneAppFrame::PhoneAppFrame(void) +{ +} + +PhoneAppFrame::~PhoneAppFrame(void) +{ +} + +result +PhoneAppFrame::OnInitializing(void) +{ + result r = E_FAILURE; + PhoneApp* pPhoneApp = static_cast(UiApp::GetInstance()); + if(pPhoneApp != null && pPhoneApp->GetInitialScene().IsEmpty() == false) + { + //Initialize factory methods and register all scenes. + r = SceneRegister::RegisterAllScenes(); + TryReturn(r == E_SUCCESS, r , "Scene registration failed"); + + //start initial Form + SceneManager* pSceneManager = SceneManager::GetInstance(); + r = pSceneManager->GoForward( ForwardSceneTransition(pPhoneApp->GetInitialScene(), SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY), pPhoneApp->GetAppLaunchArguments()); + } + return r; +} + +result +PhoneAppFrame::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} diff --git a/src/PhnPhoneFormFactory.cpp b/src/PhnPhoneFormFactory.cpp new file mode 100644 index 0000000..8987bde --- /dev/null +++ b/src/PhnPhoneFormFactory.cpp @@ -0,0 +1,327 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FormFactory.cpp + * @brief Form factory class + */ +#include "PhnPhoneFormFactory.h" +#include "PhnSceneRegister.h" +//Call forms +#include "PhnIncomingCallForm.h" +#include "PhnActiveCallForm.h" +#include "PhnConfCallerListForm.h" +#include "PhnEndCallForm.h" +//Settings Forms +#include "PhnSettingsMainMenuForm.h" +#include "PhnSettingsRejectListForm.h" +#include "PhnSettingsRejectMsgsForm.h" +#include "PhnSettingsSpeedDialForm.h" +#include "PhnSettingsMoreOptionsForm.h" +#include "PhnSettingsCallStatusTonesForm.h" +#include "PhnSettingsCallForwardWaitBarrForm.h" +#include "PhnSettingsAddNumberForm.h" +#include "PhnSettingsEditRejectMsgForm.h" +#include "PhnSettingsForwardToNumberForm.h" +#include "PhnSettingsBarringPwdForm.h" +#include "PhnSettingsDeleteListForm.h" +//Dial Forms +#include "PhnDialAppForm.h" +#include "PhnLogsDetailForm.h" +#include "PhnEmergencyDialForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + + + +FormFactory::FormFactory(void) +{ +} + +FormFactory::~FormFactory(void) +{ +} + +Form* +FormFactory::CreateFormN(const String& formId, const SceneId& sceneId) +{ + Form* pNewForm = null; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + if (formId == IDL_FORM_DIAL_APP) { + DialAppForm* pForm = new (std::nothrow) DialAppForm(); + pForm->Initialize(); + //pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } else if (formId == IDL_FORM_CALL_LOG_DETAIL) { + DlLogsDetailForm* pForm = new (std::nothrow) DlLogsDetailForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } else if(formId == IDL_FORM_EMERGENCY_DIAL) + { + EmergencyDialForm* pForm = new (std::nothrow) EmergencyDialForm(); + pForm->Initialize(); + //pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId.StartsWith(IDL_FORM_SETTINGS_PREFIX,0) == true) + { + pNewForm = CreateCallSettingsForm(formId, sceneId); + } + else + { + pNewForm = CreateVoiceCallForm(formId, sceneId); + } + + return pNewForm; +} + +Form* +FormFactory::CreateVoiceCallForm(const String& formId, const SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + BaseForm* pNewForm = null; + + if (formId == IDL_FORM_OUTCALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_OUTGOINGCALL); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_OUT_EMERGENCYCALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_EMERGENCYOUTGOINGCALL); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_ACTIVECALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_ACTIVECALL); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_ACTIVE_EMERGENCYCALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_EMERGENCYACTIVECALL); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_INCOMINGCALL) + { + IncomingCallForm* pForm = new (std::nothrow) IncomingCallForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_ENDCALL) + { + EndCallForm* pForm = new (std::nothrow) EndCallForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CONFCALLLIST) + { + ConfCallerListForm* pForm = new (std::nothrow) ConfCallerListForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_MULTIPLEACTIVECALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_MULTIPLECALLS); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CONFCALL) + { + ActiveCallForm* pForm = new (std::nothrow) ActiveCallForm(FORMTYPE_ACTIVECONFCALL); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + return pNewForm; +} + +Form* +FormFactory::CreateCallSettingsForm(const String& formId, const SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + Form* pNewForm = null; + + if (formId == IDL_FORM_MAIN_SETTING_MENU) + { + SettingsMainMenuForm* pForm = new (std::nothrow) SettingsMainMenuForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_REJECTLIST_MENU) + { + SettingsRejectListForm* pForm = new (std::nothrow) SettingsRejectListForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_REJECTMSGS_MENU) + { + SettingsRejectMsgsForm* pForm = new (std::nothrow) SettingsRejectMsgsForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_SPEED_DIAL) + { + SettingsSpeedDialForm* pForm = new (std::nothrow) SettingsSpeedDialForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_MORE_OPTIONS) + { + SettingsMoreOptionsForm* pForm = new (std::nothrow) SettingsMoreOptionsForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_STATUSTONES) + { + SettingsCallStatusTonesForm* pForm = new (std::nothrow) SettingsCallStatusTonesForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALLTYPE_FORWARD) + { + SettingsCallForwardWaitBarrForm* pForm = new (std::nothrow) SettingsCallForwardWaitBarrForm( + SettingsCallForwardWaitBarrForm::FORMTYPE_CALLFORWARDING_TYPE); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_FORWARD_OPTIONS) + { + SettingsCallForwardWaitBarrForm* pForm = new (std::nothrow) SettingsCallForwardWaitBarrForm( + SettingsCallForwardWaitBarrForm::FORMTYPE_VOICE_CALLFORWARDING); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALLTYPE_BARRING) + { + SettingsCallForwardWaitBarrForm* pForm = new (std::nothrow) SettingsCallForwardWaitBarrForm( + SettingsCallForwardWaitBarrForm::FORMTYPE_CALLBARRING_TYPE); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_BARRING_OPTIONS) + { + SettingsCallForwardWaitBarrForm* pForm = new (std::nothrow) SettingsCallForwardWaitBarrForm( + SettingsCallForwardWaitBarrForm::FORMTYPE_VOICE_CALLBARRING); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_CALL_WAITING_OPTIONS) + { + SettingsCallForwardWaitBarrForm* pForm = new (std::nothrow) SettingsCallForwardWaitBarrForm( + SettingsCallForwardWaitBarrForm::FORMTYPE_CALL_WAITING); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_ADD_REJECT_NUMBER) + { + SettingsAddNumberForm* pForm = new (std::nothrow) SettingsAddNumberForm(SettingsAddNumberForm::FORMTYPE_NUMBER_TO_REJECT); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_AUTO_AREA_CODE) + { + SettingsAddNumberForm* pForm = new (std::nothrow) SettingsAddNumberForm(SettingsAddNumberForm::FORMTYPE_AUTO_AREA_CODE); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_ADD_REJECT_MSG) + { + SettingsEditRejectMsgForm* pForm = new (std::nothrow) SettingsEditRejectMsgForm(SettingsEditRejectMsgForm::FORMMODE_NEW_MESSAGE); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_EDIT_REJECT_MSG) + { + SettingsEditRejectMsgForm* pForm = new (std::nothrow) SettingsEditRejectMsgForm(SettingsEditRejectMsgForm::FORMMODE_EDIT_MESSAGE); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_FORWARD_TO_NUMBER) + { + SettingsForwardToNumberForm* pForm = new (std::nothrow) SettingsForwardToNumberForm(SettingsForwardToNumberForm::FORWARDCONDITION); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_NOREPLY_FORWARD_TO_NUMBER) + { + SettingsForwardToNumberForm* pForm = new (std::nothrow) SettingsForwardToNumberForm(SettingsForwardToNumberForm::FORWARDCONDITION_NOREPLY); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_SCENE_SET_BARRING_PWD) + { + SettingsBarringPwdForm* pForm = new (std::nothrow) SettingsBarringPwdForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_DEL_NUMBER) + { + SettingsDeleteListForm* pForm = new (std::nothrow) SettingsDeleteListForm(SettingsDeleteListForm::LISTOF_NUMBERS); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == IDL_FORM_DEL_MESSAGE) + { + SettingsDeleteListForm* pForm = new (std::nothrow) SettingsDeleteListForm(SettingsDeleteListForm::LISTOF_MESSAGES); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + return pNewForm; +} diff --git a/src/PhnRetrieveSuggestionsTasks.cpp b/src/PhnRetrieveSuggestionsTasks.cpp new file mode 100644 index 0000000..750d845 --- /dev/null +++ b/src/PhnRetrieveSuggestionsTasks.cpp @@ -0,0 +1,605 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnRetrieveSuggestionsTasks.cpp + * @brief RetrieveContactsListTask class + */ +#include "PhnAppUtility.h" +#include "PhnCalllogManager.h" +#include "PhnCommonUtils.h" +#include "PhnDialContactInfo.h" +#include "PhnRetrieveSuggestionsTasks.h" +#include "PhnSettingsManager.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; + + +RetrieveContactsListTask::RetrieveContactsListTask(ISuggestionsRetrievedEventListener& pEventListener) + : __pEventListener(pEventListener), __pContactsList(null), __pNumberStr(null) +{ +} + +RetrieveContactsListTask::~RetrieveContactsListTask() +{ + if(__pNumberStr) + { + delete __pNumberStr; + } + if (__pAddressBook != null) + { + delete __pAddressBook; + } +} + +result +RetrieveContactsListTask::Construct(String& searchString,const IList* oldSearchResults) +{ + result r = E_SUCCESS; + + __pAddressBook = new (std::nothrow) Addressbook(); + r = __pAddressBook->Construct(); + TryCatch (r == E_SUCCESS,, "AddressBook.Contruct() failed"); + //new search string and result list + __pNumberStr = new (std::nothrow) String(searchString); + __pContactsList = new (std::nothrow) ArrayList(SingleObjectDeleter); + r = __pContactsList->Construct(); + TryCatch (r == E_SUCCESS,,"ArrayList.Contruct() failed"); + + //Copy old search result, if available + if(oldSearchResults != null) + { + IEnumerator* pOldResultsEnum = oldSearchResults->GetEnumeratorN(); + while(pOldResultsEnum->MoveNext() == E_SUCCESS) + { + DialContactInfo* pContactInfo = (static_cast(pOldResultsEnum->GetCurrent()))->CloneN(); + if(pContactInfo != null) + { + __pContactsList->Add(pContactInfo); + } + } + delete pOldResultsEnum; + } + + return r; + +CATCH: + delete __pAddressBook; + delete __pNumberStr; + delete __pContactsList; + return r; +} + +Object* +RetrieveContactsListTask::Run(void) +{ + //check if this is a new search + if(__pContactsList != null && __pContactsList->GetCount() > 0) + { + //filter out suggestion list + UpdateSuggestionList(); + } + else + { + //search for Speed dial number -> 1st Priority in Result List. + SearchSpeedDialForNumberN(); + + if(__pNumberStr->GetLength() > 0) + { + //searches contacts by name -> 2nd Priority in result list + SearchContactsForName(); + //Searches contacts by number -> 3rd Priority in result list + SearchContactsForNumber(); + } + //TODO: Search logs by number - Last Priority in the list + //Only Unknown Numbers are added, since known numbers will be added from above searches + /*SearchCallLogsForNumber();*/ + } + + //Inform listener about search completion. + __pEventListener.HandleContactsRetrievalCompleted(__pContactsList); + __pContactsList = null; + return null; +} + +void +RetrieveContactsListTask::UpdateSuggestionList(void) +{ + //search through each list to filter out suggestions not matching new search string. + for (int index = 0; index < __pContactsList->GetCount(); index++) + { + DialContactInfo* pContact = static_cast(__pContactsList->GetAt(index)); + if(pContact == null) + {//goto next record + continue; + } + //Fetch search key list + IList* pKeyList = pContact->GetSearchKeyList(); + int nextKey = 0; + while(nextKey < pKeyList->GetCount()) + { + bool isRemoveKey = false; + //search for Speed dial + String* keyWord = static_cast(pKeyList->GetAt(nextKey)); + if(keyWord->Equals(String(IDS_SPEED_DIAL_SEARCH_KEY)) == true && __pNumberStr->GetLength() > 1) + { + isRemoveKey = true; + } + else if((__pNumberStr->GetLength() > 0) && (DialUtil::IsNumericString(*keyWord) == true)) + { + //search for number - update list + if (pContact->GetPhoneNumber().Contains(*__pNumberStr) == false) + { + isRemoveKey = true; + } + else + { + //update search keys. + pContact->ReplaceSearchKey(nextKey, *__pNumberStr); + } + } + else + { + //search For name + //substring of contact name to match + String subName; + //numeric keys typed, equivalent to above 'subName'. + String numericKey; + String contactName = pContact->GetDisplayName(); + contactName.SubString(0,__pNumberStr->GetLength(),subName); + DialUtil::ConvertNameToNumericKeys(subName,numericKey); + if(numericKey.Equals(*__pNumberStr) == true) + { + //update search keys. + pContact->ReplaceSearchKey(nextKey, subName); + } + else + { + isRemoveKey = true; + } + } + + //remove previous search key, as updated key did'nt match. + if(isRemoveKey == true) + { + pContact->RemoveSearchKey(nextKey); + } + else + { + nextKey++; + } + } + + //Add to contacts list to be removed + if(pKeyList->GetCount() <= 0) + { + __pContactsList->RemoveAt(index); + index--; + } + } + + //Need to sort arraylist according to latest search keys. + if(__pContactsList->GetCount() > 0) + { + SuggestionListComparer* pComparer = new (std::nothrow) SuggestionListComparer(); + __pContactsList->Sort(*pComparer); + delete pComparer; + } + else + { + //remove old search key + delete __pNumberStr; + __pNumberStr = null; + } +} + +void +RetrieveContactsListTask::SearchContactsForNumber(void) +{ + //Searches contacts by (part of)phone number. + IList* pResultList = __pAddressBook->SearchContactsByPhoneNumberN(*__pNumberStr); + if(pResultList != null && pResultList->GetCount() > 0) + { + SaveContactsToListByNumber(*pResultList, *__pNumberStr); + pResultList->RemoveAll(true); + } + delete pResultList; +} + +void +RetrieveContactsListTask::SearchContactsForName(void) +{ + // If phoneNumber: "23" -> Possible string matches -> 9. + // It is much better to do first 3(2=A,B,C) search in 1000 fields(in database), and + // subsequent 9 searches in locally stored array of fewer records. + // then to 9 search searches in 1000 fields(in database). + + //Fetch matching names for mapping char for first digit, e.g. 2->ABC, 3->DEF. + int digit = 0; + String strDigit; + __pNumberStr->SubString(0,1,strDigit); + Integer::Parse(strDigit,digit); + IList* pNamesList = DialUtil::FetchPossibleNamesListN(L"",digit); + if (pNamesList != null) + { + int totalMatches = pNamesList->GetCount(); + for (int index = 0; index < totalMatches; index++) + { + //Search All names that start with single character + String* searchKey = static_cast(pNamesList->GetAt(index)); + SearchContactsWithInitialChar(*searchKey); + } + pNamesList->RemoveAll(); + delete pNamesList; + } +} + +void +RetrieveContactsListTask::SearchContactsWithInitialChar(String& searchStr) +{ + //search for contacts which contains 'searchStr' anywhere in displayName. + IList* pResultList = __pAddressBook->SearchContactsByNameN(searchStr); + //Check if empty list. + if(pResultList == null || pResultList->GetCount() <= 0) + { + delete pResultList; + return; + } + + //further filter out result list - save contacts starting with 'searchStr'. + ArrayList* pDialInfoList = new (std::nothrow) ArrayList(); + pDialInfoList->Construct(); + + for(int index = 0; index < pResultList->GetCount(); index++) + { + Contact* pContact = static_cast(pResultList->GetAt(index)); + //Check if display name starts with search string + String contactName; + result r = pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, contactName); + if ((r == E_SUCCESS) && (contactName.StartsWith(searchStr, 0) == true)) + { + //substring of contact name to match + String subName; + //numeric keys typed, equivalent to above 'subName'. + String numericKey; + contactName.SubString(0,__pNumberStr->GetLength(),subName); + DialUtil::ConvertNameToNumericKeys(subName,numericKey); + if(numericKey.Equals(*__pNumberStr) == true) + { + DialContactInfo* pDialInfo = ConvertToDialContactN(*pContact,subName); + if(pDialInfo != null) + { + pDialInfoList->Add(*pDialInfo); + } + } + } + } + pResultList->RemoveAll(true); + delete pResultList; + + //save list + if(pDialInfoList->GetCount() > 0 && __pContactsList != null) + { + //remove duplicate items + pDialInfoList->RemoveItems(*__pContactsList,true); + //Add all distinct item to list + __pContactsList->AddItems(*pDialInfoList); + //remove ownership for all items. + pDialInfoList->RemoveAll(); + } + delete pDialInfoList; +} + +void +RetrieveContactsListTask::SearchSpeedDialForNumberN(void) +{ + //Check if only 1 digit number + if(__pNumberStr->GetLength() != 1) + { + return; + } + //convert to speed dial rowId + int rowId; + Integer::Parse(*__pNumberStr, rowId); + if (rowId < 2 || rowId > 9) + { + return; + } + + //Fetch matched speed dial contact number + SettingsManager* pSettingsManager = SettingsManager::GetInstance(); + String* contactNo = pSettingsManager->GetMappedSpeedDialNumberN(rowId); + if (contactNo == null) + { + return; + } + + //Fetch Contact for phoneNumber + IList* pContactList = __pAddressBook->SearchContactsByPhoneNumberN(*contactNo); + if (pContactList != null) + { + IEnumerator* pContactsEnum = pContactList->GetEnumeratorN(); + while (pContactsEnum->MoveNext() == E_SUCCESS) + { + Contact* pContact = static_cast(pContactsEnum->GetCurrent()); + if(pContact != null) + { + //save to HashMap - ownership transferred of key-value pair. + DialContactInfo* pDialContact = ConvertToDialContactN(*pContact,*contactNo); + if(pDialContact != null) + { + IList* keyList = pDialContact->GetSearchKeyList(); + keyList->SetAt(*(new String(IDS_SPEED_DIAL_SEARCH_KEY)),(keyList->GetCount()-1), true); + __pContactsList->Add(pDialContact); + } + } + } + + //free resources + delete pContactsEnum; + pContactList->RemoveAll(true); + delete pContactList; + } + delete contactNo; +} + +/*void +RetrieveContactsListTask::SearchCallLogsForNumber(void) +{ + //conversion "contactNumber" to char* + const wchar_t* pContact = __pNumberStr->GetPointer(); + int len = __pNumberStr->GetLength()+1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + + //fetch Unknown numbers from Call logs Manager containing search string. + HashMapT* pLogsByNumber = CallLogManager::GetInstance()->GetCallogListByUnknownNumberFromDatabaseN(pNumber); + if(pLogsByNumber != null) + { + IListT* logDetailsList = pLogsByNumber->GetValuesN(); + if(logDetailsList != null) + { + //Convert to DialContacts + for(int index=0;indexGetCount();index++) + { + CallLogDetails logDetails; + result r = logDetailsList->GetAt(index,logDetails); + if(r == E_SUCCESS) + { + DialContactInfo* pDialContact = ConvertLogDetailsToDialContactN(logDetails); + if(pDialContact != null) + { + if((__pContactsList->GetCount() <= 0) || (__pContactsList->Contains(*pDialContact) == false)) + { + //Add only 'unknown' number to Map + __pContactsList->Add(pDialContact); + } + else + { + delete pDialContact; + pDialContact = null; + } + } + } + } + delete logDetailsList; + } + delete pLogsByNumber; + } +}*/ + +void +RetrieveContactsListTask::SaveContactsToListByNumber(IList& saveList, String& matchedString) +{ + if(__pContactsList != null) + { + //List of contacts to be saved + for (int index = 0; index < saveList.GetCount(); index++) + { + Contact* pContact = static_cast(saveList.GetAt(index)); + DialContactInfo* pDialContact = ConvertToDialContactN(*pContact, matchedString); + if (pDialContact != null) + { + //check if already present + int foundItemIndex; + if (__pContactsList->IndexOf(*pDialContact, foundItemIndex) != E_SUCCESS) + { + //save new mapping + __pContactsList->Add(pDialContact); + } + else + { + //Add search key to existing list + DialContactInfo* pExistingInfo = static_cast(__pContactsList->GetAt( foundItemIndex)); + if (pExistingInfo != null) + { + pExistingInfo->AddSearchKey(*(pDialContact->GetSearchKey())); + } + delete pDialContact; + } + } + } + } +} + +DialContactInfo* +RetrieveContactsListTask::ConvertToDialContactN(Contact& contact, String& matchedString) +{ + result r = E_FAILURE; + + //display name + String displayName; + r = contact.GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName); + TryReturn(r == E_SUCCESS,null,"Display name not available"); + + //phone number + String phoneNumber(L""); + IList* pNumberList = contact.GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + if(pNumberList == null || pNumberList->GetCount() <= 0) + { + delete pNumberList; + return null; + } + + if(DialUtil::IsNumericString(matchedString) == true) + { + //this contact searched by phone number + IEnumerator* pPhoneEnum = pNumberList->GetEnumeratorN(); + while (E_SUCCESS == pPhoneEnum->MoveNext()) + { + PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent(); + //Check if this is the correct contact + if (pPhoneNumber->GetPhoneNumber().Contains(matchedString) == true) + { + phoneNumber.Append(pPhoneNumber->GetPhoneNumber()); + break; + } + } + delete pPhoneEnum; + } + else + { + //this contact searched by name + PhoneNumber* pContactNo = static_cast(pNumberList->GetAt(0)); + phoneNumber.Append(pContactNo->GetPhoneNumber()); + } + pNumberList->RemoveAll(true); + delete pNumberList; + pNumberList = null; + TryReturn((phoneNumber.IsEmpty() == false), null, "No matching phone number found"); + + DialContactInfo* pDialContact = new (std::nothrow) DialContactInfo(); + pDialContact->AddSearchKey(matchedString); + pDialContact->SetPhoneNumber(phoneNumber); + pDialContact->SetDisplayName(displayName); + + //Check if Thumbnail is present + Bitmap* pThumbnail = contact.GetThumbnailN(); + if(pThumbnail != null) + { + pDialContact->SetThumbnail(pThumbnail); + } + return pDialContact; +} + +/*DialContactInfo* +RetrieveContactsListTask::ConvertLogDetailsToDialContactN(CallLogDetails& logDetails) +{ + DialContactInfo* pDialContact = new (std::nothrow) DialContactInfo(); + String emptyDisplayName(L""); + pDialContact->SetDisplayName(emptyDisplayName); + //call log db id + pDialContact->SetCallLogDbId(logDetails.GetCalllogDbId()); + + String phoneNumber(logDetails.GetPhoneNumber()); + pDialContact->SetPhoneNumber(phoneNumber); + pDialContact->AddSearchKey(*__pNumberStr); + return pDialContact; +}*/ + +/////////////////////////////////////////////// +// SuggestionListComparer Implementation ////// +/////////////////////////////////////////////// +result +SuggestionListComparer::Compare(const Object& objRef1, const Object& objRef2, int& cmpResult) const +{ + result r = E_INVALID_ARG; + + //Check if both object are of type 'DialContactInfo' + DialContactInfo* pDialInfo1 = dynamic_cast(const_cast(&objRef1)); + DialContactInfo* pDialInfo2 = dynamic_cast(const_cast(&objRef2)); + if((pDialInfo1 == null) || (pDialInfo2 == null)) + { + return r; + } + r = E_SUCCESS; + + //Rules for comparison:- + //Priority 1 - show contacts for Speed dial. + //Priority 2 - show contacts searched by Name from Contacts. + //Priority 3 - show contacts searched by Number from Contacts. + //Priority 4 - show contacts searched by Number from Logs. + + //Fetch initial search keys for both objects + String displayName1 = pDialInfo1->GetDisplayName(); + String* searchKey1 = pDialInfo1->GetSearchKey(); + bool isNumericKey1 = DialUtil::IsNumericString(*searchKey1); + + String displayName2 = pDialInfo2->GetDisplayName(); + String* searchKey2 = pDialInfo2->GetSearchKey(); + bool isNumericKey2 = DialUtil::IsNumericString(*searchKey2); + + //via Speed Dial + if(searchKey1->Equals(String(IDS_SPEED_DIAL_SEARCH_KEY))) + { + cmpResult = 1;//objRef1 is searched via Speed Dial + return r; + } + else if (searchKey2->Equals(String(IDS_SPEED_DIAL_SEARCH_KEY))) + { + cmpResult = -1;//objRef2 via Speed Dial + return r; + } + + //via Logs + if((displayName1.IsEmpty() == false) && (displayName2.IsEmpty() == true)) + { + cmpResult = -1;//objRef1 NOT via Logs, objRef2 via Logs + return r; + } + else if((displayName1.IsEmpty() == true) && (displayName2.IsEmpty() == false)) + { + cmpResult = 1;//objRef2 NOT via Logs, objRef1 via Logs + return r; + } + else if((displayName1.IsEmpty() == true) && (displayName2.IsEmpty() == true)) + { + //Both via Logs - keep the same ordering as shown in logs. + cmpResult = (pDialInfo2->GetCallLogDbId() - pDialInfo1->GetCallLogDbId()); + return r; + } + + //If control comes here, it means both Objects are fetched from Contacts. + //Here, priority is first Names than Numbers + if((isNumericKey1 == false) && (isNumericKey2 == true)) + { + cmpResult = -1;//objRef1 via name and objRef2 via number + return r; + } + else if((isNumericKey2 == false) && (isNumericKey1 == true)) + { + cmpResult = 1;//objRef2 via name and objRef1 via number + return r; + } + else if((isNumericKey1 == false) && (isNumericKey2 == false)) + { + //Both searched via name - sort by alphabetic ordering of search key. + cmpResult = searchKey1->CompareTo(*searchKey2); + return r; + } + else + { + //Both searched via number - keep current ordering as fetched from contacts. + cmpResult = pDialInfo1->GetPhoneNumber().CompareTo(pDialInfo2->GetPhoneNumber()); + return r; + } + + return E_SUCCESS; +} diff --git a/src/PhnSceneRegister.cpp b/src/PhnSceneRegister.cpp new file mode 100644 index 0000000..0b1d6e2 --- /dev/null +++ b/src/PhnSceneRegister.cpp @@ -0,0 +1,93 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSceneRegister.cpp + * @brief Scene register file + */ +#include +#include "PhnSceneRegister.h" +#include "PhnPhoneFormFactory.h" +#include "PhnPanelFactory.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + + +SceneRegister::SceneRegister(void) +{ +} + +SceneRegister::~SceneRegister(void) +{ +} + +result +SceneRegister::RegisterAllScenes(void) +{ + result r = E_SUCCESS; + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + //Register factory methods for form & panel creation + static FormFactory formFactory; + static PanelFactory panelFactory; + r |= pSceneManager->RegisterFormFactory(formFactory); + r |= pSceneManager->RegisterPanelFactory(panelFactory); + + //register all scenes + r |= pSceneManager->RegisterScene(IDSCN_DIALER, IDL_FORM_DIAL_APP, PANEL_DIALER); + r |= pSceneManager->RegisterScene(IDSCN_CALL_LOG, IDL_FORM_DIAL_APP, PANEL_LOGS); + r |= pSceneManager->RegisterScene(IDSCN_CALL_LOG_DETAILS, IDL_FORM_CALL_LOG_DETAIL, L""); + r |= pSceneManager->RegisterScene(IDSCN_EMERGENCY_DIAL, IDL_FORM_EMERGENCY_DIAL, L""); + + //Voice Call Scenes + r |= pSceneManager->RegisterScene(IDSCN_SCENE_OUTCALL, IDL_FORM_OUTCALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_OUT_EMERGENCYCALL, IDL_FORM_OUT_EMERGENCYCALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_ACTIVECALL, IDL_FORM_ACTIVECALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_ACTIVE_EMERGENCYCALL, IDL_FORM_ACTIVE_EMERGENCYCALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_MULTIPLEACTIVECALL, IDL_FORM_MULTIPLEACTIVECALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_INCOMINGCALL, IDL_FORM_INCOMINGCALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CONFCALL, IDL_FORM_CONFCALL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CONFCALLLIST, IDL_FORM_CONFCALLLIST, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_ENDCALL, IDL_FORM_ENDCALL, L""); + //Call Settings Scenes + r |= pSceneManager->RegisterScene(IDSCN_SCENE_MAIN_SETTING_MENU, IDL_FORM_MAIN_SETTING_MENU, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_REJECTLIST_MENU, IDL_FORM_CALL_REJECTLIST_MENU, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_REJECTMSGS_MENU, IDL_FORM_CALL_REJECTMSGS_MENU, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_SPEED_DIAL, IDL_FORM_SPEED_DIAL, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_MORE_OPTIONS, IDL_FORM_MORE_OPTIONS, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_STATUSTONES, IDL_FORM_CALL_STATUSTONES, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALLTYPE_FORWARD, IDL_FORM_CALLTYPE_FORWARD, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_FORWARD_OPTIONS, IDL_FORM_CALL_FORWARD_OPTIONS, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALLTYPE_BARRING, IDL_FORM_CALLTYPE_BARRING, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_BARRING_OPTIONS, IDL_FORM_CALL_BARRING_OPTIONS, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_CALL_WAITING_OPTIONS, IDL_FORM_CALL_WAITING_OPTIONS, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_ADD_REJECT_NUMBER, IDL_FORM_ADD_REJECT_NUMBER, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_AUTO_AREA_CODE, IDL_FORM_AUTO_AREA_CODE, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_ADD_REJECT_MSG, IDL_FORM_ADD_REJECT_MSG, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_EDIT_REJECT_MSG, IDL_FORM_EDIT_REJECT_MSG, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_FORWARD_TO_NUMBER, IDL_FORM_FORWARD_TO_NUMBER, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_NOREPLY_FORWARD_TO_NUMBER, IDL_FORM_NOREPLY_FORWARD_TO_NUMBER, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_SET_BARRING_PWD, IDL_FORM_SCENE_SET_BARRING_PWD, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_DEL_NUMBER, IDL_FORM_DEL_NUMBER, L""); + r |= pSceneManager->RegisterScene(IDSCN_SCENE_DEL_MESSAGE, IDL_FORM_DEL_MESSAGE, L""); + + return r; +} diff --git a/src/PhnSettingsAddNumberForm.cpp b/src/PhnSettingsAddNumberForm.cpp new file mode 100644 index 0000000..7ad2370 --- /dev/null +++ b/src/PhnSettingsAddNumberForm.cpp @@ -0,0 +1,823 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsAddNumberForm.cpp + * @brief Add Number form + */ +#include +#include "PhnAppUtility.h" +#include "PhnTypes.h" +#include "PhnSettingsAddNumberForm.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Social; + +static const wchar_t* IDL_SETTINGS_ADD_NUMBER_FORM = L"IDL_SETTINGS_ADD_NUMBER_FORM"; +static const wchar_t* IDL_SETTINGS_AUTO_AREA_CODE_FORM = L"IDL_SETTINGS_AUTO_AREA_CODE_FORM"; +static const wchar_t* IDS_ALREADY_USED_MSG = L"IDS_ALREADY_USED_MSG"; + +SettingsAddNumberForm::SettingsAddNumberForm(FormType formType) + : __formType(formType) + , __selectedCriteria(CRITERIAOPTIONS_EXACT) + , __isCriteriaOptionsMenuExpanded(false) + , __activePrefixDialingNumber(L"") + , __isContactAppControlLaunched(false) +{ +} + +SettingsAddNumberForm::~SettingsAddNumberForm(void) +{ +} + +void +SettingsAddNumberForm::Initialize(void) +{ + switch (__formType) + { + case FORMTYPE_NUMBER_TO_REJECT: + { + Construct(IDL_SETTINGS_ADD_NUMBER_FORM); + } + break; + + case FORMTYPE_AUTO_AREA_CODE: + { + Construct(IDL_SETTINGS_AUTO_AREA_CODE_FORM); + } + break; + } +} + +result +SettingsAddNumberForm::OnInitializing(void) +{ + result r = E_SUCCESS; + //Initialize Header + InitializeHeader(); + //Initialize table view + r = InitializeGroupedTableView(); + TryReturn(r == E_SUCCESS,r,"GroupedTableView initialization failed"); + //Initialize numeric edit field + InitializeNumberEditField(); + return r; +} + +void +SettingsAddNumberForm::InitializeHeader(void) +{ + Header* pHeader = GetHeader(); + if (pHeader != null) + { + //'Save' item + String saveItemName; + saveItemName.Append(AppUtility::GetResourceString(IDS_SETTING_SAVE_HEADER_ITEM)); + ButtonItem saveHeaderItem; + saveHeaderItem.Construct(BUTTON_ITEM_STYLE_TEXT, IDA_SAVE_HEADER_ITEMID); + saveHeaderItem.SetText(saveItemName); + pHeader->SetButton(BUTTON_POSITION_LEFT, saveHeaderItem); + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + + //'Cancel' item + ButtonItem cancelHeaderItem; + cancelHeaderItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_HEADER_ITEMID); + Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_BACK_HEADER_ITEM); + Bitmap* pPressBmp = AppUtility::GetBitmapFromResourcesN(IDB_BACK_HEADER_ITEM_PRESSED); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBmp); + pHeader->SetButton(BUTTON_POSITION_RIGHT, cancelHeaderItem); + delete pNormalBmp; + delete pPressBmp; + + pHeader->AddActionEventListener(*this); + } +} + +result +SettingsAddNumberForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SettingsAddNumberForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case IDA_CANCEL_HEADER_ITEMID: + { + GoBackToPreviousForm(); + } + break; + + case IDA_SAVE_HEADER_ITEMID: + { + SettingsPresentationModel* pSettingsPresentor = SettingsPresentationModel::GetInstance(); + String editFieldNumber; + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + if ((pEditFieldNumber != null) && (pEditFieldNumber->GetTextLength() != 0)) + { + editFieldNumber.Append(pEditFieldNumber->GetText()); + } + //handle save + switch (__formType) + { + case FORMTYPE_NUMBER_TO_REJECT: + { + if(editFieldNumber.IsEmpty() == false) + { + CallRejectMatchCondition matchCondition = (CallRejectMatchCondition)(__selectedCriteria + 1); + //todo: call update if in edit mode + result r = pSettingsPresentor->AddToCallRejectList(editFieldNumber, matchCondition); + if(r == E_OBJ_ALREADY_EXIST) + { + //Show error message box and go back to previous screen + String msg(L""); + msg.Append(editFieldNumber); + msg.Append(L" ("); + msg.Append(FetchTextForCriteria(__selectedCriteria)); + msg.Append(L") "); + msg.Append(AppUtility::GetResourceString(IDS_ALREADY_USED_MSG)); + ShowDuplicateErrorMessageBox(msg); + } + GoBackToPreviousForm(); + } + } + break; + + case FORMTYPE_AUTO_AREA_CODE: + { + if(editFieldNumber.IsEmpty() == false) + { + result r = pSettingsPresentor->SetPrefixDialNumber(0, editFieldNumber); + if (r == E_SUCCESS) + { + pSettingsPresentor->SetActivePrefixDialingValue(0); + pSettingsPresentor->SetPrefixDialingStatus(true); + } + } + else + { + pSettingsPresentor->SetPrefixDialingStatus(false); + } + GoBackToPreviousForm(); + } + break; + } + } + break; + + case IDA_SELECT_CONTACT: + { + LaunchContactsAppControl(); + } + break; + + default: + break; + } +} + +void +SettingsAddNumberForm::ShowDuplicateErrorMessageBox(String& message) +{ + // Creates an instance of MessageBox + MessageBox duplicateMsgBox; + duplicateMsgBox.Construct(L"", message, MSGBOX_STYLE_NONE, 2000); + + int modalResult = 0; + // Calls ShowAndWait() : Draws and Shows itself and processes events + duplicateMsgBox.ShowAndWait(modalResult); +} + +void +SettingsAddNumberForm::LaunchContactsAppControl(void) +{ + if (__isContactAppControlLaunched == true) + { + //app control already launched. + return; + } + //launch app control + __isContactAppControlLaunched = true; + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(SELECTION_MODE), new (std::nothrow) String(SELECTION_MODE_SINGLE)); + extraData.Add(new (std::nothrow) String(RETURN_TYPE), new (std::nothrow) String(RETURN_TYPE_PHONE)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_PICK); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + if(r != E_SUCCESS) + { + //app control request failed. + __isContactAppControlLaunched = false; + } + delete pAc; + } + extraData.RemoveAll(true); +} + +void +SettingsAddNumberForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + if (appId.Equals(String(PROVIDER_ID_CONTACTS)) && operationId.Equals(String(OPERATION_ID_PICK))) + { + //app control request completed. + __isContactAppControlLaunched = false; + //check if request was successful. + if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) + { + const String* rettype = static_cast(pExtraData->GetValue( String(RETURN_TYPE))); + if (rettype->Equals(String(RETURN_TYPE_PHONE),false)) + { + const String* pPickResult = static_cast(pExtraData->GetValue( String(RETURN_KEY_VALUE))); + if (pPickResult != null && pPickResult->IsEmpty() == false) + { + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + pEditFieldNumber->SetText(*pPickResult); + pEditFieldNumber->Invalidate(true); + //enable "save" button + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true); + pHeader->Invalidate(true); + } + } + } + } + } +} + +void +SettingsAddNumberForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + //clear edit field + pEditFieldNumber->Clear(); + pEditFieldNumber->SetFocus(); + } + __isContactAppControlLaunched = false; + + //disable "save" button + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + } + + switch (__formType) + { + case FORMTYPE_NUMBER_TO_REJECT: + { + __selectedCriteria = CRITERIAOPTIONS_EXACT; + //set default item as checked + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + //by default, "exact match" option is selected + pMainMenuTableView->SetItemChecked(GROUP_CRITERIA_OPTIONS, __selectedCriteria, true); + //un-check all other items + pMainMenuTableView->SetItemChecked(GROUP_CRITERIA_OPTIONS, CRITERIAOPTIONS_STARTSWITH, false); + pMainMenuTableView->SetItemChecked(GROUP_CRITERIA_OPTIONS, CRITERIAOPTIONS_ENDSWITH, false); + pMainMenuTableView->SetItemChecked(GROUP_CRITERIA_OPTIONS, CRITERIAOPTIONS_INCLUDE, false); + + pMainMenuTableView->RefreshItem(GROUP_SELECT_CRITERIA, SELECTCRITERIA_MATCH_CRITERIA, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + pMainMenuTableView->Invalidate(true); + } + } + break; + + case FORMTYPE_AUTO_AREA_CODE: + { + __activePrefixDialingNumber.Clear(); + //Fetch active prefix + SettingsPresentationModel* pSettingsPresentor = SettingsPresentationModel::GetInstance(); + if(pSettingsPresentor != null) + { + result r = pSettingsPresentor->GetActivePrefixDialNumber(__activePrefixDialingNumber); + if(r == E_SUCCESS && __activePrefixDialingNumber.IsEmpty() == false && pEditFieldNumber != null) + { + pEditFieldNumber->SetText(__activePrefixDialingNumber); + } + } + } + break; + } +} + +void +SettingsAddNumberForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + pEditFieldNumber->HideKeypad(); + } + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null && pMainMenuTableView->IsGroupExpanded(GROUP_CRITERIA_OPTIONS) == true) + { + pMainMenuTableView->CollapseGroup(GROUP_CRITERIA_OPTIONS); + __isCriteriaOptionsMenuExpanded = false; + } +} + +void +SettingsAddNumberForm::InitializeNumberEditField(void) +{ + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + pEditFieldNumber->AddKeypadEventListener(*this); + pEditFieldNumber->AddTextEventListener(*this); + pEditFieldNumber->SetOverlayKeypadCommandButtonVisible(false); + } + + Button* pContactBtn = static_cast(GetControl(IDC_SELECT_CONTACT_BUTTON)); + if (pContactBtn != null) + { + pContactBtn->SetActionId(IDA_SELECT_CONTACT); + pContactBtn->AddActionEventListener(*this); + } +} + +void +SettingsAddNumberForm::GoBackToPreviousForm(void) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (__formType) + { + case FORMTYPE_NUMBER_TO_REJECT: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTLIST_MENU), null); + } + break; + + case FORMTYPE_AUTO_AREA_CODE: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null); + } + break; + + default: + break; + } +} + +result +SettingsAddNumberForm::InitializeGroupedTableView(void) +{ + result r = E_SUCCESS; + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + pMainMenuTableView->SetGroupedLookEnabled(true); + pMainMenuTableView->SetItemProvider(this); + r = pMainMenuTableView->AddGroupedTableViewItemEventListener(*this); + pMainMenuTableView->UpdateTableView(); + CollapseSelectiveGroups(pMainMenuTableView); + } + return r; +} + +void +SettingsAddNumberForm::CollapseSelectiveGroups(GroupedTableView* pMainMenuTableView) +{ + //This function should be called only from "InitializeGroupedTableView()". + //since collapsing individual groups while GroupTableView construction causes flicker. + pMainMenuTableView->CollapseAllGroup(); + //Expand other groups + pMainMenuTableView->ExpandGroup(GROUP_SELECT_CRITERIA); + pMainMenuTableView->UpdateTableView(); +} + + +void +SettingsAddNumberForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + switch (groupIndex) + { + case GROUP_SELECT_CRITERIA: + { + ToggleGroupExpansion(tableView, groupIndex, itemIndex); + } + break; + + case GROUP_CRITERIA_OPTIONS: + { + HandleMatchingCriteriaSelected(tableView, itemIndex, status); + } + break; + + default: + break; + } +} + +int +SettingsAddNumberForm::GetGroupCount(void) +{ + return GROUP_TOTALCOUNT; +} + +int +SettingsAddNumberForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case GROUP_SELECT_CRITERIA: + { + itemCount = SELECTCRITERIA_TOTALCOUNT; + } + break; + + case GROUP_CRITERIA_OPTIONS: + { + itemCount = CRITERIAOPTIONS_TOTALCOUNT; + } + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsAddNumberForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +bool +SettingsAddNumberForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsAddNumberForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsAddNumberForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewItem* pItem = null; + + switch (groupIndex) + { + case GROUP_SELECT_CRITERIA: + { + pItem = CreateExpandableCriteriaItem(itemWidth); + } + break; + + case GROUP_CRITERIA_OPTIONS: + { + pItem = CreateCriteriaOptionsMenuItem(itemIndex, itemWidth); + } + break; + + default: + break; + } + return pItem; +} + +bool +SettingsAddNumberForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsAddNumberForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem) +{ + if(groupIndex == GROUP_SELECT_CRITERIA && itemIndex == SELECTCRITERIA_MATCH_CRITERIA) + { + String subText = FetchTextForCriteria(__selectedCriteria); + //sub text item + Label* pSubTxtLbl = static_cast(pItem->GetControl(IDC_SELECTEDOPTION_SUBTEXT_LABEL, true)); + if(pSubTxtLbl != null) + { + pSubTxtLbl->SetText(subText); + } + //set Drop-down icon to item + SetExpandIconToItem(pItem, __isCriteriaOptionsMenuExpanded); + } +} + +int +SettingsAddNumberForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsAddNumberForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} + +TableViewItem* +SettingsAddNumberForm::CreateExpandableCriteriaItem(int itemWidth) +{ + //main text + Rectangle mainItemRect(X_LIST_MENU_TEXT_ITEM, Y_LIST_MENU_TEXT_ITEM, (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), + H_LIST_DROPDOWN_TXT_ITEM); + String mainText = AppUtility::GetResourceString(IDS_SETTINGS_MATCHCRITERIA_STRING); + //sub text + Rectangle subItemRect(X_LIST_MENU_TEXT_ITEM, (Y_LIST_MENU_TEXT_ITEM + H_LIST_DROPDOWN_TXT_ITEM), + (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), H_LIST_DROPDOWN_TXT_ITEM); + String subText = FetchTextForCriteria(__selectedCriteria); + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_DROPDOWN_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + //main text item + Label* pMainTxtLbl = new (std::nothrow) Label(); + pMainTxtLbl->Construct(mainItemRect, mainText); + pMainTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pMainTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pMainTxtLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pMainTxtLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT); + pItem->AddControl(*pMainTxtLbl); + //sub text item + Label* pSubTxtLbl = new (std::nothrow) Label(); + pSubTxtLbl->Construct(subItemRect, subText); + pSubTxtLbl->SetName(IDC_SELECTEDOPTION_SUBTEXT_LABEL); + pSubTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pSubTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pSubTxtLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pSubTxtLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pSubTxtLbl); + + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + //set Drop-down icon to item + SetExpandIconToItem(pItem, __isCriteriaOptionsMenuExpanded); + return pItem; +} + +String +SettingsAddNumberForm::FetchTextForCriteria(int itemIndex) +{ + //default text + String subText = AppUtility::GetResourceString(IDS_MATCHCRITERIA_EXACT); + switch(itemIndex) + { + case CRITERIAOPTIONS_EXACT: + subText = AppUtility::GetResourceString(IDS_MATCHCRITERIA_EXACT); + break; + + case CRITERIAOPTIONS_STARTSWITH: + subText = AppUtility::GetResourceString(IDS_MATCHCRITERIA_START); + break; + + case CRITERIAOPTIONS_ENDSWITH: + subText = AppUtility::GetResourceString(IDS_MATCHCRITERIA_END); + break; + + case CRITERIAOPTIONS_INCLUDE: + subText = AppUtility::GetResourceString(IDS_MATCHCRITERIA_INCLUDE); + break; + + default: + break; + } + + return subText; +} + +void +SettingsAddNumberForm::SetExpandIconToItem(TableViewItem* pItem, bool isExpanded) +{ + Bitmap* pNormalIcon = null; + Bitmap* pPressIcon = null; + + if (!isExpanded) + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + else + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + + int itemWidth = pItem->GetWidth(); + + Rectangle iconRect((itemWidth - W_EXPAND_ICON - X_LIST_MENU_TEXT_ITEM), + ((H_LIST_DROPDOWN_MENU_ITEM - H_EXPAND_ICON) / 2), W_EXPAND_ICON, H_EXPAND_ICON); + + //for drawing blue bg header rectangle on left side. + Rectangle blueHeaderRect(0,0,W_LEFT_HEADER_EXPAND_ITEMS,pItem->GetHeight()); + //normal canvas + Canvas* pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pNormalIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + Bitmap* pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + delete pBgCanvas; + delete pActualBgBmp; + + //pressed canvas + pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pPressIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + delete pBgCanvas; + delete pActualBgBmp; + + delete pNormalIcon; + pNormalIcon = null; + delete pPressIcon; + pPressIcon = null; +} + +void +SettingsAddNumberForm::ToggleGroupExpansion(GroupedTableView& tableView, int groupIndex, int itemIndex) +{ + switch (itemIndex) + { + case SELECTCRITERIA_MATCH_CRITERIA: + { + if (tableView.IsGroupExpanded(GROUP_CRITERIA_OPTIONS) == true) + { + tableView.CollapseGroup(GROUP_CRITERIA_OPTIONS); + __isCriteriaOptionsMenuExpanded = false; + } + else + { + tableView.ExpandGroup(GROUP_CRITERIA_OPTIONS); + __isCriteriaOptionsMenuExpanded = true; + } + //Change icon + tableView.RefreshItem(GROUP_SELECT_CRITERIA, SELECTCRITERIA_MATCH_CRITERIA, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + break; + + default: + break; + } + + //close overlay keypad + EditField* pEditFieldNumber = static_cast(GetControl(IDC_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null && pEditFieldNumber->HasFocus() == true) + { + pEditFieldNumber->HideKeypad(); + } +} + +TableViewItem* +SettingsAddNumberForm::CreateCriteriaOptionsMenuItem(int itemIndex, int itemWidth) +{ + //create a new item + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_RADIO); + pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //text item rectangle + Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + //Option item name + String itemName(L""); + itemName.Append(FetchTextForCriteria(itemIndex)); + + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + + return pItem; +} + +void +SettingsAddNumberForm::HandleMatchingCriteriaSelected(GroupedTableView& tableView, int itemIndex, TableViewItemStatus status) +{ + //check if already checked item is selected + if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + tableView.SetItemChecked(GROUP_CRITERIA_OPTIONS, itemIndex, true); + __selectedCriteria = (GroupCriteriaOptionsItems) itemIndex; + return; + } + //un-check previous selected options + if(__selectedCriteria != (GroupCriteriaOptionsItems(itemIndex))) + { + tableView.SetItemChecked(GROUP_CRITERIA_OPTIONS, __selectedCriteria, false); + tableView.RefreshItem(GROUP_CRITERIA_OPTIONS, __selectedCriteria, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + //update selected criteria to latest checked itemIndex + __selectedCriteria = (GroupCriteriaOptionsItems) itemIndex; + //change sub text for criteria options menu + tableView.RefreshItem(GROUP_SELECT_CRITERIA, SELECTCRITERIA_MATCH_CRITERIA, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + tableView.Invalidate(true); +} + +void +SettingsAddNumberForm::OnKeypadWillOpen(Tizen::Ui::Control& source) +{ + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null && __isCriteriaOptionsMenuExpanded == true) + { + pMainMenuTableView->CollapseGroup(GROUP_CRITERIA_OPTIONS); + __isCriteriaOptionsMenuExpanded = false; + //Change icon + pMainMenuTableView->RefreshItem(GROUP_SELECT_CRITERIA, SELECTCRITERIA_MATCH_CRITERIA, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } +} + +void +SettingsAddNumberForm::OnTextValueChanged(const Control& source) +{ + //enable or disable save button + const EditField* pEditFieldNumber = static_cast(&source); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + bool activateSave = false; + switch (__formType) + { + case FORMTYPE_AUTO_AREA_CODE: + { + if (__activePrefixDialingNumber.Equals(pEditFieldNumber->GetText()) == false) + { + activateSave = true; + } + } + break; + + case FORMTYPE_NUMBER_TO_REJECT: + { + if(pEditFieldNumber->GetText().IsEmpty() == false) + { + activateSave = true; + } + } + break; + } + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, activateSave); + pHeader->Invalidate(true); + } +} + +void +SettingsAddNumberForm::OnTextValueChangeCanceled(const Control& source) +{ + //text change canceled, disable save button + const EditField* pEditFieldNumber = static_cast(&source); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + pHeader->Invalidate(true); + } +} diff --git a/src/PhnSettingsBarringPwdForm.cpp b/src/PhnSettingsBarringPwdForm.cpp new file mode 100644 index 0000000..de1c251 --- /dev/null +++ b/src/PhnSettingsBarringPwdForm.cpp @@ -0,0 +1,300 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsBarringPwdForm.cpp + * @brief Call Baring Password form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsBarringPwdForm.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +static const wchar_t* IDL_SETTINGS_SET_BARRING_PWD__FORM = L"IDL_SETTINGS_SET_BARRING_PWD__FORM"; + +SettingsBarringPwdForm::SettingsBarringPwdForm(void) + : __pErrorMsgPopup(null) +{ +} + +SettingsBarringPwdForm::~SettingsBarringPwdForm(void) +{ +} + +void +SettingsBarringPwdForm::Initialize(void) +{ + Construct(IDL_SETTINGS_SET_BARRING_PWD__FORM); +} + +result +SettingsBarringPwdForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + //Initialize Header + InitializeHeader(); + //Initialize reject message editArea + EditField* pSetPwd = static_cast(GetControl(IDC_EDITFIELD)); + if (pSetPwd != null) + { + pSetPwd->AddTextEventListener(*this); + pSetPwd->SetFocus(); + pSetPwd->SetOverlayKeypadCommandButtonVisible(false); + pSetPwd->ShowKeypad(); + } + return r; +} + +void +SettingsBarringPwdForm::InitializeHeader(void) +{ + Header* pHeader = GetHeader(); + if (pHeader != null) + { + //TODO: get correct icons. + //'Save' item + String saveItemName; + saveItemName.Append(AppUtility::GetResourceString(IDS_SETTING_SAVE_HEADER_ITEM)); + ButtonItem saveHeaderItem; + saveHeaderItem.Construct(BUTTON_ITEM_STYLE_TEXT, IDA_SAVE_HEADER_ITEMID); + saveHeaderItem.SetText(saveItemName); + pHeader->SetButton(BUTTON_POSITION_LEFT, saveHeaderItem); + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + + //'Cancel' item + Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_CANCEL_FOOTER_ITEM, W_HDR_FTR_ICON, H_HDR_FTR_ICON); + ButtonItem cancelHeaderItem; + cancelHeaderItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_HEADER_ITEMID); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pNormalBmp); + pHeader->SetButton(BUTTON_POSITION_RIGHT, cancelHeaderItem); + delete pNormalBmp; + + pHeader->AddActionEventListener(*this); + } +} + +result +SettingsBarringPwdForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SettingsBarringPwdForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_CANCEL_HEADER_ITEMID: + { + } + break; + + case IDA_SAVE_HEADER_ITEMID: + { + //save call barring settings + EditField* pSetPwd = static_cast(GetControl(IDC_EDITFIELD)); + if (pSetPwd != null) + { + SettingsPresentationModel* pPresentor = SettingsPresentationModel::GetInstance(); + String password = pSetPwd->GetText(); + //set call barring status + int errorCode = pPresentor->SetCallBarringStatus(password, __callBarringCondition, __conditionState); + if(errorCode != ERROR_NONE) + { + ShowErrorMessage(errorCode); + return; + } + else + { + if(__conditionState == false) + { + if(__callBarringCondition == CALL_BARRING_ALL_OUTGOING) + { + pPresentor->SetCallBarringStatus(password, CALL_BARRING_INTERNATIONAL_OUTGOING, false); + pPresentor->SetCallBarringStatus(password, CALL_BARRING_INTERNATIONAL_EXCEPT_HOME, false); + } + if(__callBarringCondition == CALL_BARRING_ALL_INCOMING) + { + pPresentor->SetCallBarringStatus(password, CALL_BARRING_INCOMING_ROAMING, false); + + } + } + } + + } + } + break; + + default: + break; + } + //switch back to previous form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_BARRING_OPTIONS), null); +} + +void +SettingsBarringPwdForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + if (pArgs != null) + { + Integer* pIndexInt = static_cast(pArgs->GetAt(0)); + switch (pIndexInt->ToInt()) + { + case 0: + { + __callBarringCondition = CALL_BARRING_ALL_OUTGOING; + } + break; + + case 1: + { + __callBarringCondition = CALL_BARRING_INTERNATIONAL_OUTGOING; + } + break; + + case 2: + { + __callBarringCondition = CALL_BARRING_INTERNATIONAL_EXCEPT_HOME; + } + break; + + case 3: + { + __callBarringCondition = CALL_BARRING_ALL_INCOMING; + } + break; + + case 4: + { + __callBarringCondition = CALL_BARRING_INCOMING_ROAMING; + } + break; + + default: + break; + } + + Integer* pItemState = static_cast(pArgs->GetAt(1)); + if (pItemState->ToInt() == LIST_ITEM_STATUS_CHECKED) + { + __conditionState = true; + } + else + { + __conditionState = false; + } + + //Clear edit field and disable "save" + EditField* pSetPwd = static_cast(GetControl(IDC_EDITFIELD)); + if (pSetPwd != null) + { + pSetPwd->Clear(); + pSetPwd->SetFocus(); + pSetPwd->Invalidate(true); + } + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + pHeader->Invalidate(true); + } + + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +SettingsBarringPwdForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + EditField* pSetPwd = static_cast(GetControl(IDC_EDITFIELD)); + if (pSetPwd != null) + { + pSetPwd->HideKeypad(); + } +} + +void +SettingsBarringPwdForm::OnTextValueChanged(const Control& source) +{ + int textLen = -1; + EditField* pSetPwd = static_cast(GetControl(IDC_EDITFIELD)); + Header* pHeader = GetHeader(); + if (pSetPwd != null && pHeader != null) + { + textLen = pSetPwd->GetTextLength(); + if (textLen > 0) + { + //Enable save button + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true); + } + else + { + //disable + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + } + pHeader->Invalidate(true); + } +} + +void +SettingsBarringPwdForm::OnTextValueChangeCanceled(const Control& source) +{ + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false); + pHeader->Invalidate(true); + } +} + +void +SettingsBarringPwdForm::ShowErrorMessage(int errorCode) +{ + //show error msg Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode); +} + +void +SettingsBarringPwdForm::HandlePopupClosed(void) +{ + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + return; +} diff --git a/src/PhnSettingsCallForwardWaitBarrForm.cpp b/src/PhnSettingsCallForwardWaitBarrForm.cpp new file mode 100644 index 0000000..13ea11f --- /dev/null +++ b/src/PhnSettingsCallForwardWaitBarrForm.cpp @@ -0,0 +1,1127 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsCallForwardWaitBarrForm.cpp + * @brief Call forwarding form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsCallForwardWaitBarrForm.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int IDI_GROUP_TOTALCOUNT = 1; +static const wchar_t* IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM = L"IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM"; +static const wchar_t* IDC_SLIDER_CHECHBUTTON = L"IDC_SLIDER_CHECHBUTTON"; + +SettingsCallForwardWaitBarrForm::SettingsCallForwardWaitBarrForm(FormType formType) + : __formType(formType) + , __pSettingsPresentor(null) + , __pErrorMsgPopup(null) + , __isCallForwardAlwaysActivated(false) + , __pAnimationFrameList(null) + , __isCallWaitingStatusAvailable(false) + , __isCallWaitingEnabled(false) +{ +} + +SettingsCallForwardWaitBarrForm::~SettingsCallForwardWaitBarrForm(void) +{ +} + +void +SettingsCallForwardWaitBarrForm::Initialize(void) +{ + Construct(IDL_SETTINGS_CALL_FORWARD_WAIT_BARRING_FORM); +} + +result +SettingsCallForwardWaitBarrForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + //set Title + Header* pHeader = GetHeader(); + if (pHeader != null) + { + String title(L""); + switch (__formType) + { + case FORMTYPE_CALLFORWARDING_TYPE: + { + title.Append(AppUtility::GetResourceString(IDS_SETTING_FORWARD_CALLTYPE_TITLE)); + } + break; + + case FORMTYPE_CALLBARRING_TYPE: + { + title.Append(AppUtility::GetResourceString(IDS_SETTING_BARRING_CALLTYPE_TITLE)); + } + break; + + case FORMTYPE_VOICE_CALLFORWARDING: + { + title.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEFORWARD_OPTIONS_TITLE)); + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + title.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_OPTIONS_TITLE)); + } + break; + + case FORMTYPE_CALL_WAITING: + { + title.Append(AppUtility::GetResourceString(IDS_SETTING_WAITING_OPTIONS_TITLE)); + } + break; + + default: + break; + } + pHeader->SetTitleText(title); + } + + // Setup back event listener + SetFormBackEventListener(this); + //Footer + Footer* pFooter = GetFooter(); + if (pFooter) + { + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + } + + ConstructAnimationList(); + //initialize table view + r = InitializeGroupedTableView(); + + return r; +} + +result +SettingsCallForwardWaitBarrForm::OnTerminating(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = null; + + if(__pAnimationFrameList != null) + { + __pAnimationFrameList->RemoveAll(); + delete __pAnimationFrameList; + __pAnimationFrameList = null; + } + return r; +} + +void +SettingsCallForwardWaitBarrForm::ConstructAnimationList(void) +{ + //Check if already created + if(__pAnimationFrameList != null) + { + return; + } + // Create AnimationList + __pAnimationFrameList = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pAnimationFrameList->Construct(); + + // Create Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + if (pAppResource != null) + { + for (int iconIndex = 1; iconIndex <= 30; iconIndex++) + { + //construct bitmap path + String bitmapPath(IDB_PROCESSING_ICONS); + String number(L""); + if(iconIndex < 10) + { + bitmapPath.Append(0); + } + bitmapPath.Append(iconIndex); + bitmapPath.Append(L".png"); + //Create Animation icons - fetch bitmap + Bitmap *pBitmap = pAppResource->GetBitmapN(bitmapPath); + if(pBitmap != null) + { + // Create AnimationFrames + AnimationFrame *pAnimFrame = new (std::nothrow) AnimationFrame( *pBitmap, + (IDI_ANIM_DURATION / IDI_ANIM_PROGRESS_COUNT)); + __pAnimationFrameList->Add(pAnimFrame); + delete pBitmap; + pBitmap = null; + } + } + } +} + +void +SettingsCallForwardWaitBarrForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + default: + break; + } +} + +void +SettingsCallForwardWaitBarrForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (__formType) + { + case FORMTYPE_CALLFORWARDING_TYPE: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MAIN_SETTING_MENU), null); + } + break; + + case FORMTYPE_CALLBARRING_TYPE: + case FORMTYPE_CALL_WAITING: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null); + } + break; + + case FORMTYPE_VOICE_CALLFORWARDING: + { + //switch to form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALLTYPE_FORWARD), null); + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + //switch to form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALLTYPE_BARRING), null); + } + break; + + default: + break; + } +} + +void +SettingsCallForwardWaitBarrForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + // Add your scene activate code here + __pSettingsPresentor->AddSettingEventListener(this); + int errorCode = ERROR_NONE; + switch (__formType) + { + case FORMTYPE_VOICE_CALLFORWARDING: + { + //fetch status + __isCallForwardAlwaysActivated = false; + errorCode = __pSettingsPresentor->GetCallForwardStatus(CALL_FORWARD_ALL); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallForwardStatus(CALL_FORWARD_BUSY); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallForwardStatus(CALL_FORWARD_NO_REPLY); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallForwardStatus(CALL_FORWARD_NOT_REACHABLE); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + //fetch status + errorCode = __pSettingsPresentor->GetCallBarringStatus(CALL_BARRING_ALL_OUTGOING); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallBarringStatus(CALL_BARRING_INTERNATIONAL_OUTGOING); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallBarringStatus(CALL_BARRING_INTERNATIONAL_EXCEPT_HOME); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallBarringStatus(CALL_BARRING_ALL_INCOMING); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + errorCode = __pSettingsPresentor->GetCallBarringStatus(CALL_BARRING_INCOMING_ROAMING); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + } + break; + + case FORMTYPE_CALL_WAITING: + { + //fetch status + errorCode = __pSettingsPresentor->GetCallWaitingStatus(); + TryCatch(errorCode == ERROR_NONE,,"TAPI error occurred"); + } + break; + + default: + break; + } + + return; + +CATCH: + //Show error message popup + ShowErrorMessage(errorCode); + //in case of TAPI error, un-check all items + UncheckAllOptions(); + return; +} + +void +SettingsCallForwardWaitBarrForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + // Add your scene de-activate code here + __pSettingsPresentor->RemoveSettingEventListener(); +} + +///////////////////////////////////////////////////////////////////// +////////////////// List View related functionality ////////////////// +///////////////////////////////////////////////////////////////////// +result +SettingsCallForwardWaitBarrForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + pMainMenuTableView->SetGroupedLookEnabled(true); + pMainMenuTableView->SetItemProvider(this); + r = pMainMenuTableView->AddGroupedTableViewItemEventListener(*this); + if( r == E_SUCCESS) + { + pMainMenuTableView->UpdateTableView(); + //play processing animation + if(__formType == FORMTYPE_CALL_WAITING) + { + pMainMenuTableView->RefreshItem(0, CALLWAITING_ITEM, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + } + } + return r; +} + +void +SettingsCallForwardWaitBarrForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + switch (__formType) + { + case FORMTYPE_CALLFORWARDING_TYPE: //decide voice/video type for forwarding / barring + case FORMTYPE_CALLBARRING_TYPE: + { + HandleCallTypeSelected(itemIndex); + } + break; + + case FORMTYPE_VOICE_CALLFORWARDING: + { + HandleCallForwardingOptionSelected(itemIndex, status); + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + HandleCallBarringOptionSelected(itemIndex, status); + } + break; + + case FORMTYPE_CALL_WAITING: + { + HandleCallWaitingOptionSelected(pItem, itemIndex, status); + } + break; + + default: + break; + } +} + +int +SettingsCallForwardWaitBarrForm::GetGroupCount(void) +{ + return IDI_GROUP_TOTALCOUNT; +} + +int +SettingsCallForwardWaitBarrForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (__formType) + { + case FORMTYPE_CALLFORWARDING_TYPE: //decide voice/video type for forwarding + case FORMTYPE_CALLBARRING_TYPE: //decide voice/video type for barring + { + itemCount = CALLTYPE_TOTALCOUNT; + } + break; + + case FORMTYPE_VOICE_CALLFORWARDING: //actual options for call forwarding + { + itemCount = CALLFORWARD_TOTALITEMCOUNT; + } + break; + + case FORMTYPE_VOICE_CALLBARRING: //actual options for call barring + { + itemCount = CALLBARRING_TOTALCOUNT; + } + break; + + case FORMTYPE_CALL_WAITING: + { + itemCount = CALLWAITING_TOTALCOUNT; + } + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsCallForwardWaitBarrForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG); + return pItem; +} + +bool +SettingsCallForwardWaitBarrForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsCallForwardWaitBarrForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsCallForwardWaitBarrForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewItem* pItem = null; + switch (__formType) + { + case FORMTYPE_CALLFORWARDING_TYPE: + case FORMTYPE_CALLBARRING_TYPE: + { + pItem = CreateSettingCallTypeMenuItem(itemIndex, itemWidth); + } + break; + + case FORMTYPE_VOICE_CALLFORWARDING: + { + pItem = CreateCallForwardingOptions(itemIndex, itemWidth); + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + pItem = CreateCallBarringOptions(itemIndex, itemWidth); + } + break; + + case FORMTYPE_CALL_WAITING: + { + pItem = CreateCallWaitingOptions(itemIndex, itemWidth); + } + break; + + default: + break; + } + + return pItem; +} + +bool +SettingsCallForwardWaitBarrForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsCallForwardWaitBarrForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + if(__formType == FORMTYPE_CALL_WAITING) + { + Animation* pAnimation = static_cast(pItem->GetControl(IDC_ANIMATION_CONTROL, true)); + if(__isCallWaitingStatusAvailable == false) + { + //let the animation play + if(pAnimation != null) + { + pAnimation->Play(); + } + } + else + { + //remove animation + if(pAnimation != null) + { + pAnimation->Stop(); + pItem->RemoveControl(*pAnimation); + } + //show CheckButton with on-off slider style + CheckButton* pSliderButton = static_cast(pItem->GetControl(IDC_SLIDER_CHECHBUTTON,true)); + if(pSliderButton == null) + { + //construct new "CheckButton", if not present + int itemWidth = pItem->GetWidth(); + Rectangle animRect((itemWidth - W_SLIDER_ICON), ((H_LIST_NORMAL_MENU_ITEM - H_SLIDER_ICON) /2), W_SLIDER_ICON, H_SLIDER_ICON); + pSliderButton = new (std::nothrow) CheckButton(); + pSliderButton->Construct(animRect, CHECK_BUTTON_STYLE_ONOFF_SLIDING, BACKGROUND_STYLE_NONE); + pSliderButton->SetName(IDC_SLIDER_CHECHBUTTON); + pSliderButton->SetActionId(IDA_CALL_WAITING_OPTION_CHECKED, IDA_CALL_WAITING_OPTION_UNCHECKED); + pSliderButton->AddActionEventListener(*this); + // Add a CheckButton to the Form + pItem->AddControl(*pSliderButton); + pItem->SetIndividualSelectionEnabled(pSliderButton, false); + } + //update status + pSliderButton->SetSelected(__isCallWaitingEnabled); + } + } + return; +} + +int +SettingsCallForwardWaitBarrForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsCallForwardWaitBarrForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} + +TableViewItem* +SettingsCallForwardWaitBarrForm::CreateSettingCallTypeMenuItem(int itemIndex, int itemWidth) +{ + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + String itemName(L""); + switch (itemIndex) + { + case CALLTYPE_VOICE_CALL: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CALLTYPE_VOICE_STRING)); + } + break; + + default: + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + //Item Name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + return pItem; +} + +void +SettingsCallForwardWaitBarrForm::HandleCallTypeSelected(int itemIndex) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (itemIndex) + { + case CALLTYPE_VOICE_CALL: + { + if (__formType == FORMTYPE_CALLFORWARDING_TYPE) + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_FORWARD_OPTIONS), null); + } + else + { + //for FORMTYPE_CALLBARRING_TYPE + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_BARRING_OPTIONS), null); + } + } + break; + + default: + break; + } +} + +TableViewItem* +SettingsCallForwardWaitBarrForm::CreateCallForwardingOptions(int itemIndex, int itemWidth) +{ + //sub text rectangle + Rectangle subItemRect(X_LIST_MENU_TEXT_ITEM, H_LIST_NORMAL_TXT_ITEM, + (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_SUB_TXT_ITEM); + String subText = AppUtility::GetResourceString(IDS_SETTING_DEACTIVATE_STATUS); + + //main text rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, + (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_TXT_ITEM); + String itemName; + switch (itemIndex) + { + case CALLFORWARD_ALWAYS: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEFORWARD_ALWAYS)); + } + break; + + case CALLFORWARD_IF_BUSY: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEFORWARD_IFBUSY)); + } + break; + + case CALLFORWARD_IF_NO_REPLY: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEFORWARD_NOREPLY)); + } + break; + + case CALLFORWARD_IF_OUT_OF_REACH: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEFORWARD_OUTOFREACH)); + } + break; + + default: + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING); + + //main text item + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_MAIN_TXT); + pItem->AddControl(*pItemLbl); + //sub text item + Label* pSubTxtLbl = new (std::nothrow) Label(); + pSubTxtLbl->Construct(subItemRect, subText); + pSubTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pSubTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pSubTxtLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pSubTxtLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pSubTxtLbl); + + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +void +SettingsCallForwardWaitBarrForm::HandleCallForwardingOptionSelected(int itemIndex, TableViewItemStatus status) +{ + if(status == TABLE_VIEW_ITEM_STATUS_CHECKED || status == TABLE_VIEW_ITEM_STATUS_SELECTED) + { + //Do not activate any other call forwarding option, if 'CALLFORWARD_ALWAYS' is selected. + if((itemIndex != CALLFORWARD_ALWAYS) && (__isCallForwardAlwaysActivated == true)) + { + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + pMainMenuTableView->SetItemChecked(CALLFORWARDING_GROUP, itemIndex, false); + pMainMenuTableView->Invalidate(true); + return; + } + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(1); + Integer* indexInt = new (std::nothrow) Integer(itemIndex); + pArgs->Add(indexInt); + + switch (itemIndex) + { + case CALLFORWARD_IF_NO_REPLY: + { + //switch to "NOREPLY_ForwardToNumber" form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_NOREPLY_FORWARD_TO_NUMBER), pArgs); + } + break; + + default: + { + //switch to "ForwardToNumber" form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_FORWARD_TO_NUMBER), pArgs); + } + break; + } + } + else + { + __pSettingsPresentor->SetCallForwardStatus(String(L""),CallForwardCondition(itemIndex), false, 0); + } +} + +TableViewItem* +SettingsCallForwardWaitBarrForm::CreateCallBarringOptions(int itemIndex, int itemWidth) +{ + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + + String itemName(L""); + switch (itemIndex) + { + case CALLBARRING_ALL_OUTGOING_CALL: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_OUTGOING)); + } + break; + + case CALLBARRING_INTERNATIONAL_CALL: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_INTERNATIONAL)); + } + break; + + case CALLBARRING_INTERNATIONAL_EXCEPT_HOME: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_EXCEPTHOME)); + } + break; + + case CALLBARRING_ALL_INCOMING_CALL: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_INCOMING)); + } + break; + + case CALLBARRING_INCOMING_WHILE_ROAMING: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_VOICEBARRING_WHENROAMING)); + } + break; + + default: + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING); + //Item Name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_MAIN_TXT); + pItem->AddControl(*pItemLbl); + + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +void +SettingsCallForwardWaitBarrForm::HandleCallBarringOptionSelected(int itemIndex, TableViewItemStatus status) +{ + //Don't change the item status and goto next form. + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(status == TABLE_VIEW_ITEM_STATUS_CHECKED) + { + pMainMenuTableView->SetItemChecked(0,itemIndex,false); + } + else if(status == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + pMainMenuTableView->SetItemChecked(0,itemIndex,true); + } + + //Whether status is checked or unchecked, always goto BarringPwdForm form + //to take password from user. Activation / De-activation of barring happens from BarringPwdForm. + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(2); + Integer* indexInt = new (std::nothrow) Integer(itemIndex); + pArgs->Add(indexInt); + Integer* itemState = new (std::nothrow) Integer(status); + pArgs->Add(itemState); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SET_BARRING_PWD), pArgs); +} + +TableViewItem* +SettingsCallForwardWaitBarrForm::CreateCallWaitingOptions(int itemIndex, int itemWidth) +{ + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, + (itemWidth - X_LIST_MENU_TEXT_ITEM - X_LIST_MENU_TEXT_ITEM - W_EXPAND_ICON), H_LIST_NORMAL_MENU_ITEM); + String itemName(L""); + switch (itemIndex) + { + case CALLWAITING_ITEM: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CALL_WAITING_OPTIONS)); + } + break; + + default: + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + + //Item Name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_MAIN_TXT); + pItem->AddControl(*pItemLbl); + + //animation icon + if(__pAnimationFrameList != null && __pAnimationFrameList->GetCount() > 0) + { + Rectangle animRect((itemNameRect.x + itemNameRect.width), ((H_LIST_NORMAL_MENU_ITEM - H_EXPAND_ICON) /2), W_EXPAND_ICON, H_EXPAND_ICON); + Animation* pAnimation = new (std::nothrow) Animation(); + pAnimation->Construct(animRect, *__pAnimationFrameList); + pAnimation->SetName(IDC_ANIMATION_CONTROL); + pAnimation->SetRepeatCount(IDI_ANIM_DURATION * IDI_ANIM_PROGRESS_COUNT * IDI_ANIM_PROGRESS_COUNT); + pItem->AddControl(*pAnimation); + } + + //set background + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +void +SettingsCallForwardWaitBarrForm::HandleCallWaitingOptionSelected(TableViewItem* pItem, int itemIndex, TableViewItemStatus status) +{ + switch (itemIndex) + { + case CALLWAITING_ITEM: + { + //set the state based on response + CheckButton* pSliderButton = static_cast(pItem->GetControl(IDC_SLIDER_CHECHBUTTON,true)); + if(pSliderButton != null) + { + bool activateWaiting = !(pSliderButton->IsSelected()); + int errorCode = __pSettingsPresentor->SetCallWaitingStatus(activateWaiting); + if(errorCode != ERROR_NONE) + { + ShowErrorMessage(errorCode); + } + } + } + break; + + default: + break; + } +} + +// +void +SettingsCallForwardWaitBarrForm::HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated) +{ + if (__formType == FORMTYPE_CALL_WAITING) + { + __isCallWaitingStatusAvailable = true; + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + //Hide animation and add on/Off checkbox by modifying item + __isCallWaitingEnabled = callWaitingActivated; + pMainMenuTableView->RefreshItem(0, CALLWAITING_ITEM, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } +} + +void +SettingsCallForwardWaitBarrForm::HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled) +{ + if (__formType == FORMTYPE_CALL_WAITING) + { + __isCallWaitingStatusAvailable = true; + //Update status of "On/Off" slider button + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + __isCallWaitingEnabled = isCallWaitingEnabled; + pMainMenuTableView->RefreshItem(0, CALLWAITING_ITEM, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } +} + +void +SettingsCallForwardWaitBarrForm::HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime) +{ + if (__formType == FORMTYPE_VOICE_CALLFORWARDING) + { + //todo: grey out the item if call is unsuccessful + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + + //todo: set subtext for the item + switch (callFwdCondition) + { + case CALL_FORWARD_ALL: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_ALWAYS, callForwardActivated); + __isCallForwardAlwaysActivated = callForwardActivated; + } + break; + + case CALL_FORWARD_BUSY: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_BUSY, callForwardActivated); + } + break; + + case CALL_FORWARD_NO_REPLY: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_NO_REPLY, callForwardActivated); + } + break; + + case CALL_FORWARD_NOT_REACHABLE: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_OUT_OF_REACH, callForwardActivated); + } + break; + + default: + break; + } + pMainMenuTableView->Invalidate(true); + } +} + +void +SettingsCallForwardWaitBarrForm::HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime) +{ + if (__formType == FORMTYPE_VOICE_CALLFORWARDING) + { + //todo: grey out the item if call is unsuccessful + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + //todo: set the number as the subtext for the item + switch (callFwdCondition) + { + case CALL_FORWARD_ALL: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_ALWAYS, isCallForwardActivated); + __isCallForwardAlwaysActivated = isCallForwardActivated; + } + break; + + case CALL_FORWARD_BUSY: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_BUSY, isCallForwardActivated); + } + break; + + case CALL_FORWARD_NO_REPLY: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_NO_REPLY, isCallForwardActivated); + } + break; + + case CALL_FORWARD_NOT_REACHABLE: + { + pMainMenuTableView->SetItemChecked(0, CALLFORWARD_IF_OUT_OF_REACH, isCallForwardActivated); + } + break; + + default: + break; + } + pMainMenuTableView->Invalidate(true); + } +} + +void +SettingsCallForwardWaitBarrForm::HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) +{ + if (__formType == FORMTYPE_VOICE_CALLBARRING) + { + //todo: grey out the item if call is unsuccessful + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + switch (callBarringType) + { + case CALL_BARRING_ALL_OUTGOING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_ALL_OUTGOING_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INTERNATIONAL_OUTGOING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INTERNATIONAL_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INTERNATIONAL_EXCEPT_HOME: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INTERNATIONAL_EXCEPT_HOME, isBarringActivated); + } + break; + + case CALL_BARRING_ALL_INCOMING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_ALL_INCOMING_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INCOMING_ROAMING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INCOMING_WHILE_ROAMING, isBarringActivated); + } + break; + + default: + break; + } + pMainMenuTableView->Invalidate(true); + } +} +void +SettingsCallForwardWaitBarrForm::HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) +{ + if (__formType == FORMTYPE_VOICE_CALLBARRING) + { + //todo: grey out the item if call is unsuccessful + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + switch (callBarringType) + { + case CALL_BARRING_ALL_OUTGOING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_ALL_OUTGOING_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INTERNATIONAL_OUTGOING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INTERNATIONAL_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INTERNATIONAL_EXCEPT_HOME: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INTERNATIONAL_EXCEPT_HOME, isBarringActivated); + } + break; + + case CALL_BARRING_ALL_INCOMING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_ALL_INCOMING_CALL, isBarringActivated); + } + break; + + case CALL_BARRING_INCOMING_ROAMING: + { + pMainMenuTableView->SetItemChecked(0, CALLBARRING_INCOMING_WHILE_ROAMING, isBarringActivated); + } + break; + + default: + break; + } + pMainMenuTableView->Invalidate(true); + } +} + +void +SettingsCallForwardWaitBarrForm::UncheckAllOptions(void) +{ + //un-check all items + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(pMainMenuTableView != null) + { + switch(__formType) + { + case FORMTYPE_VOICE_CALLFORWARDING: + { + for (int itemIndex = CALLFORWARD_ALWAYS; itemIndex < CALLFORWARD_TOTALITEMCOUNT; itemIndex++) + { + pMainMenuTableView->SetItemChecked(0, itemIndex, false); + } + } + break; + + case FORMTYPE_VOICE_CALLBARRING: + { + for (int itemIndex = CALLBARRING_ALL_OUTGOING_CALL; itemIndex < CALLBARRING_TOTALCOUNT; itemIndex++) + { + pMainMenuTableView->SetItemChecked(0, itemIndex, false); + } + } + break; + + case FORMTYPE_CALL_WAITING: + { + __isCallWaitingStatusAvailable = true; + __isCallWaitingEnabled = false; + pMainMenuTableView->RefreshItem(0, CALLWAITING_ITEM, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + break; + + default: + break; + } + pMainMenuTableView->Invalidate(true); + } +} + +void +SettingsCallForwardWaitBarrForm::ShowErrorMessage(int errorCode) +{ + //show error msg Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode); +} + +void +SettingsCallForwardWaitBarrForm::HandlePopupClosed(void) +{ + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + return; +} diff --git a/src/PhnSettingsCallStatusTonesForm.cpp b/src/PhnSettingsCallStatusTonesForm.cpp new file mode 100644 index 0000000..ed0c72e --- /dev/null +++ b/src/PhnSettingsCallStatusTonesForm.cpp @@ -0,0 +1,388 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsCallForwardWaitBarrForm.cpp + * @brief Call setting tone form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsCallStatusTonesForm.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +static const wchar_t* IDL_SETTINGS_STATUS_TONES_FORM = L"IDL_SETTINGS_STATUS_TONES_FORM"; + +SettingsCallStatusTonesForm::SettingsCallStatusTonesForm(void) +{ +} + +SettingsCallStatusTonesForm::~SettingsCallStatusTonesForm(void) +{ +} + +void +SettingsCallStatusTonesForm::Initialize(void) +{ + Construct(IDL_SETTINGS_STATUS_TONES_FORM); +} + +result +SettingsCallStatusTonesForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + + // Setup back event listener + SetFormBackEventListener(this); + //Footer + Footer* pFooter = GetFooter(); + if (pFooter) + { + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + pFooter->AddActionEventListener(*this); + } + + //initialize table view + r = InitializeGroupedTableView(); + + return r; +} + +result +SettingsCallStatusTonesForm::OnTerminating(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = null; + return r; +} + +void +SettingsCallStatusTonesForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + default: + break; + } +} + +void +SettingsCallStatusTonesForm::OnFormBackRequested(Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null); +} + +void +SettingsCallStatusTonesForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ +} + +void +SettingsCallStatusTonesForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +result +SettingsCallStatusTonesForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pStatusTonesTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pStatusTonesTableView != null) + { + pStatusTonesTableView->SetGroupedLookEnabled(true); + pStatusTonesTableView->SetItemProvider(this); + r = pStatusTonesTableView->AddGroupedTableViewItemEventListener(*this); + } + return r; +} + +void +SettingsCallStatusTonesForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + bool activateState = false; + if (status == TABLE_VIEW_ITEM_STATUS_CHECKED) + { + activateState = true; + } + switch (groupIndex) + { + case GROUP_CALL_CONNECT:// for "CALLCONNECT_CONNECT_TONE" item + { + if (status == TABLE_VIEW_ITEM_STATUS_SELECTED) + { + if (__pSettingsPresentor->GetCallConnectToneStatus() == true) + { + activateState = false; + } + else + { + activateState = true; + } + } + tableView.SetItemChecked(GROUP_CALL_CONNECT,CALLCONNECT_CONNECT_TONE,activateState); + __pSettingsPresentor->SetCallConnectToneStatus(activateState); + } + break; + + case GROUP_CALL_REMINDER:// for "CALLREMINDER_MINUTE_REMINDERS" item + { + if (status == TABLE_VIEW_ITEM_STATUS_SELECTED) + { + if (__pSettingsPresentor->GetMinuteMinderToneStatus() == true) + { + activateState = false; + } + else + { + activateState = true; + } + } + tableView.SetItemChecked(GROUP_CALL_REMINDER,CALLREMINDER_MINUTE_REMINDERS,activateState); + __pSettingsPresentor->SetMinuteMinderToneStatus(activateState); + } + break; + + case GROUP_CALL_END:// for "CALLEND_END_TONE" item + { + if (status == TABLE_VIEW_ITEM_STATUS_SELECTED) + { + if (__pSettingsPresentor->GetCallEndToneStatus() == true) + { + activateState = false; + } + else + { + activateState = true; + } + } + tableView.SetItemChecked(GROUP_CALL_END,CALLEND_END_TONE,activateState); + __pSettingsPresentor->SetCallEndToneStatus(activateState); + } + break; + + default: + break; + } +} + +int +SettingsCallStatusTonesForm::GetGroupCount(void) +{ + return GROUP_TOTALCOUNT; +} + +int +SettingsCallStatusTonesForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case GROUP_CALL_CONNECT: + { + itemCount = CALLCONNECT_TOTALCOUNT; + } + break; + + case GROUP_CALL_REMINDER: + { + itemCount = CALLREMINDER_TOTALCOUNT; + } + break; + + case GROUP_CALL_END: + { + itemCount = CALLEND_TOTALCOUNT; + } + break; + + case GROUP_CALL_CONNECT_HLPTXT: + case GROUP_CALL_REMINDER_HLPTXT: + case GROUP_CALL_END_HLPTXT: + { + itemCount = 0; + } + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsCallStatusTonesForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + String helpText(L""); + int groupHeight = H_LIST_HIDDENGROUP_ITEM; + switch (groupIndex) + { + case GROUP_CALL_CONNECT_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_CONNECTTONE_HLP_STRING)); + groupHeight = H_LIST_MENU_TWOLINE_HLPTXT_ITEM; + } + break; + + case GROUP_CALL_REMINDER_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REMINDERS_HLP_STRING)); + groupHeight = H_LIST_MENU_SINGLELINE_HLPTXT_ITEM; + } + break; + + case GROUP_CALL_END_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_ENDTONE_HLP_STRING)); + groupHeight = H_LIST_MENU_TWOLINE_HLPTXT_ITEM; + } + break; + + default: + break; + } + + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + if (helpText.IsEmpty() == true) + { + pItem->Construct(Dimension(itemWidth, groupHeight)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG); + } + else + { + //help text item rectangle + Rectangle helpItemRect(X_LIST_MENU_HLPTXT_ITEM, 0, (itemWidth - X_LIST_MENU_HLPTXT_ITEM), groupHeight); + pItem->Construct(Dimension(itemWidth, groupHeight)); + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(helpItemRect, helpText); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_HELP_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_HELP_TXT); + pItem->AddControl(*pItemLbl); + pItem->SetEnabled(false); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + } + return pItem; +} + +bool +SettingsCallStatusTonesForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsCallStatusTonesForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsCallStatusTonesForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + GroupedTableView* pStatusTonesTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + //text item rectangle + Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING); + + //Set the item name and status for all menu items + String itemName(L""); + bool activateState = false; + switch (groupIndex) + { + case GROUP_CALL_CONNECT:// for "CALLCONNECT_CONNECT_TONE" item + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CONNECTTONE_STRING)); + activateState = __pSettingsPresentor->GetCallConnectToneStatus(); + } + break; + + case GROUP_CALL_REMINDER:// for "CALLREMINDER_MINUTE_REMINDERS" item + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REMINDERS_STRING)); + activateState = __pSettingsPresentor->GetMinuteMinderToneStatus(); + } + break; + + case GROUP_CALL_END:// for "CALLEND_END_TONE" item + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_ENDTONE_STRING)); + activateState = __pSettingsPresentor->GetCallEndToneStatus(); + } + break; + + default: + break; + } + + //Item Name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //set status + pStatusTonesTableView->SetItemChecked(groupIndex, itemIndex, activateState); + return pItem; +} + +bool +SettingsCallStatusTonesForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsCallStatusTonesForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + return; +} + +int +SettingsCallStatusTonesForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsCallStatusTonesForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} diff --git a/src/PhnSettingsConstants.cpp b/src/PhnSettingsConstants.cpp new file mode 100644 index 0000000..6d8c720 --- /dev/null +++ b/src/PhnSettingsConstants.cpp @@ -0,0 +1,185 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsConstants.cpp + * @brief Call setting tone form + */ +#include "PhnSettingsConstants.h" + +using namespace Tizen::Graphics; + +// String Constants - Bitmap File +const wchar_t* IDB_CONTROLBAR_SAVE_ICON = L"C01-4_controlbar_icon_save.png"; +const wchar_t* IDB_CONTROLBAR_ICON_DELETE = L"C01-4_controlbar_icon_delete.png"; +const wchar_t* IDB_CANCEL_BTN_NORMAL = L"00_button_cancel_normal.png"; +const wchar_t* IDB_VOICECALL_ICON = L"C01-5_icon_voicecall.png"; +const wchar_t* IDB_LIST_EXPAND = L"00_list_expand_closed.png"; +const wchar_t* IDB_LIST_EXPAND_PRESSED = L"00_list_expand_closed_press.png"; +const wchar_t* IDB_LIST_OPENED = L"00_list_expand_opened.png"; +const wchar_t* IDB_LIST_OPENED_PRESSED = L"00_list_expand_opened_press.png"; +const wchar_t* IDB_BACK_HEADER_ITEM = L"00_icon_Back.png"; +const wchar_t* IDB_BACK_HEADER_ITEM_PRESSED = L"00_icon_Back_press.png"; +const wchar_t* IDB_CANCEL_FOOTER_ITEM = L"C01-5_icon_cancel.png"; +const wchar_t* IDB_PROCESSING_ICONS = L"00_list_process_"; + +//control name +const wchar_t* IDC_GROUPEDTABLEVIEW = L"IDC_GROUPEDTABLEVIEW"; +const wchar_t* IDC_LISTVIEW = L"IDC_LISTVIEW"; +const wchar_t* IDC_NUMBER_EDITFIELD = L"IDC_NUMBER_EDITFIELD"; +const wchar_t* IDC_SELECT_CONTACT_BUTTON = L"IDC_SELECT_CONTACT_BUTTON"; +const wchar_t* IDC_FOWARDING_NUMBER_EDITFIELD = L"IDC_FOWARDING_NUMBER_EDITFIELD"; +const wchar_t* IDC_VOICEMAIL_BUTTON = L"IDC_VOICEMAIL_BUTTON"; +const wchar_t* IDC_REJECTMSG_EXPANDABLEEDITAREA = L"IDC_REJECTMSG_EXPANDABLEEDITAREA"; +const wchar_t* IDC_EDITFIELD = L"IDC_EDITFIELD"; +const wchar_t* IDC_SELECTEDOPTION_SUBTEXT_LABEL = L"IDC_SELECTEDOPTION_SUBTEXT_LABEL"; +const wchar_t* IDC_ANIMATION_CONTROL = L"IDC_ANIMATION_CONTROL"; + +//resource string contants +const wchar_t* IDS_ADD_BTN_STRING = L"IDS_ADD_BTN_STRING"; +const wchar_t* IDS_DELETE_BTN_STRING = L"IDS_DELETE_BTN_STRING"; +const wchar_t* IDS_CANCEL_BTN_STRING = L"IDS_CANCEL_BTN_STRING"; +const wchar_t* IDS_REMOVE_CONTACT = L"IDS_REMOVE_CONTACT"; +const wchar_t* IDS_DELETE_NUMBER_TITLE = L"IDS_SETTINGS_DELETE_NUMBER_TITLE_STRING"; +const wchar_t* IDS_DELETE_MSGS_TITLE = L"IDS_SETTINGS_DELETE_MSGS_TITLE_STRING"; +const wchar_t* IDS_SELECT_ALL_LIST_ITEM_STRING = L"IDS_SELECT_ALL_LIST_ITEM_STRING"; +const wchar_t* IDS_DEFAULT_REJECT_ITEM_STRING = L"IDS_DEFAULT_REJECT_ITEM_STRING"; +const wchar_t* IDS_SETTINGS_MATCHCRITERIA_STRING = L"IDS_SETTINGS_MATCHCRITERIA_STRING"; +const wchar_t* IDS_CALLERID_BYNETWORK_STRING = L"IDS_CALLERID_BYNETWORK_STRING"; +const wchar_t* IDS_CALLERID_SHOW_STRING = L"IDS_CALLERID_SHOW_STRING"; +const wchar_t* IDS_CALLERID_HIDE_STRING = L"IDS_CALLERID_HIDE_STRING"; +const wchar_t* IDS_SETTING_CALLALERT_OFF_STRING = L"IDS_SETTING_CALLALERT_OFF_STRING"; +const wchar_t* IDS_SETTING_CALLALERT_SOUND_STRING = L"IDS_SETTING_CALLALERT_SOUND_STRING"; +const wchar_t* IDS_SETTING_CALLALERT_VIBRATE_STRING = L"IDS_SETTING_CALLALERT_VIBRATE_STRING"; +const wchar_t* IDS_SETTING_BARRING_STRING = L"IDS_SETTING_BARRING_STRING"; +const wchar_t* IDS_SETTING_WAITING_STRING = L"IDS_SETTING_WAITING_STRING"; +const wchar_t* IDS_SETTING_WAITING_HLP_STRING = L"IDS_SETTING_WAITING_HLP_STRING"; +const wchar_t* IDS_SETTING_STATUS_TONES_STRING = L"IDS_SETTING_STATUS_TONES_STRING"; +const wchar_t* IDS_SETTING_STATUS_TONES_HLP_STRING = L"IDS_SETTING_STATUS_TONES_HLP_STRING"; +const wchar_t* IDS_SETTING_AUTO_AREACODE_STRING = L"IDS_SETTING_AUTO_AREACODE_STRING"; +const wchar_t* IDS_SETTING_AUTO_AREACODE_HLP_STRING = L"IDS_SETTING_AUTO_AREACODE_HLP_STRING"; +const wchar_t* IDS_SETTING_REJECT_STRING = L"IDS_SETTING_REJECT_STRING"; +const wchar_t* IDS_SETTING_REJECT_HLP_STRING = L"IDS_SETTING_REJECT_HLP_STRING"; +const wchar_t* IDS_SETTING_REJECT_MSG_STRING = L"IDS_SETTING_REJECT_MSG_STRING"; +const wchar_t* IDS_SETTING_REJECT_MSG_HLP_STRING = L"IDS_SETTING_REJECT_MSG_HLP_STRING"; +const wchar_t* IDS_SETTING_SPEEDDIAL_STRING = L"IDS_SETTING_SPEEDDIAL_STRING"; +const wchar_t* IDS_SETTING_FORWARDING_STRING = L"IDS_SETTING_FORWARDING_STRING"; +const wchar_t* IDS_SETTING_MORE_MAIN_STRING = L"IDS_SETTING_MORE_MAIN_STRING"; +const wchar_t* IDS_SETTING_MORE_SUB_STRING = L"IDS_SETTING_MORE_SUB_STRING"; +const wchar_t* IDS_SETTING_WAITING_TIME_STRING = L"IDS_SETTING_WAITING_TIME_STRING"; +const wchar_t* IDS_SETTING_WAIT_INTERVAL_STRING = L"IDS_SETTING_WAIT_INTERVAL_STRING"; +const wchar_t* IDS_SETTING_CONNECTTONE_STRING = L"IDS_SETTING_CONNECTTONE_STRING"; +const wchar_t* IDS_SETTING_CONNECTTONE_HLP_STRING = L"IDS_SETTING_CONNECTTONE_HLP_STRING"; +const wchar_t* IDS_SETTING_REMINDERS_STRING = L"IDS_SETTING_REMINDERS_STRING"; +const wchar_t* IDS_SETTING_REMINDERS_HLP_STRING = L"IDS_SETTING_REMINDERS_HLP_STRING"; +const wchar_t* IDS_SETTING_ENDTONE_STRING = L"IDS_SETTING_ENDTONE_STRING"; +const wchar_t* IDS_SETTING_ENDTONE_HLP_STRING = L"IDS_SETTING_ENDTONE_HLP_STRING"; +const wchar_t* IDS_SETTING_FORWARD_CALLTYPE_TITLE = L"IDS_SETTING_FORWARD_CALLTYPE_TITLE_STRING"; +const wchar_t* IDS_SETTING_BARRING_CALLTYPE_TITLE = L"IDS_SETTING_BARRING_CALLTYPE_TITLE_STRING"; +const wchar_t* IDS_SETTING_VOICEFORWARD_OPTIONS_TITLE = L"IDS_SETTING_VOICEFORWARD_OPTIONS_TITLE_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_OPTIONS_TITLE = L"IDS_SETTING_VOICEBARRING_OPTIONS_TITLE_STRING"; +const wchar_t* IDS_SETTING_WAITING_OPTIONS_TITLE = L"IDS_SETTING_WAITING_OPTIONS_TITLE_STRING"; +const wchar_t* IDS_SETTING_CALLTYPE_VOICE_STRING = L"IDS_SETTING_CALLTYPE_VOICE_STRING"; +const wchar_t* IDS_SETTING_VOICEFORWARD_ALWAYS = L"IDS_SETTING_VOICEFORWARD_ALWAYS_STRING"; +const wchar_t* IDS_SETTING_VOICEFORWARD_IFBUSY = L"IDS_SETTING_VOICEFORWARD_IFBUSY_STRING"; +const wchar_t* IDS_SETTING_VOICEFORWARD_NOREPLY = L"IDS_SETTING_VOICEFORWARD_NOREPLY_STRING"; +const wchar_t* IDS_SETTING_VOICEFORWARD_OUTOFREACH = L"IDS_SETTING_VOICEFORWARD_OUTOFREACH_STRING"; +const wchar_t* IDS_SETTING_DEACTIVATE_STATUS = L"IDS_SETTING_DEACTIVATE_STATUS_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_OUTGOING = L"IDS_SETTING_VOICEBARRING_OUTGOING_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_INTERNATIONAL = L"IDS_SETTING_VOICEBARRING_INTERNATIONAL_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_EXCEPTHOME = L"IDS_SETTING_VOICEBARRING_EXCEPTHOME_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_INCOMING = L"IDS_SETTING_VOICEBARRING_INCOMING_STRING"; +const wchar_t* IDS_SETTING_VOICEBARRING_WHENROAMING = L"IDS_SETTING_VOICEBARRING_WHENROAMING_STRING"; +const wchar_t* IDS_SETTING_CALL_WAITING_OPTIONS = L"IDS_SETTING_CALL_WAITING_OPTIONS_STRING"; +const wchar_t* IDS_MATCHCRITERIA_EXACT = L"IDS_MATCHCRITERIA_EXACT_STRING"; +const wchar_t* IDS_MATCHCRITERIA_START = L"IDS_MATCHCRITERIA_START_STRING"; +const wchar_t* IDS_MATCHCRITERIA_END = L"IDS_MATCHCRITERIA_END_STRING"; +const wchar_t* IDS_MATCHCRITERIA_INCLUDE = L"IDS_MATCHCRITERIA_INCLUDE_STRING"; +const wchar_t* IDS_SETTING_CALLERID_MAIN_STR = L"IDS_SETTING_CALLERID_MAIN_STRING"; +const wchar_t* IDS_SETTING_CALLERID_SUB_STR = L"IDS_SETTING_CALLERID_SUB_STRING"; +const wchar_t* IDS_SETTING_CALL_ALERT_MAIN_STR = L"IDS_SETTING_CALL_ALERT_MAIN_STRING"; +const wchar_t* IDS_SETTING_CALL_ALERT_SUB_STR = L"IDS_SETTING_CALL_ALERT_SUB_STRING"; +const wchar_t* IDS_SETTING_SAVE_HEADER_ITEM = L"IDS_SETTING_SAVE_HEADER_ITEM"; +const wchar_t* IDS_SETTING_DONE_HEADER_ITEM = L"IDS_SETTING_DONE_HEADER_ITEM"; +const wchar_t* IDS_NOT_ASSIGNED_STR = L"IDS_NOT_ASSIGNED_STR"; + +// Dimensions used in List views // +// menu item height +const int H_LIST_HIDDENGROUP_ITEM = 1; +const int H_LIST_NORMAL_MENU_ITEM = 112; +const int H_LIST_DROPDOWN_MENU_ITEM = 128; +const int H_LIST_MENU_SINGLELINE_HLPTXT_ITEM = 102; +const int H_LIST_MENU_TWOLINE_HLPTXT_ITEM = 140; +//text item height +const int H_LIST_NORMAL_TXT_ITEM = 54; +const int H_LIST_SUB_TXT_ITEM = 38; +//Two line text for Drop down menu item +const int H_LIST_DROPDOWN_TXT_ITEM = 52; +//single line text +const int X_LIST_MENU_TEXT_ITEM = 26; +const int Y_LIST_MENU_TEXT_ITEM = 8; +//Help text +const int X_LIST_MENU_HLPTXT_ITEM = 26; +const int Y_LIST_MENU_HLPTXT_ITEM = 8; +//custom Item for Bg line +const int Y_CUSTOM_BG_ELEMENT = 0; +//Position for delete list item +const int X_DEL_LIST_ELEMENT = 16; +const int Y_DEL_LIST_ELEMENT = 0; + +// Dimensions for icons // +//Expand icon for DropDown Menu Items +const int W_EXPAND_ICON = 64; +const int H_EXPAND_ICON = 64; +const int W_SLIDER_ICON = 150; +const int H_SLIDER_ICON = 64; +//contact icon for Add Rejected Number view +const int W_CONTACT_ICON = 128; +const int H_CONTACT_ICON = 128; +//Dimensions for custom bg line +const int W_CUSTOM_BG_ELEMENT = 1; +//Item Width for delete list +const int W_DELETE_LIST_ITEM = 628; +const int W_LEFT_HEADER_EXPAND_ITEMS = 8; + +const int FONT_SIZE_MAIN_TXT = 44; +const int FONT_SIZE_SUB_TXT = 32; +//Help text +const int FONT_SIZE_HELP_TXT = 32; +//Header, Footer icon +const int W_HDR_FTR_ICON = 60; +const int H_HDR_FTR_ICON = 60; +//Processing Animation constants +const int IDI_ANIM_DURATION = 500; +const int IDI_ANIM_PROGRESS_COUNT = 30; + +//Settings UI contants +// Colors used in List views // +const unsigned int COLOR_GROUP_ITEM_BG = Color32<249, 249, 249>::Value; +const unsigned int COLOR_LIST_MENU_ITEM = Color32<236, 240, 242>::Value; +const unsigned int COLOR_SECONDDEPTH_ITEM_BG = Color32<215, 225, 232>::Value; +const unsigned int COLOR_HELP_ITEM_BG = Color32<255, 255, 255, 0>::Value; +const unsigned int COLOR_NORMAL_MAIN_TXT = Color32<102, 102, 102>::Value; +const unsigned int COLOR_NORMAL_SUB_TXT = Color32<124, 124, 124>::Value; +const unsigned int COLOR_PRESS_SUB_TXT = Color32<42, 137, 194>::Value; +const unsigned int COLOR_PRESS_MAIN_TXT = Color32<249, 249, 249>::Value; +const unsigned int COLOR_HELP_TXT = Color32<124, 124, 124>::Value; +const unsigned int COLOR_LEFT_HEADER_EXPAND_ITEMS = Color32<108, 168, 199>::Value; +//Main List Option text +const unsigned int COLOR_MAIN_TXT = Color32<0, 0, 0>::Value; +const unsigned int COLOR_NORMAL_ITEM_BG = Color32<249, 249, 249>::Value; +const unsigned int COLOR_PRESS_ITEM_BG = Color32<42, 137, 194>::Value; +const unsigned int COLOR_SELECTALL_ITEM_BG = Color32<215, 225, 232>::Value; diff --git a/src/PhnSettingsDeleteListForm.cpp b/src/PhnSettingsDeleteListForm.cpp new file mode 100644 index 0000000..dc15922 --- /dev/null +++ b/src/PhnSettingsDeleteListForm.cpp @@ -0,0 +1,666 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsDeleteListForm.cpp + * @brief Settings Delete list form + */ +#include +#include "PhnAppUtility.h" +#include "PhnCustomItemBgElement.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsDeleteListForm.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int IDI_SELECT_ALL_ITEM_ELEMENT_ID = 20010; +//by default, list has 1 item +const int IDI_DEFAULT_LIST_COUNT = 1; +//Element Id for main text used in List view item +const int IDI_LIST_MAIN_TXT_ITEMID = 1000; +static const wchar_t* IDL_SETTINGS_DELETE_LIST_FORM = L"IDL_SETTINGS_DELETE_LIST_FORM"; +static const wchar_t* IDC_LABEL_DELETE_SELECTED = L"IDC_LABEL_DELETE_SELECTED"; + +static const unsigned int COLOR_DELETE_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value; + +SettingsDeleteListForm::SettingsDeleteListForm(ListOfType listOfType) + : __listOfType(listOfType) + , __pNumbersList(null) + , __pMsgsMap(null) + , __pSettingsPresentor(null) + , __checkedItemCount(0) + , __pSelectedLabel(null) +{ +} + +SettingsDeleteListForm::~SettingsDeleteListForm(void) +{ +} + +void +SettingsDeleteListForm::Initialize(void) +{ + Construct(IDL_SETTINGS_DELETE_LIST_FORM); +} + +result +SettingsDeleteListForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + + String title(L""); + switch (__listOfType) + { + case LISTOF_NUMBERS: + { + title.Append(AppUtility::GetResourceString(IDS_DELETE_NUMBER_TITLE)); + } + break; + + case LISTOF_MESSAGES: + { + title.Append(AppUtility::GetResourceString(IDS_DELETE_MSGS_TITLE)); + } + break; + + default: + break; + } + + //set Title + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetTitleText(title); + } + //Initialize Footer + InitializeFooter(); + + //initialize list view + r = InitializeListView(); + return r; +} + +void +SettingsDeleteListForm::InitializeSelectLabel() +{ + __pSelectedLabel = static_cast(GetControl(IDC_LABEL_DELETE_SELECTED)); + if(__pSelectedLabel != null) + { + if(__listOfType == LISTOF_NUMBERS) + { + __pSelectedLabel->SetText(AppUtility::GetResourceString(IDS_SELECT_NUMBER)); + } + else if(__listOfType == LISTOF_MESSAGES) + { + __pSelectedLabel->SetText(AppUtility::GetResourceString(IDS_SELECT_MESSAGE)); + } + + SetControlAlwaysOnTop(*__pSelectedLabel,true); + __pSelectedLabel->SetBackgroundColor(COLOR_DELETE_LABEL_SELECTED); + __pSelectedLabel->SetShowState(true); + } +} +void +SettingsDeleteListForm::InitializeFooter(void) +{ + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT); + + String footerItemName(L""); + //Delete footer item + footerItemName.Append(AppUtility::GetResourceString(IDS_DELETE_BTN_STRING)); + FooterItem delFooterItem; + delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID); + delFooterItem.SetText(footerItemName); + pFooter->InsertItemAt(0, delFooterItem); + pFooter->SetItemEnabled(0, false); + + //Cancel button + Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_CANCEL_FOOTER_ITEM, W_HDR_FTR_ICON, H_HDR_FTR_ICON); + ButtonItem cancelButtonItem; + cancelButtonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_FOOTER_ITEMID); + cancelButtonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp); + cancelButtonItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pNormalBmp); + pFooter->SetButton(BUTTON_POSITION_RIGHT, cancelButtonItem); + delete pNormalBmp; + pNormalBmp = null; + + pFooter->AddActionEventListener(*this); + } +} + +result +SettingsDeleteListForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pNumbersList) + { + delete __pNumbersList; + __pNumbersList = null; + } + + if (__pMsgsMap) + { + delete __pMsgsMap; + __pMsgsMap = null; + } + __pSettingsPresentor = null; + return r; +} + +void +SettingsDeleteListForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_CANCEL_FOOTER_ITEMID: + { + if (__listOfType == LISTOF_NUMBERS) + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTLIST_MENU), null); + } + else + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null); + } + } + break; + case IDA_DELETE_FOOTER_ITEMID: + { + if (__listOfType == LISTOF_NUMBERS) + { + DeleteRejectNumbersList(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTLIST_MENU), null); + } + else + { + DeleteRejectMsgsList(); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null); + } + } + break; + + default: + break; + } +} + +void +SettingsDeleteListForm::DeleteRejectNumbersList(void) +{ + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + if (pDelListView != null) + { + for (int index = 1; index < pDelListView->GetItemCount(); index++) + { + if (pDelListView->IsItemChecked(index) == true) + { + CallRejectInfo rejectInfo; + __pNumbersList->GetAt(index-1, rejectInfo); + __pSettingsPresentor->RemoveCallRejectRow(rejectInfo.rowId); + } + } + } +} + +void +SettingsDeleteListForm::DeleteRejectMsgsList(void) +{ + IListT *pMsgKeyList = __pMsgsMap->GetKeysN(); + //list of deleted keys + ArrayListT *pDelKeyList = new (std::nothrow) ArrayListT(); + pDelKeyList->Construct(); + //fetch checked messages to be deleted + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + if (pDelListView != null) + { + for (int index = 1; index < pDelListView->GetItemCount(); index++) + { + if (pDelListView->IsItemChecked(index) == true) + { + int key; + if(pMsgKeyList->GetAt(index-1, key) == E_SUCCESS) + { + pDelKeyList->Add(key); + } + } + } + } + delete pMsgKeyList; + //delete messages + if(pDelKeyList->GetCount() > 0) + { + __pSettingsPresentor->RemoveRejectMessage(*pDelKeyList); + } + delete pDelKeyList; +} + +void +SettingsDeleteListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + // Add your scene activate code here + switch (__listOfType) + { + case LISTOF_NUMBERS: + { + //fetch "reject numbers" or "reject msg" list + FetchNumbersRejectList(); + } + break; + + case LISTOF_MESSAGES: + { + //fetch "reject msgs" list + FetchRejectMsgsList(); + } + break; + + default: + break; + } + + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + if (pDelListView != null) + { + pDelListView->UpdateList(); + int itemCount = pDelListView->GetItemCount(); + for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--) + { + bool isSelected = pDelListView->IsItemChecked(itemIndex); + if(isSelected == true) + { + pDelListView->SetItemChecked(itemIndex,false); + } + } + } + __checkedItemCount = 0; + Footer* pFooter = GetFooter(); + if(pFooter != null) + { + pFooter->SetItemEnabled(0, false); + pFooter->Invalidate(true); + } + //to show selected msg or numbers + InitializeSelectLabel(); +} + +void +SettingsDeleteListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +void +SettingsDeleteListForm::FetchNumbersRejectList(void) +{ + if (__pNumbersList != null) + { + delete __pNumbersList; + __pNumbersList = null; + } + __pNumbersList = static_cast*>(__pSettingsPresentor->GetCallRejectList()); +} + +void +SettingsDeleteListForm::FetchRejectMsgsList(void) +{ + if (__pMsgsMap != null) + { + delete __pMsgsMap; + __pMsgsMap = null; + } + //item to be fetched from Db + __pMsgsMap = __pSettingsPresentor->GetRejectMessageListN(); +} + +result +SettingsDeleteListForm::InitializeListView(void) +{ + result r = E_FAILURE; + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + if (pDelListView != null) + { + pDelListView->SetBackgroundColor(this->GetBackgroundColor()); + pDelListView->AddListViewItemEventListener(*this); + r = pDelListView->SetItemProvider(*this); + } + return r; +} + +void +SettingsDeleteListForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status) +{ + String text; + String selStr; + switch (index) + { + case 0://"Select All" + { + bool isSelect = (status == LIST_ITEM_STATUS_CHECKED); + SelectAllItems(isSelect); + } + break; + + default: + { + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + bool isItemUnchecked = (status == LIST_ITEM_STATUS_UNCHECKED); + if(isItemUnchecked == true) + { + __checkedItemCount--; + //un-check "Select All", if it was checked earlier and any other item is unchecked. + if(pDelListView->IsItemChecked(0) == true) + { + pDelListView->SetItemChecked(0,false); + } + } + else + { + __checkedItemCount++; + if(pDelListView->GetItemCount() == (__checkedItemCount+1)) + { + pDelListView->SetItemChecked(0,true); + } + } + if (__checkedItemCount == 0) + { + + if(__listOfType == LISTOF_NUMBERS) + { + selStr = AppUtility::GetResourceString(IDS_SELECT_NUMBER); + } + else if(__listOfType == LISTOF_MESSAGES) + { + selStr = AppUtility::GetResourceString(IDS_SELECT_MESSAGE); + } + __pSelectedLabel->SetText(selStr); + } + else + { + if(__listOfType == LISTOF_NUMBERS) + { + //selStr = AppUtility::GetResourceString(IDS_NUMBER_SELECTED); + if(__checkedItemCount > 1) + { + selStr = AppUtility::GetResourceString(IDS_NUMBERS_SELECTED); + } + else + { + selStr = AppUtility::GetResourceString(IDS_NUMBER_SELECTED); + } + } + else if(__listOfType == LISTOF_MESSAGES) + { + if(__checkedItemCount > 1) + { + selStr = AppUtility::GetResourceString(IDS_MESSAGES_SELECTED); + } + else + { + selStr = AppUtility::GetResourceString(IDS_MESSAGE_SELECTED); + } + + } + text.Format(100, selStr.GetPointer(), __checkedItemCount); + __pSelectedLabel->SetText(text); + } + pDelListView->Invalidate(true); + __pSelectedLabel->Invalidate(false); + } + break; + } + + Footer* pFooter = GetFooter(); + if(pFooter != null) + { + if(__checkedItemCount > 0) + { + pFooter->SetItemEnabled(0, true); + } + else + { + pFooter->SetItemEnabled(0, false); + } + pFooter->Invalidate(true); + } +} + +void +SettingsDeleteListForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction) +{ +} +void +SettingsDeleteListForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state) +{ +} + +void +SettingsDeleteListForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback) +{ +} + +void +SettingsDeleteListForm::SelectAllItems(bool isSelect) +{ + String text; + String selStr; + ListView* pDelListView = static_cast(GetControl(IDC_LISTVIEW)); + int itemCount = pDelListView->GetItemCount(); + for (int index = 1; index < itemCount; index++) + { + pDelListView->SetItemChecked(index,isSelect); + } + pDelListView->RequestRedraw(); + if(isSelect) + { + __checkedItemCount = pDelListView->GetItemCount()-1; + if(__listOfType == LISTOF_NUMBERS) + { + if(__checkedItemCount > 1) + { + selStr = AppUtility::GetResourceString(IDS_NUMBERS_SELECTED); + } + else + { + selStr = AppUtility::GetResourceString(IDS_NUMBER_SELECTED); + } + + } + else if(__listOfType == LISTOF_MESSAGES) + { + if(__checkedItemCount > 1) + { + selStr = AppUtility::GetResourceString(IDS_MESSAGES_SELECTED); + } + else + { + selStr = AppUtility::GetResourceString(IDS_MESSAGE_SELECTED); + } + } + text.Format(100, selStr.GetPointer(), __checkedItemCount); + __pSelectedLabel->SetText(text); + } + else + { + __checkedItemCount = 0; + if(__listOfType == LISTOF_NUMBERS) + { + selStr = AppUtility::GetResourceString(IDS_SELECT_NUMBER); + } + else if(__listOfType == LISTOF_MESSAGES) + { + selStr = AppUtility::GetResourceString(IDS_SELECT_MESSAGE); + } + __pSelectedLabel->SetText(selStr); + + } + + __pSelectedLabel->Invalidate(false); + Draw(); +} + +int +SettingsDeleteListForm::GetItemCount(void) +{ + int itemCount = IDI_DEFAULT_LIST_COUNT; + + switch (__listOfType) + { + case LISTOF_NUMBERS: + { + if (__pNumbersList != null) + { + itemCount += __pNumbersList->GetCount(); + } + } + break; + + case LISTOF_MESSAGES: + { + if (__pMsgsMap != null) + { + itemCount += __pMsgsMap->GetCount(); + } + } + break; + + default: + break; + } + return itemCount; +} + +ListItemBase* +SettingsDeleteListForm::CreateItem(int index, int itemWidth) +{ + CustomItem* pItem = null; + + if (index == 0) + { + //Default Item - "SELECT ALL" + pItem = new (std::nothrow) CustomItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), LIST_ANNEX_STYLE_MARK); + + String itemName = AppUtility::GetResourceString(IDS_SELECT_ALL_LIST_ITEM_STRING); + pItem->AddElement(Rectangle(X_DEL_LIST_ELEMENT, Y_DEL_LIST_ELEMENT, W_DELETE_LIST_ITEM, H_LIST_NORMAL_MENU_ITEM), IDI_SELECT_ALL_ITEM_ELEMENT_ID, itemName, false); + pItem->SetElementTextHorizontalAlignment(IDI_LIST_MAIN_TXT_ITEMID, ALIGNMENT_LEFT); + pItem->SetElementTextVerticalAlignment(IDI_LIST_MAIN_TXT_ITEMID, ALIGNMENT_MIDDLE); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, COLOR_SELECTALL_ITEM_BG); + } + else + { + switch (__listOfType) + { + case LISTOF_NUMBERS: + pItem = CreateListItemForNumbers(index, itemWidth); + break; + + case LISTOF_MESSAGES: + pItem = CreateListItemForMsgs(index, itemWidth); + break; + + default: + break; + + } + } + + return pItem; +} + +CustomItem* +SettingsDeleteListForm::CreateListItemForNumbers(int index, int itemWidth) +{ + CustomItem* pItem = null; + int listIndex = index - 1; + + if (__pNumbersList != null && listIndex < __pNumbersList->GetCount()) + { + //fetch number + String number; + CallRejectInfo rejectInfo; + __pNumbersList->GetAt(listIndex, rejectInfo); + number.Append(rejectInfo.phoneNumber); + //create list item + pItem = new (std::nothrow) CustomItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), LIST_ANNEX_STYLE_MARK); + + pItem->AddElement(Rectangle(X_DEL_LIST_ELEMENT, Y_DEL_LIST_ELEMENT, W_DELETE_LIST_ITEM, H_LIST_NORMAL_MENU_ITEM), listIndex, number, + FONT_SIZE_MAIN_TXT, COLOR_NORMAL_SUB_TXT, COLOR_PRESS_MAIN_TXT, COLOR_PRESS_MAIN_TXT, false); + pItem->SetElementTextHorizontalAlignment(listIndex, ALIGNMENT_LEFT); + pItem->SetElementTextVerticalAlignment(listIndex, ALIGNMENT_MIDDLE); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, COLOR_NORMAL_ITEM_BG); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, COLOR_PRESS_ITEM_BG); + } + return pItem; +} + +CustomItem* +SettingsDeleteListForm::CreateListItemForMsgs(int index, int itemWidth) +{ + CustomItem* pItem = null; + int listIndex = index - 1; + + if (__pMsgsMap != null && listIndex < __pMsgsMap->GetCount()) + { + IListT *pMsgList = __pMsgsMap->GetValuesN(); + if(pMsgList != null) + { + //fetch number + String message; + pMsgList->GetAt(listIndex, message); + + //create list item + pItem = new (std::nothrow) CustomItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), LIST_ANNEX_STYLE_MARK); + + pItem->AddElement(Rectangle(X_DEL_LIST_ELEMENT, Y_DEL_LIST_ELEMENT, W_DELETE_LIST_ITEM, H_LIST_NORMAL_MENU_ITEM), listIndex, message, + FONT_SIZE_MAIN_TXT, COLOR_NORMAL_SUB_TXT, COLOR_PRESS_MAIN_TXT, COLOR_PRESS_MAIN_TXT, false); + pItem->SetElementTextHorizontalAlignment(listIndex, ALIGNMENT_LEFT); + pItem->SetElementTextVerticalAlignment(listIndex, ALIGNMENT_MIDDLE); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, COLOR_NORMAL_ITEM_BG); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, COLOR_PRESS_ITEM_BG); + delete pMsgList; + } + } + return pItem; +} + +bool +SettingsDeleteListForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} diff --git a/src/PhnSettingsEditRejectMsgForm.cpp b/src/PhnSettingsEditRejectMsgForm.cpp new file mode 100644 index 0000000..67853f1 --- /dev/null +++ b/src/PhnSettingsEditRejectMsgForm.cpp @@ -0,0 +1,238 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsEditRejectMsgForm.cpp + * @brief Settings Edit reject message form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSettingsEditRejectMsgForm.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +static const wchar_t* IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM = L"IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM"; + +SettingsEditRejectMsgForm::SettingsEditRejectMsgForm(FormMode formMode) + : __formMode(formMode),__pSettingsPresentor(null) +{ +} + +SettingsEditRejectMsgForm::~SettingsEditRejectMsgForm(void) +{ +} + +bool +SettingsEditRejectMsgForm::Initialize(void) +{ + Construct(IDL_SETTINGS_ADD_EDIT_REJECT_MSGS_FORM); + return true; +} + +result +SettingsEditRejectMsgForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + //Initialize Header + InitializeHeader(); + //Initialize reject message editArea + ExpandableEditArea* pEditMsgs = static_cast(GetControl(IDC_REJECTMSG_EXPANDABLEEDITAREA)); + if (pEditMsgs != null) + { + pEditMsgs->AddTextEventListener(*this); + pEditMsgs->SetFocus(); + pEditMsgs->ShowKeypad(); + } + + return r; +} + +void +SettingsEditRejectMsgForm::InitializeHeader(void) +{ + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetStyle(HEADER_STYLE_BUTTON); + + //'Save' item + String saveItemName; + saveItemName.Append(AppUtility::GetResourceString(IDS_SETTING_SAVE_HEADER_ITEM)); + HeaderItem saveHeaderItem; + saveHeaderItem.Construct(IDA_SAVE_HEADER_ITEMID); + saveHeaderItem.SetText(saveItemName); + pHeader->AddItem(saveHeaderItem); + pHeader->SetItemEnabled(0,false); + + //'Cancel' item + ButtonItem cancelHeaderItem; + cancelHeaderItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_HEADER_ITEMID); + Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_BACK_HEADER_ITEM, W_HDR_FTR_ICON, H_HDR_FTR_ICON); + Bitmap* pPressBmp = AppUtility::GetBitmapFromResourcesN(IDB_BACK_HEADER_ITEM_PRESSED, W_HDR_FTR_ICON, H_HDR_FTR_ICON); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBmp); + pHeader->SetButton(BUTTON_POSITION_RIGHT, cancelHeaderItem); + delete pNormalBmp; + pNormalBmp = null; + delete pPressBmp; + pPressBmp = null; + + pHeader->AddActionEventListener(*this); + } +} + +result +SettingsEditRejectMsgForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SettingsEditRejectMsgForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_CANCEL_HEADER_ITEMID: + { + } + break; + + case IDA_SAVE_HEADER_ITEMID: + { + if (__itemIndex != -1) + { + String msgString; + ExpandableEditArea* pEditMsgs = static_cast(GetControl(IDC_REJECTMSG_EXPANDABLEEDITAREA)); + if (pEditMsgs != null) + { + if (pEditMsgs->GetTextLength() == 0) + { + //switch back to previous form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null); + return; + } + msgString.Append(pEditMsgs->GetText()); + } + __pSettingsPresentor->SetRejectMessage(__itemIndex, msgString); + } + } + break; + + default: + break; + } + + //switch back to previous form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null); +} + +void +SettingsEditRejectMsgForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + __itemIndex = -1; + + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + ExpandableEditArea* pEditMsgs = static_cast(GetControl(IDC_REJECTMSG_EXPANDABLEEDITAREA)); + if (__formMode == FORMMODE_EDIT_MESSAGE && pArgs != null) + { + __itemIndex = (static_cast(pArgs->GetAt(0)))->ToInt(); + String* pRejectMsg = static_cast(pArgs->GetAt(1)); + if (pEditMsgs != null) + { + pEditMsgs->SetText(*pRejectMsg); + pEditMsgs->SetFocus(); + } + } + else if (__formMode == FORMMODE_NEW_MESSAGE && pArgs != null) + { + __itemIndex = (static_cast(pArgs->GetAt(0)))->ToInt(); + if (pEditMsgs != null) + { + pEditMsgs->Clear(); + pEditMsgs->SetFocus(); + } + } + + //Enable or disable save button + Header* pHeader = GetHeader(); + bool enableSaveHeaderItem = (__formMode == FORMMODE_EDIT_MESSAGE); + if (pHeader) + { + pHeader->SetItemEnabled(0, enableSaveHeaderItem); + pHeader->Invalidate(true); + } + + if (pArgs) + { + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +SettingsEditRejectMsgForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + // Add your scene deactivate code here + __pSettingsPresentor = null; + ExpandableEditArea* pEditMsgs = static_cast(GetControl(IDC_REJECTMSG_EXPANDABLEEDITAREA)); + if (pEditMsgs != null) + { + pEditMsgs->HideKeypad(); + } +} + +void +SettingsEditRejectMsgForm::OnTextValueChanged(const Control& source) +{ + int textLen = -1; + ExpandableEditArea* pEditMsgs = static_cast(GetControl(IDC_REJECTMSG_EXPANDABLEEDITAREA)); + if (pEditMsgs) + { + textLen = pEditMsgs->GetTextLength(); + Header* pHeader = GetHeader(); + if (textLen > 0) + { + //Enable save button + pHeader->SetItemEnabled(0, true); + } + else + { + //disable + pHeader->SetItemEnabled(0, false); + } + pHeader->Invalidate(true); + } +} + +void +SettingsEditRejectMsgForm::OnTextValueChangeCanceled(const Control& source) +{ +} diff --git a/src/PhnSettingsForwardToNumberForm.cpp b/src/PhnSettingsForwardToNumberForm.cpp new file mode 100644 index 0000000..6363772 --- /dev/null +++ b/src/PhnSettingsForwardToNumberForm.cpp @@ -0,0 +1,843 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsForwardToNumberForm.cpp + * @brief Setting Forward to number form + */ +#include +#include +#include "PhnAppUtility.h" +#include "PhnCallPresentationModel.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSettingsForwardToNumberForm.h" +#include "PhnSceneRegister.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +static const wchar_t* IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM = L"IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM"; +static const wchar_t* IDL_SETTINGS_FORWARDTO_NUMBER_FORM = L"IDL_SETTINGS_FORWARDTO_NUMBER_FORM"; +const int IDI_WAITTIMEOPTIONS_TOTALCOUNT = 6; + +SettingsForwardToNumberForm::SettingsForwardToNumberForm(ForwardCondition forwardCondition) + : __forwardCondition(forwardCondition) + , __pSettingsPresentor(null) + , __selectedWaitTime(WAITTIMEOPTIONS_THIRTY_SEC) + , __isWaitTimeOptionsMenuExpanded(false) + , __pErrorMsgPopup(null) +{ +} + +SettingsForwardToNumberForm::~SettingsForwardToNumberForm(void) +{ +} + +bool +SettingsForwardToNumberForm::Initialize(void) +{ + switch (__forwardCondition) + { + case FORWARDCONDITION_NOREPLY: + { + Construct(IDL_SETTINGS_NOREPLY_FORWARDTO_NUMBER_FORM); + } + break; + + default: + { + Construct(IDL_SETTINGS_FORWARDTO_NUMBER_FORM); + } + break; + } + + return true; +} + +result +SettingsForwardToNumberForm::OnInitializing(void) +{ + result r = E_SUCCESS; + //Initialize Header + InitializeHeader(); + //Initialize list view + r = InitializeGroupedTableView(); + TryReturn(r == E_SUCCESS,r,"GroupedTableView initialization failed"); + //Initialize numeric edit field + InitializeNumberEditField(); + return r; +} + +void +SettingsForwardToNumberForm::InitializeHeader(void) +{ + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetStyle(HEADER_STYLE_BUTTON); + //'Done' item + String doneItemName; + doneItemName.Append(AppUtility::GetResourceString(IDS_SETTING_DONE_HEADER_ITEM)); + HeaderItem doneHeaderItem; + doneHeaderItem.Construct(IDA_SAVE_HEADER_ITEMID); + doneHeaderItem.SetText(doneItemName); + pHeader->AddItem(doneHeaderItem); + pHeader->SetItemEnabled(0, false); + + //'Cancel' item + ButtonItem cancelHeaderItem; + cancelHeaderItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_HEADER_ITEMID); + Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_CANCEL_FOOTER_ITEM, W_HDR_FTR_ICON, H_HDR_FTR_ICON); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp); + cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pNormalBmp); + pHeader->SetButton(BUTTON_POSITION_RIGHT, cancelHeaderItem); + delete pNormalBmp; + pNormalBmp = null; + + pHeader->AddActionEventListener(*this); + } +} + +result +SettingsForwardToNumberForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SettingsForwardToNumberForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_CANCEL_HEADER_ITEMID: + { + //go back to previous form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_FORWARD_OPTIONS), null); + } + break; + + case IDA_SAVE_HEADER_ITEMID: + { + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + //disable all other forwarding conditions, if 'CALL_FORWARD_ALL' is activated + /*if(__callForwardCondition == CALL_FORWARD_ALL) + { + __pSettingsPresentor->SetCallForwardStatus(L"", CALL_FORWARD_BUSY, false, 0); + __pSettingsPresentor->SetCallForwardStatus(L"", CALL_FORWARD_NO_REPLY, false, 0); + __pSettingsPresentor->SetCallForwardStatus(L"", CALL_FORWARD_NOT_REACHABLE, false, 0); + }*/ + + //enable status + String phoneNumber = pEditFieldNumber->GetText(); + int errorCode = __pSettingsPresentor->SetCallForwardStatus(phoneNumber, __callForwardCondition, true, __selectedWaitTime); + if(errorCode != ERROR_NONE) + { + ShowErrorMessage(errorCode); + return; + } + } + //go back to previous form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_FORWARD_OPTIONS), null); + } + break; + + case IDA_VOICEMAIL: + { + } + break; + + case IDA_SELECT_CONTACT: + { + LaunchContactsAppControl(); + } + break; + + default: + break; + } +} + +void +SettingsForwardToNumberForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + __pSettingsPresentor->AddSettingEventListener(this); + + if (pArgs != null) + { + int errorCode = ERROR_NONE; + Integer* indexInt = static_cast(pArgs->GetAt(0)); + switch (indexInt->ToInt()) + { + case 0: + { + __callForwardCondition = CALL_FORWARD_ALL; + } + break; + + case 1: + { + __callForwardCondition = CALL_FORWARD_BUSY; + } + break; + + case 2: + { + __callForwardCondition = CALL_FORWARD_NO_REPLY; + } + break; + + case 3: + { + __callForwardCondition = CALL_FORWARD_NO_REPLY; + } + break; + + default: + break; + } + + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(pMainMenuTableView != null) + { + __selectedWaitTime = WAITTIMEOPTIONS_THIRTY_SEC; + int selectIndex = (__selectedWaitTime / 5) - 1; + //by default, "30 seconds" option is selected + pMainMenuTableView->SetItemChecked(GROUP_WAIT_TIME_OPTIONS, selectIndex, true); + //uncheck all other items + for (int deselectIndex = 0; deselectIndex < selectIndex; deselectIndex++) + { + pMainMenuTableView->SetItemChecked(GROUP_WAIT_TIME_OPTIONS, deselectIndex, false); + } + pMainMenuTableView->RefreshItem(GROUP_SELECT_WAIT_TIME, SELECTWAITTIME_WAIT_TIME, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + pMainMenuTableView->Invalidate(true); + } + + //fetch forwarding status + errorCode = __pSettingsPresentor->GetCallForwardStatus(__callForwardCondition); + if(errorCode != ERROR_NONE) + { + //Show error message popup + ShowErrorMessage(errorCode); + } + + //clear text field and disable "Done" button + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if(pEditFieldNumber != null) + { + pEditFieldNumber->Clear(); + pEditFieldNumber->SetFocus(); + } + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetItemEnabled(0, false); + } + + pArgs->RemoveAll(); + delete pArgs; + pArgs = null; + } +} + +void +SettingsForwardToNumberForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + __pSettingsPresentor->RemoveSettingEventListener(); + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + pEditFieldNumber->HideKeypad(); + } +} + +void +SettingsForwardToNumberForm::InitializeNumberEditField(void) +{ + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + pEditFieldNumber->AddKeypadEventListener(*this); + pEditFieldNumber->AddTextEventListener(*this); + pEditFieldNumber->SetOverlayKeypadCommandButtonVisible(false); + } + + Button* pContactBtn = static_cast(GetControl(IDC_SELECT_CONTACT_BUTTON)); + if (pContactBtn != null) + { + pContactBtn->SetActionId(IDA_SELECT_CONTACT); + pContactBtn->AddActionEventListener(*this); + } + + Button* pVoiceMailBtn = static_cast(GetControl(IDC_VOICEMAIL_BUTTON)); + if (pVoiceMailBtn != null) + { + pVoiceMailBtn->SetActionId(IDA_VOICEMAIL); + pVoiceMailBtn->AddActionEventListener(*this); + } +} + +result +SettingsForwardToNumberForm::InitializeGroupedTableView(void) +{ + result r = E_SUCCESS; + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + pMainMenuTableView->SetGroupedLookEnabled(true); + pMainMenuTableView->SetItemProvider(this); + r = pMainMenuTableView->AddGroupedTableViewItemEventListener(*this); + pMainMenuTableView->UpdateTableView(); + CollapseSelectiveGroups(pMainMenuTableView); + } + return r; +} + +void +SettingsForwardToNumberForm::CollapseSelectiveGroups(GroupedTableView* pMainMenuTableView) +{ + //This function should be called only from "InitializeGroupedTableView()". + //since collapsing individual groups while GroupTableView construction causes flicker. + pMainMenuTableView->CollapseAllGroup(); + //Expand other groups + pMainMenuTableView->ExpandGroup(GROUP_SELECT_WAIT_TIME); + pMainMenuTableView->UpdateTableView(); +} + +void +SettingsForwardToNumberForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + switch (groupIndex) + { + case GROUP_SELECT_WAIT_TIME: + { + //close overlay keypad + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null && pEditFieldNumber->HasFocus() == true) + { + //If Keyapd is open, then "CloseGroup" in OnKeypadClose() callback + pEditFieldNumber->HideKeypad(); + } + else + { + //keypad is closed, directly expand group + ToggleGroupExpansion(tableView, itemIndex); + } + } + break; + + case GROUP_WAIT_TIME_OPTIONS: + { + HandleSelectedWaitingTime(tableView, itemIndex, status); + } + break; + + default: + break; + } +} + +int +SettingsForwardToNumberForm::GetGroupCount(void) +{ + return GROUP_TOTALCOUNT; +} + +int +SettingsForwardToNumberForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case GROUP_SELECT_WAIT_TIME: + { + itemCount = SELECTWAITTIME_TOTALCOUNT; + } + break; + + case GROUP_WAIT_TIME_OPTIONS: + { + itemCount = IDI_WAITTIMEOPTIONS_TOTALCOUNT; + } + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsForwardToNumberForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +bool +SettingsForwardToNumberForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsForwardToNumberForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsForwardToNumberForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewItem* pItem = null; + + switch (groupIndex) + { + case GROUP_SELECT_WAIT_TIME: + { + pItem = CreateExpandableWaitingItem(itemWidth); + } + break; + + case GROUP_WAIT_TIME_OPTIONS: + { + pItem = CreateWaitingTimeOptionsMenuItems(itemIndex, itemWidth); + } + break; + + default: + break; + } + + return pItem; +} + +bool +SettingsForwardToNumberForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsForwardToNumberForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem) +{ + if(groupIndex == GROUP_SELECT_WAIT_TIME && itemIndex == SELECTWAITTIME_WAIT_TIME) + { + String subText = FetchTextForSelectedOption(__selectedWaitTime); + //sub text item + Label* pSubTxtLbl = static_cast(pItem->GetControl(IDC_SELECTEDOPTION_SUBTEXT_LABEL, true)); + if(pSubTxtLbl != null) + { + pSubTxtLbl->SetText(subText); + pSubTxtLbl->Invalidate(true); + } + //set Drop-down icon to item + SetExpandIconToItem(pItem, __isWaitTimeOptionsMenuExpanded); + } +} + +int +SettingsForwardToNumberForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsForwardToNumberForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} + +TableViewItem* +SettingsForwardToNumberForm::CreateExpandableWaitingItem(int itemWidth) +{ + //main text + Rectangle mainItemRect(X_LIST_MENU_TEXT_ITEM, Y_LIST_MENU_TEXT_ITEM, (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), + H_LIST_DROPDOWN_TXT_ITEM); + String mainText = AppUtility::GetResourceString(IDS_SETTING_WAITING_TIME_STRING); + //sub text + Rectangle subItemRect(X_LIST_MENU_TEXT_ITEM, (Y_LIST_MENU_TEXT_ITEM + H_LIST_DROPDOWN_TXT_ITEM), + (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), H_LIST_DROPDOWN_TXT_ITEM); + String subText = FetchTextForSelectedOption(__selectedWaitTime); + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_DROPDOWN_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + + //main text item + Label* pMainTxtLbl = new (std::nothrow) Label(); + pMainTxtLbl->Construct(mainItemRect, mainText); + pMainTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pMainTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pMainTxtLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pMainTxtLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT); + pItem->AddControl(*pMainTxtLbl); + //sub text item + Label* pSubTxtLbl = new (std::nothrow) Label(); + pSubTxtLbl->Construct(subItemRect, subText); + pSubTxtLbl->SetName(IDC_SELECTEDOPTION_SUBTEXT_LABEL); + pSubTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pSubTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pSubTxtLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pSubTxtLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pSubTxtLbl); + + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + //set Drop-down icon to item + SetExpandIconToItem(pItem, __isWaitTimeOptionsMenuExpanded); + return pItem; +} + +String +SettingsForwardToNumberForm::FetchTextForSelectedOption(int selectedWaitTimeOption) +{ + //default text + String subText(L""); + switch(selectedWaitTimeOption) + { + case WAITTIMEOPTIONS_FIVE_SEC: + subText.Append(L"5 "); + break; + + case WAITTIMEOPTIONS_TEN_SEC: + subText.Append(L"10 "); + break; + + case WAITTIMEOPTIONS_FIFTEEN_SEC: + subText.Append(L"15 "); + break; + + case WAITTIMEOPTIONS_TWENTY_SEC: + subText.Append(L"20 "); + break; + + case WAITTIMEOPTIONS_TWENTYFIVE_SEC: + subText.Append(L"25 "); + break; + + case WAITTIMEOPTIONS_THIRTY_SEC: + default: + subText.Append(L"30 "); + break; + } + subText.Append(AppUtility::GetResourceString(IDS_SETTING_WAIT_INTERVAL_STRING)); + return subText; +} + +void +SettingsForwardToNumberForm::SetExpandIconToItem(TableViewItem* pItem, bool isExpanded) +{ + Bitmap* pNormalIcon = null; + Bitmap* pPressIcon = null; + + if (!isExpanded) + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + else + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + + int itemWidth = pItem->GetWidth(); + Rectangle iconRect((itemWidth - W_EXPAND_ICON - X_LIST_MENU_TEXT_ITEM), + ((H_LIST_DROPDOWN_MENU_ITEM - H_EXPAND_ICON) / 2), W_EXPAND_ICON, H_EXPAND_ICON); + //for drawing blue bg header rectangle on left side. + Rectangle blueHeaderRect(0,0,W_LEFT_HEADER_EXPAND_ITEMS,pItem->GetHeight()); + //normal canvas + Canvas* pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pNormalIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + Bitmap* pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + delete pBgCanvas; + delete pActualBgBmp; + //pressed canvas + pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pPressIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + delete pBgCanvas; + delete pActualBgBmp; + + delete pNormalIcon; + pNormalIcon = null; + delete pPressIcon; + pPressIcon = null; +} + +void +SettingsForwardToNumberForm::ToggleGroupExpansion(GroupedTableView& tableView, int itemIndex) +{ + switch (itemIndex) + { + case SELECTWAITTIME_WAIT_TIME: + { + if (tableView.IsGroupExpanded(GROUP_WAIT_TIME_OPTIONS)) + { + tableView.CollapseGroup(GROUP_WAIT_TIME_OPTIONS); + __isWaitTimeOptionsMenuExpanded = false; + } + else + { + tableView.ExpandGroup(GROUP_WAIT_TIME_OPTIONS); + __isWaitTimeOptionsMenuExpanded = true; + } + //Change icon + tableView.RefreshItem(GROUP_SELECT_WAIT_TIME, SELECTWAITTIME_WAIT_TIME, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + break; + + default: + break; + } + +} + +TableViewItem* +SettingsForwardToNumberForm::CreateWaitingTimeOptionsMenuItems(int itemIndex, int itemWidth) +{ + //create a new item + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_RADIO); + pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //text item rectangle + Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_DROPDOWN_MENU_ITEM); + //Option item name + String itemName(L""); + GroupSelectWaitTimeItems selectedOption = (GroupSelectWaitTimeItems)((itemIndex + 1) * 5); + itemName.Append(FetchTextForSelectedOption(selectedOption)); + + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + return pItem; +} + +void +SettingsForwardToNumberForm::HandleSelectedWaitingTime(GroupedTableView& tableView, int itemIndex, TableViewItemStatus status) +{ + GroupWaitTimeOptionsItems currentWaitTime = (GroupWaitTimeOptionsItems) ((itemIndex + 1) * 5); + + //check if already checked item is selected + if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + tableView.SetItemChecked(GROUP_WAIT_TIME_OPTIONS, itemIndex, true); + __selectedWaitTime = currentWaitTime; + return; + } + //uncheck previously selected option + if(__selectedWaitTime != currentWaitTime) + { + int deselectIndex = ((__selectedWaitTime / 5) - 1); + tableView.SetItemChecked(GROUP_WAIT_TIME_OPTIONS, deselectIndex, false); + tableView.RefreshItem(GROUP_WAIT_TIME_OPTIONS, deselectIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + //update selected wait time for selected itemIndex + __selectedWaitTime = currentWaitTime; + //Change icon and sub text for wait time options menu + tableView.RefreshItem(GROUP_SELECT_WAIT_TIME, SELECTWAITTIME_WAIT_TIME, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + tableView.Invalidate(true); +} + +void +SettingsForwardToNumberForm::OnKeypadWillOpen(Tizen::Ui::Control& source) +{ + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(pMainMenuTableView != null && __isWaitTimeOptionsMenuExpanded == true) + { + pMainMenuTableView->CollapseGroup(GROUP_WAIT_TIME_OPTIONS); + __isWaitTimeOptionsMenuExpanded = false; + //Change icon + pMainMenuTableView->RefreshItem(GROUP_SELECT_WAIT_TIME, SELECTWAITTIME_WAIT_TIME, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } +} + +void +SettingsForwardToNumberForm::OnKeypadClosed(Tizen::Ui::Control& source) +{ + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(pMainMenuTableView != null && __isWaitTimeOptionsMenuExpanded == false) + { + ToggleGroupExpansion(*pMainMenuTableView, SELECTWAITTIME_WAIT_TIME); + } +} + +void +SettingsForwardToNumberForm::ShowErrorMessage(int errorCode) +{ + //show error msg Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode); +} + +void +SettingsForwardToNumberForm::HandlePopupClosed(void) +{ + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + return; +} + +void +SettingsForwardToNumberForm::HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime) +{ + if (callForwardActivated == true) + { + //update forward number in text field + if(callFwdNumber.IsEmpty() == false) + { + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + if (pEditFieldNumber != null) + { + pEditFieldNumber->SetText(callFwdNumber); + pEditFieldNumber->Invalidate(true); + } + } + //update No Reply Wait time status + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + //un-check all waiting time options + int index = 0; + while(index < IDI_WAITTIMEOPTIONS_TOTALCOUNT) + { + pMainMenuTableView->SetItemChecked(GROUP_WAIT_TIME_OPTIONS, index, false); + index++; + } + //enable selected wait time option + if(noReplyWaitTime >= WAITTIMEOPTIONS_FIVE_SEC) + { + int selectedIndex = (noReplyWaitTime / WAITTIMEOPTIONS_FIVE_SEC) - 1; + pMainMenuTableView->SetItemChecked(GROUP_WAIT_TIME_OPTIONS, selectedIndex, true); + } + pMainMenuTableView->Invalidate(true); + } + } +} + +void +SettingsForwardToNumberForm::LaunchContactsAppControl(void) +{ + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(SELECTION_MODE), new (std::nothrow) String(SELECTION_MODE_SINGLE)); + extraData.Add(new (std::nothrow) String(RETURN_TYPE), new (std::nothrow) String(RETURN_TYPE_PHONE)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_PICK); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + delete pAc; + } + extraData.RemoveAll(true); +} + +void +SettingsForwardToNumberForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + if (appId.Equals(String(PROVIDER_ID_CONTACTS)) && operationId.Equals(String(OPERATION_ID_PICK)) + && (appControlResult == APP_CTRL_RESULT_SUCCEEDED)) + { + const String* rettype = static_cast(pExtraData->GetValue( String(RETURN_TYPE))); + if (rettype->Equals(String(RETURN_TYPE_PHONE))) + { + const String* pPickResult = static_cast(pExtraData->GetValue( String(RETURN_KEY_VALUE))); + if (pPickResult != null && pPickResult->IsEmpty() == false) + { + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + pEditFieldNumber->SetText(*pPickResult); + pEditFieldNumber->Invalidate(true); + //enable "Done" button + pHeader->SetItemEnabled(0, true); + pHeader->Invalidate(true); + } + } + } + } + +} + +void +SettingsForwardToNumberForm::OnTextValueChanged(const Control& source) +{ + //enable or disable "Done" button + EditField* pEditFieldNumber = static_cast(GetControl(IDC_FOWARDING_NUMBER_EDITFIELD)); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + bool activate = false; + if(pEditFieldNumber->GetTextLength() > 0) + { + activate = true; + } + pHeader->SetItemEnabled(0, activate); + pHeader->Invalidate(true); + } +} + +void +SettingsForwardToNumberForm::OnTextValueChangeCanceled(const Control& source) +{ + //text change canceled, disable save button + const EditField* pEditFieldNumber = static_cast(&source); + Header* pHeader = GetHeader(); + if (pEditFieldNumber != null && pHeader != null) + { + pHeader->SetItemEnabled(0, false); + pHeader->Invalidate(true); + } +} + diff --git a/src/PhnSettingsMainMenuForm.cpp b/src/PhnSettingsMainMenuForm.cpp new file mode 100644 index 0000000..ea3d7b0 --- /dev/null +++ b/src/PhnSettingsMainMenuForm.cpp @@ -0,0 +1,369 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsMainMenuForm.cpp + * @brief Setting Main menu form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSceneRegister.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsMainMenuForm.h" +#include "PhnSettingsPresentationModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; + +static const wchar_t* IDL_SETTINGS_MAINMENU_FORM = L"IDL_SETTINGS_MAINMENU_FORM"; + +SettingsMainMenuForm::SettingsMainMenuForm(void) +{ +} + +SettingsMainMenuForm::~SettingsMainMenuForm(void) +{ +} + +bool +SettingsMainMenuForm::Initialize(void) +{ + Construct(IDL_SETTINGS_MAINMENU_FORM); + return true; +} + +result +SettingsMainMenuForm::OnInitializing(void) +{ + result r = E_SUCCESS; + //Footer + Footer* pFooter = GetFooter(); + if (pFooter) + { + pFooter->SetBackButton(); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + // Setup back event listener + SetFormBackEventListener(this); + pFooter->AddActionEventListener(*this); + } + + //initialize table view + r = InitializeGroupedTableView(); + + return r; +} + +result +SettingsMainMenuForm::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SettingsMainMenuForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + default: + break; + } +} + +void +SettingsMainMenuForm::OnFormBackRequested(Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} + +void +SettingsMainMenuForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ +} + +void +SettingsMainMenuForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +result +SettingsMainMenuForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pMainMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMainMenuTableView != null) + { + pMainMenuTableView->SetGroupedLookEnabled(true); + pMainMenuTableView->SetItemProvider(this); + r = pMainMenuTableView->AddGroupedTableViewItemEventListener(*this); + pMainMenuTableView->UpdateTableView(); + //disabling "call forwarding" option on emulator + pMainMenuTableView->SetItemEnabled(GROUP_MAIN_CALL_SETTINGS, MAINCALLSETTINGS_CALLFORWARDING, false); + } + return r; +} + +void +SettingsMainMenuForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + if(groupIndex == GROUP_CALL_REJECTION) + { + //switch to call reject list form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTLIST_MENU), null); + } + else if(groupIndex == GROUP_REJECT_MSG) + { + //switch to reject msg list form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null); + } + else if(groupIndex == GROUP_MAIN_CALL_SETTINGS) + { + switch (itemIndex) + { + case MAINCALLSETTINGS_SPEEDDIAL: + { + //switch to speed dial form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null); + } + break; + + case MAINCALLSETTINGS_CALLFORWARDING: + { + //switch to form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALLTYPE_FORWARD), null); + } + break; + + case MAINCALLSETTINGS_MORECALLSETTINGS: + { + //switch to speed dial form + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null); + } + break; + + default: + break; + } + } +} + +int +SettingsMainMenuForm::GetGroupCount(void) +{ + return GROUP_TOTALCOUNT; +} + +int +SettingsMainMenuForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case GROUP_CALL_REJECTION: + itemCount = CALLREJECTION_TOTALCOUNT; + break; + + case GROUP_REJECT_MSG: + itemCount = REJECTMSG_TOTALCOUNT; + break; + + case GROUP_MAIN_CALL_SETTINGS: + itemCount = MAINCALLSETTINGS_TOTALCOUNT; + break; + + case GROUP_CALL_REJECTION_HLPTXT: + case GROUP_REJECT_MSG_HLPTXT: + itemCount = 0; + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsMainMenuForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + String helpText(L""); + switch (groupIndex) + { + case GROUP_CALL_REJECTION_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_HLP_STRING)); + } + break; + + case GROUP_REJECT_MSG_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_MSG_HLP_STRING)); + } + break; + + default: + break; + } + + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + if (helpText.IsEmpty() == true) + { + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG); + } + else + { + //help text item rectangle + Rectangle helpItemRect(X_LIST_MENU_HLPTXT_ITEM, Y_LIST_MENU_HLPTXT_ITEM, (itemWidth - X_LIST_MENU_HLPTXT_ITEM), + (H_LIST_MENU_SINGLELINE_HLPTXT_ITEM - Y_LIST_MENU_HLPTXT_ITEM)); + pItem->Construct(Dimension(itemWidth, H_LIST_MENU_SINGLELINE_HLPTXT_ITEM)); + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(helpItemRect, helpText); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_HELP_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_HELP_TXT); + pItem->AddControl(*pItemLbl); + pItem->SetEnabled(false); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + } + return pItem; +} + +bool +SettingsMainMenuForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsMainMenuForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsMainMenuForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + //description text rectangle + Rectangle descriptionTxtRect(X_LIST_MENU_TEXT_ITEM, H_LIST_NORMAL_TXT_ITEM, + (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_SUB_TXT_ITEM); + String itemName(L""); + String descriptionText(L""); + if(groupIndex == GROUP_CALL_REJECTION) + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_STRING)); + } + else if(groupIndex == GROUP_REJECT_MSG) + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_MSG_STRING)); + } + else if(groupIndex == GROUP_MAIN_CALL_SETTINGS) + { + switch (itemIndex) + { + case MAINCALLSETTINGS_SPEEDDIAL: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_SPEEDDIAL_STRING)); + } + break; + + case MAINCALLSETTINGS_CALLFORWARDING: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_FORWARDING_STRING)); + } + break; + + case MAINCALLSETTINGS_MORECALLSETTINGS: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_MORE_MAIN_STRING)); + descriptionText.Append(AppUtility::GetResourceString(IDS_SETTING_MORE_SUB_STRING)); + //update item Name rectangle + itemNameRect.y = Y_LIST_MENU_TEXT_ITEM; + itemNameRect.height = H_LIST_NORMAL_TXT_ITEM; + } + break; + + default: + break; + } + } + + //Item Name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + //description text + if(descriptionText.IsEmpty() == false) + { + Label* pDescriptionLbl = new (std::nothrow) Label(); + pDescriptionLbl->Construct(descriptionTxtRect, descriptionText); + pDescriptionLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pDescriptionLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pDescriptionLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pDescriptionLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pDescriptionLbl); + } + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +bool +SettingsMainMenuForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsMainMenuForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + return; +} + +int +SettingsMainMenuForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsMainMenuForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} diff --git a/src/PhnSettingsManager.cpp b/src/PhnSettingsManager.cpp new file mode 100644 index 0000000..cf65c10 --- /dev/null +++ b/src/PhnSettingsManager.cpp @@ -0,0 +1,1758 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsManager.cpp + * @brief Setting Manager class + */ +#include +#include +#include +#include +#include "vconf.h" +#include "vconf-internal-ciss-keys.h" +#include "PhnSettingsManager.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::Social; + +SettingsManager* SettingsManager::__pInstance = null; + +SettingsManager::SettingsManager(void) + : __pTapiHandle(null) + , __pSettingsEventListener(null) + , __pCallSettingDataService(null) +{ + +} + +SettingsManager::~SettingsManager(void) +{ + //De-initialize the TAPI Library + if(__pTapiHandle != null) + { + tel_deinit(__pTapiHandle); + } + if (__pCallSettingDataService) + { + __pCallSettingDataService->CloseDatabase(); + delete __pCallSettingDataService; + } + if (__pSettingsEventListener != null) + { + delete __pSettingsEventListener; + } +} + +void SettingsManager::CreateInstance(void) +{ + __pInstance = new (std::nothrow) SettingsManager(); + result r = __pInstance->Construct(); + if(IsFailed(r)) + { + delete __pInstance; + __pInstance = null; + return; + } + std::atexit(&(SettingsManager::DestroyInstance)); +} + +void SettingsManager::DestroyInstance(void) +{ + delete __pInstance; +} + +result +SettingsManager::Construct(void) +{ + __pCallSettingDataService = CallSettingDataService::CreateInstance(); + result r = __pCallSettingDataService->OpenDatabase(); + if(IsFailed(r)) + { + return E_FAILURE; + } + //initialize telephony + __pTapiHandle = tel_init(null); + SetCallState(CALL_STATE__CALL_OFF); + return E_SUCCESS; +} + +SettingsManager* +SettingsManager::GetInstance(void) +{ + if (__pInstance == null) + { + CreateInstance(); + } + return __pInstance; +} + +void +SettingsManager::AddSettingEventListener(ISettingsEventListener* pSettingsEventListener) +{ + if (__pSettingsEventListener == null) + { + __pSettingsEventListener = new (std::nothrow) ArrayListT(); + } + + //Add to listeners, if not already in list. + if ( (pSettingsEventListener != null) + && !(__pSettingsEventListener->Contains(pSettingsEventListener)) ) + { + __pSettingsEventListener->Add(pSettingsEventListener); + } +} + +void +SettingsManager::RemoveSettingEventListener(ISettingsEventListener* pSettingsEventListener) +{ + if ((__pSettingsEventListener != null) && (pSettingsEventListener != null) + && __pSettingsEventListener->Contains(pSettingsEventListener)) + { + __pSettingsEventListener->Remove(pSettingsEventListener); + } +} + +void +SettingsManager::NotifyForwardingEventListeners(ForwardResponseType responseType, bool isCallSuccessful, CallForwardCondition callFwdCondition, const Tizen::Base::String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime) +{ + IEnumeratorT* pListenerEnum = null; + result r = E_FAILURE; + if (__pSettingsEventListener != null) + { + pListenerEnum = __pSettingsEventListener->GetEnumeratorN(); + //TryReturn(pListenerEnum != null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(GetLastResult())); + + while ((r = pListenerEnum->MoveNext()) != E_OUT_OF_RANGE) + { + ISettingsEventListener* pListener; + r = pListenerEnum->GetCurrent(pListener); + //TryCatch(r == E_SUCCESS, , "[%s] Propagated.", GetErrorMessage(r)); + if (responseType == SET_CALLFORWARD_RESPONSE) + { + pListener->HandleSetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, isCallForwardActivated, noReplyWaitTime); + } + else + { + pListener->HandleGetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, isCallForwardActivated, noReplyWaitTime); + } + } + } +} + +void +SettingsManager::NotifyBarringEventListeners(BarringResponseType responseType, bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) +{ + IEnumeratorT* pListenerEnum = null; + result r = E_FAILURE; + if (__pSettingsEventListener != null) + { + pListenerEnum = __pSettingsEventListener->GetEnumeratorN(); + //TryReturn(pListenerEnum != null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(GetLastResult())); + + while ((r = pListenerEnum->MoveNext()) != E_OUT_OF_RANGE) + { + ISettingsEventListener* pListener; + r = pListenerEnum->GetCurrent(pListener); + //TryCatch(r == E_SUCCESS, , "[%s] Propagated.", GetErrorMessage(r)); + if (responseType == SET_CALLBARRING_RESPONSE) + { + pListener->HandleSetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated); + } + else + { + pListener->HandleGetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated); + } + } + } +} + +void +SettingsManager::NotifyWaitingEventListeners(WaitingResponseType responseType, bool isCallSuccessful, bool isCallWaitingActivated) +{ + IEnumeratorT* pListenerEnum = null; + result r = E_FAILURE; + if (__pSettingsEventListener != null) + { + pListenerEnum = __pSettingsEventListener->GetEnumeratorN(); + //TryReturn(pListenerEnum != null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(GetLastResult())); + + while ((r = pListenerEnum->MoveNext()) != E_OUT_OF_RANGE) + { + ISettingsEventListener* pListener; + r = pListenerEnum->GetCurrent(pListener); + //TryCatch(r == E_SUCCESS, , "[%s] Propagated.", GetErrorMessage(r)); + if (responseType == SET_CALLWAITING_RESPONSE) + { + pListener->HandleSetCallWaitingResponse(isCallSuccessful, isCallWaitingActivated); + } + else + { + pListener->HandleGetCallWaitingResponse(isCallSuccessful, isCallWaitingActivated); + } + } + delete pListenerEnum; + } +} + +int +SettingsManager::SetCallForwardStatus(const String& phoneNumber, CallForwardCondition callFwdCondition, bool activateFwding, int noReplyTime) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null, ERROR_TAPI_INIT_FAILED, "Telephony initialization failed"); + + TelSsForwardInfo_t forwardInfo; + memset(&forwardInfo, 0, sizeof(TelSsForwardInfo_t)); + forwardInfo.Class = TAPI_SS_CLASS_VOICE; + if (activateFwding == true) + { + forwardInfo.Mode = TAPI_SS_CF_MODE_REGISTRATION_EV; + } + else + { + forwardInfo.Mode = TAPI_SS_CF_MODE_ERASURE_EV; + } + const wchar_t* pContact = phoneNumber.GetPointer(); + int len = phoneNumber.GetLength()+1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + strncpy(forwardInfo.szPhoneNumber, pNumber, len); + delete []pNumber; + pNumber = null; + switch (callFwdCondition) + { + case CALL_FORWARD_ALL: + { + forwardInfo.Condition = TAPI_SS_CF_WHEN_CFU; + } + break; + + case CALL_FORWARD_BUSY: + { + forwardInfo.Condition = TAPI_SS_CF_WHEN_CFB; + } + break; + + case CALL_FORWARD_NO_REPLY: + { + forwardInfo.Condition = TAPI_SS_CF_WHEN_CFNRy; + forwardInfo.NoReplyConditionTimer = TelSsNoReplyTime_t(noReplyTime); + } + break; + + case CALL_FORWARD_NOT_REACHABLE: + { + forwardInfo.Condition = TAPI_SS_CF_WHEN_CFNRc; + } + break; + + default: + { + return ERROR_INVALID_INPUT; + } + break; + } + + int retStatus = tel_set_ss_forward(__pTapiHandle, &forwardInfo, &HandleSetForwardResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + return errorCode; +} + +void +SettingsManager::HandleSetForwardResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsForwardResp_t* pResponse = (TelSsForwardResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + if (pResponse != null) + { + int count = pResponse->record_num; + for (int index = 0; index < count; index++) + { + CallForwardCondition callFwdCondition = CALL_FORWARD_ALL; + bool isActivated = false; + int noReplyWaitTime = 0; + //Check if status is "Active or Quiescent" and forwarding number is available + if ((pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE + || pResponse->record[index].Status == TAPI_SS_STATUS_QUIESCENT + || pResponse->record[index].Status == TAPI_SS_STATUS_REGISTERED) + && (pResponse->record[index].bCallForwardingNumberPresent != 0)) + { + isActivated = true; + } + switch (pResponse->record[index].ForwardCondition) + { + case TAPI_SS_CF_WHEN_CFU: + { + callFwdCondition = CALL_FORWARD_ALL; + } + break; + + case TAPI_SS_CF_WHEN_CFB: + { + callFwdCondition = CALL_FORWARD_BUSY; + } + break; + + case TAPI_SS_CF_WHEN_CFNRy: + { + callFwdCondition = CALL_FORWARD_NO_REPLY; + //fetch WaitTime + noReplyWaitTime = (pResponse->record[index].NoReplyWaitTime); + } + break; + + case TAPI_SS_CF_WHEN_CFNRc: + { + callFwdCondition = CALL_FORWARD_NOT_REACHABLE; + } + break; + + default: + break; + } + //fetch forwarding number + char* pTmpNumberPtr = new (std::nothrow) char[TAPI_CALL_DIALDIGIT_LEN_MAX]; + strncpy(pTmpNumberPtr, (char*) (pResponse->record[index].szCallForwardingNumber), TAPI_CALL_DIALDIGIT_LEN_MAX); + String callFwdNumber(pTmpNumberPtr); + delete []pTmpNumberPtr; + pTmpNumberPtr = null; + + //notify event listeners + pSettingsManager->NotifyForwardingEventListeners(SET_CALLFORWARD_RESPONSE,(result == TAPI_SS_SUCCESS),callFwdCondition, callFwdNumber, isActivated, noReplyWaitTime); + } + } +} + +int +SettingsManager::GetCallForwardStatus(CallForwardCondition callFwdCondition) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null,ERROR_TAPI_INIT_FAILED,"Telephony initialization failed"); + + TelSsForwardWhen_t condition; + switch (callFwdCondition) + { + case CALL_FORWARD_ALL: + { + condition = TAPI_SS_CF_WHEN_CFU; + } + break; + + case CALL_FORWARD_BUSY: + { + condition = TAPI_SS_CF_WHEN_CFB; + } + break; + + case CALL_FORWARD_NO_REPLY: + { + condition = TAPI_SS_CF_WHEN_CFNRy; + } + break; + + case CALL_FORWARD_NOT_REACHABLE: + { + condition = TAPI_SS_CF_WHEN_CFNRc; + } + break; + + default: + { + return ERROR_INVALID_INPUT; + } + break; + } + int retStatus = tel_get_ss_forward_status(__pTapiHandle, TAPI_SS_CLASS_VOICE, condition, &HandleGetForwardResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + + return errorCode; +} + +void +SettingsManager::HandleGetForwardResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsForwardResp_t* pResponse = (TelSsForwardResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + if (pResponse != null) + { + int count = pResponse->record_num; + for (int index = 0; index < count; index++) + { + CallForwardCondition callFwdCondition = CALL_FORWARD_ALL; + bool isActivated = false; + int noReplyWaitTime = 0; + //Check if status is "ACTIVE or QUIESCENT or REGISTERED" and forwarding number is available + if ((pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE + || pResponse->record[index].Status == TAPI_SS_STATUS_QUIESCENT + || pResponse->record[index].Status == TAPI_SS_STATUS_REGISTERED) + && (pResponse->record[index].bCallForwardingNumberPresent != 0)) + { + isActivated = true; + } + switch (pResponse->record[index].ForwardCondition) + { + case TAPI_SS_CF_WHEN_CFU: + { + callFwdCondition = CALL_FORWARD_ALL; + } + break; + + case TAPI_SS_CF_WHEN_CFB: + { + callFwdCondition = CALL_FORWARD_BUSY; + } + break; + + case TAPI_SS_CF_WHEN_CFNRy: + { + callFwdCondition = CALL_FORWARD_NO_REPLY; + noReplyWaitTime = (pResponse->record[index].NoReplyWaitTime); + } + break; + + case TAPI_SS_CF_WHEN_CFNRc: + { + callFwdCondition = CALL_FORWARD_NOT_REACHABLE; + } + break; + + default: + break; + } + char* pTmpNumberPtr = new (std::nothrow) char[TAPI_CALL_DIALDIGIT_LEN_MAX]; + strncpy(pTmpNumberPtr, (char*) (pResponse->record[index].szCallForwardingNumber), TAPI_CALL_DIALDIGIT_LEN_MAX); + String callFwdNumber(pTmpNumberPtr); + //notify event listeners + pSettingsManager->NotifyForwardingEventListeners(GET_CALLFORWARD_RESPONSE, (result == TAPI_SS_SUCCESS), callFwdCondition, callFwdNumber, isActivated, noReplyWaitTime); + delete []pTmpNumberPtr; + pTmpNumberPtr = null; + } + } +} + +int +SettingsManager::SetCallBarringStatus(const String& password, CallBarringType callBarringType, bool activateBarring) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null, ERROR_TAPI_INIT_FAILED, "Telephony initialization failed"); + + TelSsBarringInfo_t barringInfo; + memset(&barringInfo, 0, sizeof(TelSsBarringInfo_t)); + barringInfo.Class = TAPI_SS_CLASS_VOICE; + if (activateBarring == true) + { + barringInfo.Mode = TAPI_SS_CB_MODE_ACTIVATE; + } + else + { + barringInfo.Mode = TAPI_SS_CB_MODE_DEACTIVATE; + } + const wchar_t* pContact = password.GetPointer(); + int len = password.GetLength(); + if (len > 4) + { + return ERROR_BARRING_PWD_TOO_LONG; + } + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + strncpy(barringInfo.szPassword, pNumber, len); + delete []pNumber; + pNumber = null; + switch (callBarringType) + { + case CALL_BARRING_ALL_OUTGOING: + { + barringInfo.Type = TAPI_SS_CB_TYPE_BAOC; + } + break; + + case CALL_BARRING_INTERNATIONAL_OUTGOING: + { + barringInfo.Type = TAPI_SS_CB_TYPE_BOIC; + } + break; + + case CALL_BARRING_INTERNATIONAL_EXCEPT_HOME: + { + barringInfo.Type = TAPI_SS_CB_TYPE_BOIC_NOT_HC; + } + break; + + case CALL_BARRING_ALL_INCOMING: + { + barringInfo.Type = TAPI_SS_CB_TYPE_BAIC; + } + break; + + case CALL_BARRING_INCOMING_ROAMING: + { + barringInfo.Type = TAPI_SS_CB_TYPE_BIC_ROAM; + } + break; + + default: + { + return ERROR_INVALID_INPUT; + } + break; + } + int retStatus = tel_set_ss_barring(__pTapiHandle, &barringInfo, &HandleSetBarringResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + + return errorCode; +} + +void +SettingsManager::HandleSetBarringResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsBarringResp_t* pResponse = (TelSsBarringResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + if (pResponse != null) + { + CallBarringType callBarringType = CALL_BARRING_ALL_OUTGOING; + bool isActivated = false; + int count = pResponse->record_num; + for (int index = 0; index < count; index++) + { + if (pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE) + { + isActivated = true; + } + switch (pResponse->record[index].Flavour) + { + case TAPI_SS_CB_TYPE_BAOC: + { + callBarringType = CALL_BARRING_ALL_OUTGOING; + } + break; + + case TAPI_SS_CB_TYPE_BOIC: + { + callBarringType = CALL_BARRING_INTERNATIONAL_OUTGOING; + } + break; + + case TAPI_SS_CB_TYPE_BOIC_NOT_HC: + { + callBarringType = CALL_BARRING_INTERNATIONAL_EXCEPT_HOME; + } + break; + + case TAPI_SS_CB_TYPE_BAIC: + { + callBarringType = CALL_BARRING_ALL_INCOMING; + } + break; + + case TAPI_SS_CB_TYPE_BIC_ROAM: + { + callBarringType = CALL_BARRING_INCOMING_ROAMING; + } + break; + + default: + break; + } + //notify event listeners + pSettingsManager->NotifyBarringEventListeners(SET_CALLBARRING_RESPONSE,(result == TAPI_SS_SUCCESS), callBarringType, isActivated); + } + } +} + +int +SettingsManager::GetCallBarringStatus(CallBarringType callBarringType) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null, ERROR_TAPI_INIT_FAILED, "Telephony initialization failed"); + + TelSsBarringType_t barringType; + switch (callBarringType) + { + case CALL_BARRING_ALL_OUTGOING: + { + barringType = TAPI_SS_CB_TYPE_BAOC; + } + break; + + case CALL_BARRING_INTERNATIONAL_OUTGOING: + { + barringType = TAPI_SS_CB_TYPE_BOIC; + } + break; + + case CALL_BARRING_INTERNATIONAL_EXCEPT_HOME: + { + barringType = TAPI_SS_CB_TYPE_BOIC_NOT_HC; + } + break; + + case CALL_BARRING_ALL_INCOMING: + { + barringType = TAPI_SS_CB_TYPE_BAIC; + } + break; + + case CALL_BARRING_INCOMING_ROAMING: + { + barringType = TAPI_SS_CB_TYPE_BIC_ROAM; + } + break; + + default: + { + return ERROR_INVALID_INPUT; + } + break; + } + int retStatus = tel_get_ss_barring_status(__pTapiHandle, TAPI_SS_CLASS_VOICE, barringType, &HandleGetBarringResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + + return errorCode; +} + +void +SettingsManager::HandleGetBarringResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsBarringResp_t* pResponse = (TelSsBarringResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + if (pResponse != null) + { + CallBarringType callBarringType = CALL_BARRING_ALL_OUTGOING; + bool isActivated = false; + int count = pResponse->record_num; + for (int index = 0; index < count; index++) + { + if (pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE) + { + isActivated = true; + } + switch (pResponse->record[index].Flavour) + { + case TAPI_SS_CB_TYPE_BAOC: + { + callBarringType = CALL_BARRING_ALL_OUTGOING; + } + break; + + case TAPI_SS_CB_TYPE_BOIC: + { + callBarringType = CALL_BARRING_INTERNATIONAL_OUTGOING; + } + break; + + case TAPI_SS_CB_TYPE_BOIC_NOT_HC: + { + callBarringType = CALL_BARRING_INTERNATIONAL_EXCEPT_HOME; + } + break; + + case TAPI_SS_CB_TYPE_BAIC: + { + callBarringType = CALL_BARRING_ALL_INCOMING; + } + break; + + case TAPI_SS_CB_TYPE_BIC_ROAM: + { + callBarringType = CALL_BARRING_INCOMING_ROAMING; + } + break; + + default: + break; + } + //notify event listeners + pSettingsManager->NotifyBarringEventListeners(GET_CALLBARRING_RESPONSE,(result == TAPI_SS_SUCCESS), callBarringType, isActivated); + } + } +} + +int +SettingsManager::SetCallWaitingStatus(bool activateWaiting) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null, ERROR_TAPI_INIT_FAILED,"Telephony initialization failed"); + + TelSsWaitingInfo_t waitingInfo; + memset(&waitingInfo, 0, sizeof(TelSsWaitingInfo_t)); + waitingInfo.Class = TAPI_SS_CLASS_VOICE; + if (activateWaiting == true) + { + waitingInfo.Mode = TAPI_SS_CW_MODE_ACTIVATE; + } + else + { + waitingInfo.Mode = TAPI_SS_CW_MODE_DEACTIVATE; + } + int retStatus = tel_set_ss_waiting(__pTapiHandle, &waitingInfo, &HandleSetWaitingResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + + return errorCode; +} + +void +SettingsManager::HandleSetWaitingResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsWaitingResp_t* pResponse = (TelSsWaitingResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + bool isCallSuccessful = false; + if (result == TAPI_SS_SUCCESS) + { + isCallSuccessful = true; + } + if (pResponse != null) + { + + int count = pResponse->record_num; + if (pSettingsManager->__pSettingsEventListener != null) + { + for (int index = 0; index < count; index++) + { + //notify event listeners + bool isCallWaitingEnabled = (pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE); + pSettingsManager->NotifyWaitingEventListeners(SET_CALLWAITING_RESPONSE, isCallSuccessful, isCallWaitingEnabled); + } + } + } +} + +int +SettingsManager::GetCallWaitingStatus(void) +{ + int errorCode = ERROR_NONE; + TryReturn(__pTapiHandle != null, ERROR_TAPI_INIT_FAILED,"Telephony initialization failed"); + + int retStatus = tel_get_ss_waiting_status(__pTapiHandle, TAPI_SS_CLASS_VOICE, &HandleGetWaitingResponse, this); + if (retStatus != TAPI_API_SUCCESS) + { + errorCode = ERROR_TAPI_ERROR; + } + + return errorCode; +} + +void +SettingsManager::HandleGetWaitingResponse(TapiHandle* pHandle, int result, void* pData, void* pUserData) +{ + TelSsWaitingResp_t* pResponse = (TelSsWaitingResp_t*) pData; + SettingsManager* pSettingsManager = (SettingsManager*) pUserData; + if (pResponse != null) + { + bool isCallSuccessful = false; + if (result == TAPI_SS_SUCCESS) + { + isCallSuccessful = true; + } + int count = pResponse->record_num; + if (pSettingsManager->__pSettingsEventListener != null) + { + for (int index = 0; index < count; index++) + { + //notify event listeners + bool isCallWaitingEnabled = (pResponse->record[index].Status == TAPI_SS_STATUS_ACTIVE); + pSettingsManager->NotifyWaitingEventListeners(GET_CALLWAITING_RESPONSE, isCallSuccessful, isCallWaitingEnabled); + } + } + } +} + +IMapT* +SettingsManager::GetRejectMessageListN(void) +{ + int messagesCount; + char* pMessage = null; + HashMapT *pMessageMap = null; + + int retval = vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &messagesCount); + if (retval == 0 && messagesCount > 0) + { + pMessageMap = new (std::nothrow) HashMapT(); + pMessageMap->Construct(messagesCount); + for (int index = 0; index < messagesCount; index++) + { + int keyForMsg = index; + String *pMessageStr = new (std::nothrow) String(); + switch (index) + { + case 0: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR); + } + break; + + case 1: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR); + } + break; + + case 2: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR); + } + break; + + case 3: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR); + } + break; + + case 4: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR); + } + break; + + case 5: + { + pMessage = vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR); + } + break; + + default: + { + delete pMessageMap; + pMessageMap = null; + return null; + } + break; + } + //todo:Chk if this is allowed outside the call settings library + bindtextdomain("ug-setting-call-efl", "/usr/ug/res/locale"); + pMessageStr->Append(dgettext("ug-setting-call-efl", pMessage)); + pMessageMap->Add(keyForMsg, *pMessageStr); + } + } + return pMessageMap; +} + +result +SettingsManager::SetRejectMessage(int messageIndex, const String& rejectMessage) +{ + result r = E_FAILURE; + int messagesCount = 0; + vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &messagesCount); + //convert to char* + const wchar_t* pRejectMessage = rejectMessage.GetPointer(); + int len = (rejectMessage.GetLength()*sizeof(wchar_t)); + char* pMessageToBeSet = new (std::nothrow) char[len + 1]; + memset(pMessageToBeSet, 0, (len + 1) * sizeof(char)); + wcstombs(pMessageToBeSet, pRejectMessage, len); + //save to vconf + int retval = -1; + + switch (messageIndex) + { + case 0: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR, pMessageToBeSet); + } + break; + + case 1: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR, pMessageToBeSet); + } + break; + + case 2: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR, pMessageToBeSet); + } + break; + + case 3: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR, pMessageToBeSet); + } + break; + + case 4: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR, pMessageToBeSet); + } + break; + + case 5: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR, pMessageToBeSet); + } + break; + + default: + { + delete []pMessageToBeSet; + pMessageToBeSet = null; + return r; + } + break; + } + + delete []pMessageToBeSet; + pMessageToBeSet = null; + if (retval == 0) + { + //increment the count only in case of new addition + if (messagesCount < 6 && messageIndex >= messagesCount) + { + messagesCount++; + } + vconf_set_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, messagesCount); + r = E_SUCCESS; + } + + return r; +} + +result +SettingsManager::RemoveRejectMessage(const IListT& deleteKeyList) +{ + result r = E_FAILURE; + int retval = -1; + int newMsgCount = 0; + //Fetch old message count + int oldMsgCount = 0; + vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &oldMsgCount); + //fetch old messages + IMapT *pRejectMsgMap = GetRejectMessageListN(); + if(pRejectMsgMap != null) + { + //First,remove all messages from vconf + for (int index = 0; index < oldMsgCount; index++) + { + switch (index) + { + case 0: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR); + break; + + case 1: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR); + break; + + case 2: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR); + break; + + case 3: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR); + break; + + case 4: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR); + break; + + case 5: + retval = vconf_unset(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR); + break; + } + } + + //Check if all messages are deleted + if(oldMsgCount == deleteKeyList.GetCount()) + { + vconf_set_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, 0); + delete pRejectMsgMap; + return E_SUCCESS; + } + + //Second, delete messages to be deleted from fetched old Message map + for (int index = 0; index < deleteKeyList.GetCount(); index++) + { + int keyForMsg = -1; + if (deleteKeyList.GetAt(index, keyForMsg) == E_SUCCESS) + { + pRejectMsgMap->Remove(keyForMsg); + } + } + + //Third, reset remaining message in vconf with ordered keys + IListT *pRejectMsgList = pRejectMsgMap->GetValuesN(); + newMsgCount = pRejectMsgList->GetCount(); + for (int index = 0; index < newMsgCount; index++) + { + String msg; + pRejectMsgList->GetAt(index,msg); + //convert to char* + const wchar_t* pMsgPtr = msg.GetPointer(); + int len = msg.GetLength()*sizeof(wchar_t); + char* pMessageToBeSet = new (std::nothrow) char[len + 1]; + memset(pMessageToBeSet, 0, (len + 1) * sizeof(char)); + wcstombs(pMessageToBeSet, pMsgPtr, len); + switch (index) + { + case 0: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR, pMessageToBeSet); + } + break; + + case 1: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR, pMessageToBeSet); + } + break; + + case 2: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR, pMessageToBeSet); + } + break; + + case 3: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR, pMessageToBeSet); + } + break; + + case 4: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR, pMessageToBeSet); + } + break; + + case 5: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR, pMessageToBeSet); + } + break; + + default: + break; + } + delete []pMessageToBeSet; + pMessageToBeSet = null; + } + delete pRejectMsgMap; + pRejectMsgMap = null; + } + + //todo: retVal from vconf_unset is always -1. to be checked +// if (retval == 0) + { + //Update message count in vconf + vconf_set_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, newMsgCount); + r = E_SUCCESS; + } + + return r; +} + +IList* +SettingsManager::GetPrefixDialListN(void) +{ + int phoneNumberCount; + char* pPhoneNumber = null; + ArrayList* pPhoneNumberList = null; + + int retval = vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, &phoneNumberCount); + if (retval == 0) + { + pPhoneNumberList = new (std::nothrow) ArrayList(); + for (int index = 0; index < phoneNumberCount; index++) + { + String* phoneNumberStr = new (std::nothrow) String(); + switch (index) + { + case 0: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR); + } + break; + + case 1: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR); + } + break; + + case 2: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR); + } + break; + + case 3: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR); + } + break; + + case 4: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR); + } + break; + + default: + { + delete pPhoneNumberList; + pPhoneNumberList = null; + return null; + } + break; + } + phoneNumberStr->Append(pPhoneNumber); + pPhoneNumberList->Add(*phoneNumberStr); + } + } + else + { + return null; + } + return pPhoneNumberList; +} + +result +SettingsManager::SetPrefixDialNumber(int phoneNumberIndex, const String& phoneNumber) +{ + result r = E_FAILURE; + int phoneNumberCount = 0; + + int retval = -1; + const wchar_t* pRejectMessage = phoneNumber.GetPointer(); + int len = phoneNumber.GetLength(); + char* pTmpPhonePtr = new (std::nothrow) char[len + 1]; + memset(pTmpPhonePtr, 0, (len + 1) * sizeof(char)); + wcstombs(pTmpPhonePtr, pRejectMessage, len); + char* pNumberToBeSet = new (std::nothrow) char[len + 1]; + memset(pNumberToBeSet, 0, (len + 1) * sizeof(char)); + strncpy(pNumberToBeSet, pTmpPhonePtr, len); + delete []pTmpPhonePtr; + pTmpPhonePtr = null; + vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, &phoneNumberCount); + switch (phoneNumberIndex) + { + case 0: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR, pNumberToBeSet); + } + break; + + case 1: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR, pNumberToBeSet); + } + break; + + case 2: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR, pNumberToBeSet); + } + break; + + case 3: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR, pNumberToBeSet); + } + break; + + case 4: + { + retval = vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR, pNumberToBeSet); + } + break; + + default: + { + delete []pNumberToBeSet; + pNumberToBeSet = null; + return r; + } + break; + } + + delete []pNumberToBeSet; + pNumberToBeSet = null; + + if (retval == 0) + { + if (phoneNumberCount < 5) + { + phoneNumberCount++; + } + vconf_set_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, phoneNumberCount); + //todo: change to adding single area code if its prefix number list is supported + + r = E_SUCCESS; + } + + return r; +} + +result +SettingsManager::GetPrefixDialNumberAtIndex(int phoneNumberIndex, String& phoneNumber) +{ + result r = E_FAILURE; + + int phoneNumberCount = 0; + vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, &phoneNumberCount); + + //check valid index + if(phoneNumberCount > 0 && phoneNumberIndex < phoneNumberCount) + { + char* pPhoneNumber = null; + switch (phoneNumberIndex) + { + case 0: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR); + } + break; + + case 1: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR); + } + break; + + case 2: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR); + } + break; + + case 3: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR); + } + break; + + case 4: + { + pPhoneNumber = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR); + } + break; + + default: + break; + } + + if(pPhoneNumber != null) + { + r = phoneNumber.Append(pPhoneNumber); + } + } + return r; +} + +result +SettingsManager::RemovePrefixDialNumber(int phoneNumberIndex) +{ + result r = E_FAILURE; + int phoneNumberCount = 0; + + int retval = -1; + vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, &phoneNumberCount); + switch (phoneNumberIndex) + { + case 0: + { + retval = vconf_unset(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR); + } + break; + + case 1: + { + retval = vconf_unset(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR); + } + break; + + case 2: + { + retval = vconf_unset(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR); + } + break; + + case 3: + { + retval = vconf_unset(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR); + } + break; + + case 4: + { + retval = vconf_unset(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR); + } + break; + + default: + { + return r; + } + break; + } + + //todo: retVal from vconf_unset is always -1. to be checked +// if (retval == 0) + { + if (phoneNumberCount > 0) + { + phoneNumberCount--; + } + vconf_set_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_INT, phoneNumberCount); + r = E_SUCCESS; + } + + return r; +} + +result +SettingsManager::SetPrefixDialingStatus(bool enablePrefixDialing) +{ + result r = E_FAILURE; + int retVal = vconf_set_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, enablePrefixDialing); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::SetActivePrefixDialingValue(int prefixDialIndex) +{ + result r = E_FAILURE; + int retVal = vconf_set_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_VALUE_INT, prefixDialIndex); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::GetActivePrefixDialingValue(int& prefixDialIndex) +{ + result r = E_FAILURE; + int indexPos = -1; + int retVal = vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_VALUE_INT, &indexPos); + if (retVal == 0) + { + prefixDialIndex = indexPos; + r = E_SUCCESS; + } + return r; +} + +bool +SettingsManager::GetPrefixDialingStatus(void) +{ + int isPrefixDialingEnabled = -1; + + vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &isPrefixDialingEnabled); + + bool retVal = isPrefixDialingEnabled; + return retVal; +} + +result +SettingsManager::SetVideoCallImagePath(const String& imagePath) +{ + result r = E_FAILURE; + const wchar_t* pRejectMessage = imagePath.GetPointer(); + int len = imagePath.GetLength(); + char* pTmpPath = new (std::nothrow) char[len + 1]; + memset(pTmpPath, 0, (len + 1) * sizeof(char)); + wcstombs(pTmpPath, pRejectMessage, len); + char* pPathToBeSet = new (std::nothrow) char[len + 1]; + memset(pPathToBeSet, 0, (len + 1) * sizeof(char)); + strncpy(pPathToBeSet, pTmpPath, len); + int retVal = vconf_set_str(VCONFKEY_CISSAPPL_VIDEO_IMAGE_PATH_STR, pPathToBeSet); + if (retVal == 0) + { + r = E_SUCCESS; + } + delete []pTmpPath; + pTmpPath = null; + delete []pPathToBeSet; + pPathToBeSet = null; + return r; +} + +result +SettingsManager::GetVideoCallImagePath(String& imagePath) +{ + result r = E_FAILURE; + char* pVideoImagePath = null; + pVideoImagePath = vconf_get_str(VCONFKEY_CISSAPPL_VIDEO_IMAGE_PATH_STR); + if (pVideoImagePath != null) + { + imagePath.Clear(); + imagePath.Append(pVideoImagePath); + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::SetCallLineIdentity(CallLineIdentity identity) +{ + result r = E_FAILURE; + int retVal = vconf_set_int(VCONFKEY_CISSAPPL_SHOW_MY_NUMBER_INT, identity); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::GetCallLineIdentity(CallLineIdentity& identity) +{ + result r = E_FAILURE; + int lineIdentity = -1; + int retVal = vconf_get_int(VCONFKEY_CISSAPPL_SHOW_MY_NUMBER_INT, &lineIdentity); + if (retVal == 0) + { + identity = (CallLineIdentity) lineIdentity; + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::AddToCallRejectList(const String& phoneNumber, CallRejectMatchCondition rejectCondition) +{ + //construct CallRejectInfo. + CallRejectInfo rejInfo; + rejInfo.phoneNumber = phoneNumber; + rejInfo.rejectCondition = rejectCondition; + rejInfo.isActivated = false; + + //Fetch call reject list + IListT* pRejNumbersList = GetCallRejectList(); + //Check if this is not already present in database. + bool isDuplicate = false; + if (pRejNumbersList != null) + { + IEnumeratorT* pRejectEnum = pRejNumbersList->GetEnumeratorN(); + if (pRejectEnum != null) + { + while (pRejectEnum->MoveNext() == E_SUCCESS) + { + CallRejectInfo fetchedInfo; + if (( pRejectEnum->GetCurrent(fetchedInfo) == E_SUCCESS) && (fetchedInfo == rejInfo)) + { + isDuplicate = true; + } + } + delete pRejectEnum; + } + delete pRejNumbersList; + } + + result r = E_OBJ_ALREADY_EXIST; + if (isDuplicate == false) + { + r = __pCallSettingDataService->AddCallRejectInfoToDatabase(&rejInfo); + } + return r; +} + +IListT* +SettingsManager::GetCallRejectList(void) +{ + int rejectCount = 0; + __pCallSettingDataService->GetCallRejectCount(rejectCount); + + if (rejectCount > 0) + { + ArrayListT* pCallRejectList = new (std::nothrow) ArrayListT(); + pCallRejectList->Construct(rejectCount); + __pCallSettingDataService->GetAllCallRejectInfoFromDatabaseN(*pCallRejectList); + return pCallRejectList; + } + return null; +} + +result +SettingsManager::UpdateCallRejectRow(int rowId, const String& phoneNumber, bool activate, CallRejectMatchCondition rejectCondition) +{ + result r = E_FAILURE; + CallRejectInfo* rejInfo = new (std::nothrow) CallRejectInfo(); + rejInfo->rowId = rowId; + rejInfo->phoneNumber.Append(phoneNumber); + rejInfo->rejectCondition = rejectCondition; + rejInfo->isActivated = activate; + r = __pCallSettingDataService->UpdateCallRejectInfoDatabase(rowId,rejInfo); + delete rejInfo; + return r; +} + +result +SettingsManager::RemoveCallRejectRow(int rowId) +{ + return __pCallSettingDataService->DeleteCallRejectInfoFromDatabase(rowId); +} + +result +SettingsManager::SetUnknownRejectStatus(bool activate) +{ + result r = E_FAILURE; + int retVal = vconf_set_bool(VCONFKEY_CISSAPPL_AUTO_REJECT_UNKNOWN_BOOL, activate); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +bool +SettingsManager::IsCallToBeRejected(String& phoneNumber) +{ + return __pCallSettingDataService->IsCallToBeRejected(phoneNumber); +} + +bool +SettingsManager::GetUnknownRejectStatus(void) +{ + int unknownRejectStatus = -1; + + vconf_get_bool(VCONFKEY_CISSAPPL_AUTO_REJECT_UNKNOWN_BOOL, &unknownRejectStatus); + + bool retVal = unknownRejectStatus; + return retVal; +} + +result +SettingsManager::SetCallAlertStatus(CallAlertStatus callAlertStatus) +{ + result r = E_FAILURE; + int retVal = vconf_set_int(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, callAlertStatus); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::GetCallAlertStatus(CallAlertStatus& callAlertStatus) +{ + result r = E_FAILURE; + int alertStatus = -1; + int retVal = vconf_get_int(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, &alertStatus); + if (retVal == 0) + { + callAlertStatus = (CallAlertStatus) alertStatus; + r = E_SUCCESS; + } + return r; +} + +result +SettingsManager::SetCallConnectToneStatus(bool activate) +{ + result r = E_FAILURE; + int retVal = vconf_set_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, activate); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +bool +SettingsManager::GetCallConnectToneStatus(void) +{ + int unknownRejectStatus = -1; + + vconf_get_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, &unknownRejectStatus); + + bool retVal = unknownRejectStatus; + return retVal; +} + +result +SettingsManager::SetMinuteMinderToneStatus(bool activate) +{ + result r = E_FAILURE; + int retVal = vconf_set_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, activate); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +bool +SettingsManager::GetMinuteMinderToneStatus(void) +{ + int unknownRejectStatus = -1; + + vconf_get_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, &unknownRejectStatus); + + bool retVal = unknownRejectStatus; + return retVal; +} + +result +SettingsManager::SetCallEndToneStatus(bool activate) +{ + result r = E_FAILURE; + int retVal = vconf_set_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, activate); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + +bool +SettingsManager::GetCallEndToneStatus(void) +{ + int unknownRejectStatus = -1; + + vconf_get_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, &unknownRejectStatus); + + bool retVal = unknownRejectStatus; + return retVal; +} + +result +SettingsManager::SetSpeedDialMapping(const String& contactId, int numberToMap) +{ + result r = E_FAILURE; + SpeedDialInfo mappingInfo;; + mappingInfo.keyMapping = numberToMap; + mappingInfo.contactId = contactId; + r = __pCallSettingDataService->AddSpeedDialInfoToDatabase(&mappingInfo); + return r; +} + +IMapT* +SettingsManager::GetSpeedDialMappingN(void) +{ + return (__pCallSettingDataService->GetAllSpeedDialInfoMapFromDatabaseN()); +} + +result +SettingsManager::RemoveSpeedDialMapping(int rowId) +{ + return __pCallSettingDataService->DeleteSpeedDialInfoFromDatabase(rowId); +} + +result +SettingsManager::UpdateSpeedDialMapping(int rowId, const String& contactId, int numberToMap) +{ + result r = E_FAILURE; + SpeedDialInfo* mappingInfo = new (std::nothrow) SpeedDialInfo(); + mappingInfo->rowId = rowId; + mappingInfo->contactId.Append(contactId); + mappingInfo->keyMapping = numberToMap; + r = __pCallSettingDataService->UpdateSpeedDialInfoDatabase(rowId,mappingInfo); + delete mappingInfo; + return r; +} + +String* +SettingsManager::GetMappedSpeedDialNumberN(int aIndex) +{ + String* contactNumber = null; + + //Fetch contactId for mapped speed dial + String* contactId = __pCallSettingDataService->GetSpeedDialContactN(aIndex); + if(contactId != null && contactId->IsEmpty() == false) + { + RecordId recordId = INVALID_RECORD_ID; + Integer::Parse(*contactId, recordId); + //check if recordId is correct + if (recordId != Tizen::Social::INVALID_RECORD_ID) + { + AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); + Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); + if (pAddressbook != null) + { + Contact* pMappedContact = pAddressbook->GetContactN(recordId); + if (pMappedContact != null) + { + IList* pPhoneNumberList = pMappedContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + if (pPhoneNumberList != null) + { + PhoneNumber* pPhoneNumber = static_cast(pPhoneNumberList->GetAt(0)); + if(pPhoneNumber != null) + { + contactNumber = new (std::nothrow) String(pPhoneNumber->GetPhoneNumber()); + } + pPhoneNumberList->RemoveAll(true); + delete pPhoneNumberList; + } + delete pMappedContact; + } + delete pAddressbook; + } + } + } + delete contactId; + contactId = null; + return contactNumber; +} + +Contact* +SettingsManager::FetchContactDetailsN(const String& contactId) +{ + Contact* pFetchedContact = null; + + RecordId recordId = INVALID_RECORD_ID; + Integer::Parse(contactId, recordId); + //check if recordId is correct + if (recordId != Tizen::Social::INVALID_RECORD_ID) + { + AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); + Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); + if (pAddressbook != null) + { + pFetchedContact = pAddressbook->GetContactN(recordId); + delete pAddressbook; + } + } + return pFetchedContact; +} + +result +SettingsManager::SetCallState(CallState callState) +{ + AppLogDebug("Enter %d",callState); + result r = E_FAILURE; + int retVal = vconf_set_int(VCONFKEY_CALL_STATE, callState); + if (retVal == 0) + { + r = E_SUCCESS; + } + return r; +} + diff --git a/src/PhnSettingsMoreOptionsForm.cpp b/src/PhnSettingsMoreOptionsForm.cpp new file mode 100644 index 0000000..8c0b905 --- /dev/null +++ b/src/PhnSettingsMoreOptionsForm.cpp @@ -0,0 +1,887 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsMoreOptionsForm.cpp + * @brief Setting More option form + */ +#include +#include "PhnSettingsMoreOptionsForm.h" +#include "PhnSettingsConstants.h" +#include "PhnAppUtility.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; + +static const wchar_t* IDL_SETTINGS_MOREOPTIONS_FORM = L"IDL_SETTINGS_MOREOPTIONS_FORM"; + +SettingsMoreOptionsForm::SettingsMoreOptionsForm(void) + : __pSettingsPresentor(null) + , __isCallerIdExpanded(false) + , __isCallAlertExpanded(false) + , __autoAreaCode(L"") +{ +} + +SettingsMoreOptionsForm::~SettingsMoreOptionsForm(void) +{ +} + +bool +SettingsMoreOptionsForm::Initialize(void) +{ + Construct(IDL_SETTINGS_MOREOPTIONS_FORM); + return true; +} + +result +SettingsMoreOptionsForm::OnInitializing(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + // Setup back event listener + SetFormBackEventListener(this); + //Footer + Footer* pFooter = GetFooter(); + if (pFooter) + { + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + pFooter->AddActionEventListener(*this); + } + //Initialize list view + r = InitializeGroupedTableView(); + return r; +} + +result +SettingsMoreOptionsForm::OnTerminating(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = null; + return r; +} + +void +SettingsMoreOptionsForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + default: + break; + } +} + +void +SettingsMoreOptionsForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MAIN_SETTING_MENU), null); +} + +void +SettingsMoreOptionsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + __autoAreaCode.Clear(); + GroupedTableView* pMoreOptionsTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if(__pSettingsPresentor != null && pMoreOptionsTableView != null) + { + //set status for 'GROUP_CALLERID_OPTIONS' + CallLineIdentity lineIdentity; + __pSettingsPresentor->GetCallLineIdentity(lineIdentity); + pMoreOptionsTableView->SetItemChecked(GROUP_CALLERID_OPTIONS, (GroupCallerIdOptionsItems) lineIdentity, true); + pMoreOptionsTableView->RefreshItem(GROUP_CALLERID, CALLERID_CALLER_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + + //set status for 'GROUP_CALL_ALERT_OPTIONS' + CallAlertStatus alertStatus; + __pSettingsPresentor->GetCallAlertStatus(alertStatus); + pMoreOptionsTableView->SetItemChecked(GROUP_CALL_ALERT_OPTIONS, (GroupCallAlertOptionsItems) alertStatus, true); + pMoreOptionsTableView->RefreshItem(GROUP_CALL_ALERT, CALLALERT_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + + //update auto area code status + result r = __pSettingsPresentor->GetActivePrefixDialNumber(__autoAreaCode); + pMoreOptionsTableView->RefreshItem(GROUP_AREACODE, AREACODE_AUTO_AREA_CODE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + if(r == E_SUCCESS && __autoAreaCode.IsEmpty() == false) + { + pMoreOptionsTableView->SetItemChecked(GROUP_AREACODE, AREACODE_AUTO_AREA_CODE, true); + } + else + { + pMoreOptionsTableView->SetItemChecked(GROUP_AREACODE, AREACODE_AUTO_AREA_CODE, false); + } + } +} + +void +SettingsMoreOptionsForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +result +SettingsMoreOptionsForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pMoreOptionsTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMoreOptionsTableView != null) + { + pMoreOptionsTableView->SetGroupedLookEnabled(true); + pMoreOptionsTableView->SetItemProvider(this); + r = pMoreOptionsTableView->AddGroupedTableViewItemEventListener(*this); + pMoreOptionsTableView->UpdateTableView(); + CollapseSelectiveGroups(pMoreOptionsTableView); + } + return r; +} + +void +SettingsMoreOptionsForm::CollapseSelectiveGroups(GroupedTableView* pMoreOptionsTableView) +{ + //This function should be called only from "InitializeGroupedTableView()". + //since collapsing individual groups while GroupTableView construction causes flicker. + pMoreOptionsTableView->CollapseAllGroup(); + //Expand other groups + pMoreOptionsTableView->ExpandGroup(GROUP_CALLERID); + pMoreOptionsTableView->ExpandGroup(GROUP_CALL_SETTINGS); + pMoreOptionsTableView->ExpandGroup(GROUP_CALL_SETTINGS_HLPTXT); + pMoreOptionsTableView->ExpandGroup(GROUP_CALL_REMINDER); + pMoreOptionsTableView->ExpandGroup(GROUP_CALL_REMINDER_HLPTXT); + pMoreOptionsTableView->ExpandGroup(GROUP_CALL_ALERT); + pMoreOptionsTableView->ExpandGroup(GROUP_AREACODE); + pMoreOptionsTableView->ExpandGroup(GROUP_AREACODE_HLPTXT); + pMoreOptionsTableView->UpdateTableView(); +} + +void +SettingsMoreOptionsForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + switch (groupIndex) + { + case GROUP_CALLERID: + { + if (tableView.IsGroupExpanded(GROUP_CALLERID_OPTIONS)) + { + tableView.CollapseGroup(GROUP_CALLERID_OPTIONS); + __isCallerIdExpanded = false; + } + else + { + tableView.ExpandGroup(GROUP_CALLERID_OPTIONS); + __isCallerIdExpanded = true; + } + //Change icon + tableView.RefreshItem(GROUP_CALLERID, CALLERID_CALLER_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + break; + + case GROUP_CALLERID_OPTIONS: + { + HandleSelectedCallerIdOptions(tableView, itemIndex, status); + } + break; + + case GROUP_CALL_ALERT: + { + if (tableView.IsGroupExpanded(GROUP_CALL_ALERT_OPTIONS)) + { + tableView.CollapseGroup(GROUP_CALL_ALERT_OPTIONS); + __isCallAlertExpanded = false; + } + else + { + tableView.ExpandGroup(GROUP_CALL_ALERT_OPTIONS); + __isCallAlertExpanded = true; + } + //Change icon + tableView.RefreshItem(GROUP_CALL_ALERT, CALLALERT_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + break; + + case GROUP_CALL_ALERT_OPTIONS: + { + HandleSelectedCallAlertOptions(tableView, itemIndex, status); + } + break; + + case GROUP_CALL_SETTINGS: + case GROUP_CALL_REMINDER: + case GROUP_AREACODE: + { + HandleSelectedSettings(groupIndex, itemIndex); + } + break; + + default: + break; + } +} + +int +SettingsMoreOptionsForm::GetGroupCount(void) +{ + return GROUP_TOTALCOUNT; +} + +int +SettingsMoreOptionsForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case GROUP_CALLERID: + { + itemCount = CALLERID_TOTALCOUNT; + } + break; + + case GROUP_CALLERID_OPTIONS: + { + itemCount = CALLEROPTIONS_TOTALCOUNT; + } + break; + + case GROUP_CALL_SETTINGS: + { + itemCount = CALLSETTINGS_TOTALCOUNT; + } + break; + + case GROUP_CALL_REMINDER: + { + itemCount = CALLREMINDER_TOTALCOUNT; + } + break; + + case GROUP_CALL_ALERT: + { + itemCount = CALLALERT_TOTALCOUNT; + } + break; + + case GROUP_CALL_ALERT_OPTIONS: + { + itemCount = CALLALERT_OPTIONS_TOTALCOUNT; + } + break; + + case GROUP_AREACODE: + { + itemCount = AREACODE_TOTALCOUNT; + } + break; + + case GROUP_CALL_SETTINGS_HLPTXT: + case GROUP_CALL_REMINDER_HLPTXT: + case GROUP_AREACODE_HLPTXT: + { + itemCount = 0; + } + break; + + default: + break; + } + return itemCount; +} + +TableViewGroupItem* +SettingsMoreOptionsForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + String helpText(L""); + switch (groupIndex) + { + case GROUP_CALL_SETTINGS_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_WAITING_HLP_STRING)); + } + break; + + case GROUP_CALL_REMINDER_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_STATUS_TONES_HLP_STRING)); + } + break; + + case GROUP_AREACODE_HLPTXT: + { + helpText.Append(AppUtility::GetResourceString(IDS_SETTING_AUTO_AREACODE_HLP_STRING)); + } + break; + + default: + break; + } + + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + if (helpText.IsEmpty() == true) + { + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + } + else + { + pItem->Construct(Dimension(itemWidth, H_LIST_MENU_SINGLELINE_HLPTXT_ITEM)); + //help text item rectangle + Rectangle helpItemRect(X_LIST_MENU_HLPTXT_ITEM, Y_LIST_MENU_HLPTXT_ITEM, + (itemWidth - X_LIST_MENU_HLPTXT_ITEM), (H_LIST_MENU_SINGLELINE_HLPTXT_ITEM - Y_LIST_MENU_HLPTXT_ITEM)); + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(helpItemRect, helpText); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_HELP_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_HELP_TXT); + pItem->AddControl(*pItemLbl); + pItem->SetEnabled(false); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + } + + return pItem; +} + +bool +SettingsMoreOptionsForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsMoreOptionsForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsMoreOptionsForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewItem* pItem = null; + + switch (groupIndex) + { + case GROUP_CALLERID: + case GROUP_CALL_ALERT: + { + pItem = CreateExpandableItem(groupIndex, itemIndex, itemWidth); + } + break; + + case GROUP_CALLERID_OPTIONS: + { + pItem = CreateCallerIdOptionsItem(itemIndex, itemWidth); + } + break; + + case GROUP_CALL_ALERT_OPTIONS: + { + pItem = CreateCallerAlertOptionsItem(itemIndex, itemWidth); + + } + break; + + case GROUP_CALL_SETTINGS: + case GROUP_CALL_REMINDER: + case GROUP_AREACODE: + { + pItem = CreateSettingMenuItem(groupIndex, itemIndex, itemWidth); + } + break; + + default: + break; + } + return pItem; +} + +bool +SettingsMoreOptionsForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsMoreOptionsForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + if(groupIndex == GROUP_CALLERID || groupIndex == GROUP_CALL_ALERT) + { + String subText(L""); + bool isExpanded = false; + switch (groupIndex) + { + case GROUP_CALLERID: + { + subText.Append(FetchSubTextForSelectedCallerId()); + isExpanded = __isCallerIdExpanded; + } + break; + + case GROUP_CALL_ALERT: + { + subText.Append(FetchSubTextForSelectedCallerAlert()); + isExpanded = __isCallAlertExpanded; + } + break; + } + //sub text item + Label* pSubTxtLbl = static_cast(pItem->GetControl(IDC_SELECTEDOPTION_SUBTEXT_LABEL, true)); + pSubTxtLbl->SetText(subText); + pSubTxtLbl->Invalidate(true); + //set Drop-down icon to item + SetExpandIconToItem(pItem, isExpanded); + pItem->Invalidate(true); + } + else if(groupIndex == GROUP_AREACODE) + { + if(__autoAreaCode.IsEmpty() == true) + { + __autoAreaCode.Append(AppUtility::GetResourceString(IDS_NOT_ASSIGNED_STR)); + } + //sub text item + Label* pSubTxtLbl = static_cast(pItem->GetControl(IDC_SELECTEDOPTION_SUBTEXT_LABEL, true)); + pSubTxtLbl->SetText(__autoAreaCode); + pSubTxtLbl->Invalidate(true); + pItem->Invalidate(true); + } +} + +int +SettingsMoreOptionsForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsMoreOptionsForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} + +TableViewItem* +SettingsMoreOptionsForm::CreateExpandableItem(int groupIndex, int itemIndex, int itemWidth) +{ + String mainText(L""); + String subText(L""); + + switch (groupIndex) + { + case GROUP_CALLERID: + { + mainText.Append(AppUtility::GetResourceString(IDS_SETTING_CALLERID_MAIN_STR)); + subText.Append(FetchSubTextForSelectedCallerId()); + } + break; + + case GROUP_CALL_ALERT: + { + mainText.Append(AppUtility::GetResourceString(IDS_SETTING_CALL_ALERT_MAIN_STR)); + subText.Append(FetchSubTextForSelectedCallerAlert()); + } + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_DROPDOWN_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + + //main text item + Rectangle mainItemRect(X_LIST_MENU_TEXT_ITEM, Y_LIST_MENU_TEXT_ITEM, (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), + H_LIST_DROPDOWN_TXT_ITEM); + Label* pMainTxtLbl = new (std::nothrow) Label(); + pMainTxtLbl->Construct(mainItemRect, mainText); + pMainTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pMainTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pMainTxtLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pMainTxtLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT); + pItem->AddControl(*pMainTxtLbl); + + //sub text item + Rectangle subItemRect(X_LIST_MENU_TEXT_ITEM, (Y_LIST_MENU_TEXT_ITEM + H_LIST_DROPDOWN_TXT_ITEM), + (itemWidth - (2 * X_LIST_MENU_TEXT_ITEM) - W_EXPAND_ICON), H_LIST_DROPDOWN_TXT_ITEM); + Label* pSubTxtLbl = new (std::nothrow) Label(); + pSubTxtLbl->Construct(subItemRect, subText); + pSubTxtLbl->SetName(IDC_SELECTEDOPTION_SUBTEXT_LABEL); + pSubTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pSubTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pSubTxtLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pSubTxtLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pSubTxtLbl); + + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + //set Drop-down icon to item + SetExpandIconToItem(pItem, true); + return pItem; +} + +String +SettingsMoreOptionsForm::FetchSubTextForSelectedCallerId() +{ + //default text + String subText(L""); + CallLineIdentity lineIdentity; + __pSettingsPresentor->GetCallLineIdentity(lineIdentity); + //Fetch text for selected item + GroupCallerIdOptionsItems selectedIndex = (GroupCallerIdOptionsItems)lineIdentity; + switch(selectedIndex) + { + case CALLEROPTIONS_BY_NETWORK: + subText.Append(AppUtility::GetResourceString(IDS_CALLERID_BYNETWORK_STRING)); + break; + + case CALLEROPTIONS_SHOW: + subText.Append(AppUtility::GetResourceString(IDS_CALLERID_SHOW_STRING)); + break; + + case CALLEROPTIONS_HIDE: + subText.Append(AppUtility::GetResourceString(IDS_CALLERID_HIDE_STRING)); + break; + + default: + break; + } + return subText; +} + +String +SettingsMoreOptionsForm::FetchSubTextForSelectedCallerAlert() +{ + //default text + String subText(L""); + CallAlertStatus alertStatus; + __pSettingsPresentor->GetCallAlertStatus(alertStatus); + //Fetch text for selected item + GroupCallAlertOptionsItems selectedIndex = (GroupCallAlertOptionsItems) alertStatus; + switch(selectedIndex) + { + case CALLALERT_OPTIONS_OFF: + subText.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_OFF_STRING)); + break; + + case CALLALERT_OPTIONS_SOUND: + subText.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_SOUND_STRING)); + break; + + case CALLALERT_OPTIONS_VIBRATION: + subText.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_VIBRATE_STRING)); + break; + + default: + break; + } + return subText; +} + + + +void +SettingsMoreOptionsForm::SetExpandIconToItem(TableViewItem* pItem, bool isExpanded) +{ + Bitmap* pNormalIcon = null; + Bitmap* pPressIcon = null; + + if (!isExpanded) + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_EXPAND_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + else + { + pNormalIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED, W_EXPAND_ICON, H_EXPAND_ICON); + pPressIcon = AppUtility::GetBitmapFromResourcesN(IDB_LIST_OPENED_PRESSED, W_EXPAND_ICON, H_EXPAND_ICON); + } + + int itemWidth = pItem->GetWidth(); + Rectangle iconRect((itemWidth - W_EXPAND_ICON - X_LIST_MENU_TEXT_ITEM), + ((H_LIST_DROPDOWN_MENU_ITEM - H_EXPAND_ICON) / 2), W_EXPAND_ICON, H_EXPAND_ICON); + //for drawing blue bg header rectangle on left side. + Rectangle blueHeaderRect(0,0,W_LEFT_HEADER_EXPAND_ITEMS,pItem->GetHeight()); + //normal canvas + Canvas* pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pNormalIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + Bitmap* pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + delete pBgCanvas; + delete pActualBgBmp; + + //pressed canvas + pBgCanvas = new (std::nothrow) Canvas(); + pBgCanvas->Construct(Rectangle(0,0, pItem->GetBounds().width, pItem->GetBounds().height)); + pBgCanvas->DrawBitmap(iconRect, *pPressIcon); + pBgCanvas->FillRectangle(COLOR_LEFT_HEADER_EXPAND_ITEMS, blueHeaderRect); + pActualBgBmp = new (std::nothrow) Bitmap(); + pActualBgBmp->Construct(*pBgCanvas,pBgCanvas->GetBounds()); + pItem->SetBackgroundBitmap(pActualBgBmp, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + delete pBgCanvas; + delete pActualBgBmp; + + delete pNormalIcon; + pNormalIcon = null; + delete pPressIcon; + pPressIcon = null; +} + +TableViewItem* +SettingsMoreOptionsForm::CreateCallerIdOptionsItem(int itemIndex, int itemWidth) +{ + //create a new item + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_RADIO); + pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //text item rectangle + Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + //Option item name + String itemName(L""); + switch (itemIndex) + { + case CALLEROPTIONS_BY_NETWORK: + itemName.Append(AppUtility::GetResourceString(IDS_CALLERID_BYNETWORK_STRING)); + break; + + case CALLEROPTIONS_SHOW: + itemName.Append(AppUtility::GetResourceString(IDS_CALLERID_SHOW_STRING)); + break; + + case CALLEROPTIONS_HIDE: + itemName.Append(AppUtility::GetResourceString(IDS_CALLERID_HIDE_STRING)); + break; + } + + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + + return pItem; +} + +TableViewItem* +SettingsMoreOptionsForm::CreateCallerAlertOptionsItem(int itemIndex, int itemWidth) +{ + //create a new item + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_RADIO); + pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + //text item rectangle + Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + //Option item name + String itemName(L""); + switch (itemIndex) + { + case CALLALERT_OPTIONS_OFF: + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_OFF_STRING)); + break; + + case CALLALERT_OPTIONS_SOUND: + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_SOUND_STRING)); + break; + + case CALLALERT_OPTIONS_VIBRATION: + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CALLALERT_VIBRATE_STRING)); + break; + } + + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + return pItem; +} + +TableViewItem* +SettingsMoreOptionsForm::CreateSettingMenuItem(int groupIndex, int itemIndex, int itemWidth) +{ + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + + String itemName(L""); + String subText(L""); + if(groupIndex == GROUP_CALL_SETTINGS) + { + switch (itemIndex) + { + case CALLSETTINGS_CALL_BARRING: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_BARRING_STRING)); + } + break; + + case CALLSETTINGS_CALL_WAITING: + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_WAITING_STRING)); + } + break; + + default: + break; + } + } + else if(groupIndex == GROUP_CALL_REMINDER) + { + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_STATUS_TONES_STRING)); + } + else if(groupIndex == GROUP_AREACODE) + { + style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + itemName.Append(AppUtility::GetResourceString(IDS_SETTING_AUTO_AREACODE_STRING)); + if(__autoAreaCode.IsEmpty() == true) + { + subText.Append(AppUtility::GetResourceString(IDS_NOT_ASSIGNED_STR)); + } + else + { + subText.Append(__autoAreaCode); + } + //update itemName rectangle + itemNameRect.y = Y_LIST_MENU_TEXT_ITEM; + itemNameRect.height = H_LIST_NORMAL_TXT_ITEM; + itemNameRect.width = (itemWidth - X_LIST_MENU_TEXT_ITEM - W_SLIDER_ICON); + } + + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), style); + + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT + pItem->AddControl(*pItemLbl); + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + if(subText.IsEmpty() == false) + { + //sub text item + Rectangle subItemRect(X_LIST_MENU_TEXT_ITEM, (Y_LIST_MENU_TEXT_ITEM + H_LIST_NORMAL_TXT_ITEM), + (itemWidth - X_LIST_MENU_TEXT_ITEM - W_SLIDER_ICON), H_LIST_SUB_TXT_ITEM); + Label* pSubTxtLbl = new (std::nothrow) Label(); + pSubTxtLbl->Construct(subItemRect, subText); + pSubTxtLbl->SetName(IDC_SELECTEDOPTION_SUBTEXT_LABEL); + pSubTxtLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pSubTxtLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pSubTxtLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pSubTxtLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pSubTxtLbl); + } + + return pItem; +} + +void +SettingsMoreOptionsForm::HandleSelectedCallerIdOptions(GroupedTableView& tableView, int itemIndex, TableViewItemStatus state) +{ + //check if already checked item is selected + if(state == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + tableView.SetItemChecked(GROUP_CALLERID_OPTIONS, itemIndex, true); + return; + } + //uncheck previous selection + CallLineIdentity oldLineIdentity; + __pSettingsPresentor->GetCallLineIdentity(oldLineIdentity); + tableView.SetItemChecked(GROUP_CALLERID_OPTIONS, oldLineIdentity, false); + tableView.RefreshItem(GROUP_CALLERID_OPTIONS, oldLineIdentity, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + + //send information to network / save data for checked item index. + CallLineIdentity updateLineIndentity = (CallLineIdentity)itemIndex; + __pSettingsPresentor->SetCallLineIdentity(updateLineIndentity); + //update status for group + tableView.RefreshItem(GROUP_CALLERID, CALLERID_CALLER_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); +} + +void +SettingsMoreOptionsForm::HandleSelectedCallAlertOptions(GroupedTableView& tableView, int itemIndex, TableViewItemStatus state) +{ + //check if already checked item is selected + if(state == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + tableView.SetItemChecked(GROUP_CALL_ALERT_OPTIONS, itemIndex, true); + return; + } + //uncheck previous selection + CallAlertStatus oldAlertStatus; + __pSettingsPresentor->GetCallAlertStatus(oldAlertStatus); + tableView.SetItemChecked(GROUP_CALL_ALERT_OPTIONS, oldAlertStatus, false); + tableView.RefreshItem(GROUP_CALL_ALERT_OPTIONS, oldAlertStatus, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + + //send information to network / save data for checked item index. + CallAlertStatus updateAlertStatus = (CallAlertStatus)itemIndex; + __pSettingsPresentor->SetCallAlertStatus(updateAlertStatus); + //update status for group + tableView.RefreshItem(GROUP_CALL_ALERT, CALLALERT_SETTING, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); +} + +void +SettingsMoreOptionsForm::HandleSelectedSettings(int groupIndex, int itemIndex) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (groupIndex) + { + case GROUP_CALL_SETTINGS: + { + if(itemIndex == CALLSETTINGS_CALL_BARRING) + { + //switch to form - CALLSETTINGS_CALL_BARRING + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALLTYPE_BARRING), null); + } + else + { + //switch to form - CALLSETTINGS_CALL_WAITING + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_WAITING_OPTIONS), null); + } + } + break; + + case GROUP_CALL_REMINDER: + { + //switch to form - CALLREMINDER_STATUS_TONES + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_STATUSTONES), null); + } + break; + + case GROUP_AREACODE: + { + //switch to form - AREACODE_AUTO_AREA_CODE + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_AUTO_AREA_CODE), null); + } + break; + + default: + break; + } +} diff --git a/src/PhnSettingsPresentationModel.cpp b/src/PhnSettingsPresentationModel.cpp new file mode 100644 index 0000000..1665162 --- /dev/null +++ b/src/PhnSettingsPresentationModel.cpp @@ -0,0 +1,385 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsPresentationModel.cpp + * @brief Setting Presentation model + */ +#include "PhnSettingsConstants.h" +#include "PhnSettingsManager.h" +#include "PhnSettingsPresentationModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Social; + +SettingsPresentationModel* SettingsPresentationModel::__pInstance = null; + +SettingsPresentationModel::SettingsPresentationModel() +{ + __pSettingsMgr = null; + __pSettingsEventListener = null; +} + +SettingsPresentationModel::~SettingsPresentationModel() +{ +} + +void +SettingsPresentationModel::CreateInstance(void) +{ + __pInstance = new (std::nothrow) SettingsPresentationModel(); + result r = __pInstance->Construct(); + if(IsFailed(r)) + { + delete __pInstance; + __pInstance = null; + return; + } + atexit(&(SettingsPresentationModel::DestroyInstance)); +} + +SettingsPresentationModel* +SettingsPresentationModel::GetInstance(void) +{ + if (__pInstance == null) + { + CreateInstance(); + } + return __pInstance; +} + +void +SettingsPresentationModel::DestroyInstance(void) +{ + if (__pInstance->__pSettingsMgr != null) + { + __pInstance->__pSettingsMgr->RemoveSettingEventListener(__pInstance); + __pInstance->__pSettingsMgr = null; + } + delete __pInstance; +} + +result +SettingsPresentationModel::Construct(void) +{ + //Construct Settings Manager + __pSettingsMgr = SettingsManager::GetInstance(); + __pSettingsMgr->AddSettingEventListener(this); + return E_SUCCESS; +} + +result +SettingsPresentationModel::AddSettingEventListener(ISettingsEventListener* pSettingsEventListener) +{ + result r = E_FAILURE; + if (__pSettingsEventListener == null && pSettingsEventListener != null) + { + __pSettingsEventListener = pSettingsEventListener; + r = E_SUCCESS; + } + return r; +} + +void +SettingsPresentationModel::RemoveSettingEventListener(void) +{ + __pSettingsEventListener = null; +} + +IMapT* +SettingsPresentationModel::GetRejectMessageListN(void) +{ + return __pSettingsMgr->GetRejectMessageListN(); +} + +result +SettingsPresentationModel::AddToCallRejectList(const String& phoneNumber, CallRejectMatchCondition rejectCondition) +{ + return __pSettingsMgr->AddToCallRejectList(phoneNumber, rejectCondition); +} + +IListT* +SettingsPresentationModel::GetCallRejectList(void) +{ + return __pSettingsMgr->GetCallRejectList(); +} + +result +SettingsPresentationModel::SetPrefixDialNumber(int phoneNumberIndex, const String& phoneNumber) +{ + return __pSettingsMgr->SetPrefixDialNumber(phoneNumberIndex, phoneNumber); +} + +result +SettingsPresentationModel::SetActivePrefixDialingValue(int prefixDialIndex) +{ + return __pSettingsMgr->SetActivePrefixDialingValue(prefixDialIndex); +} + +result +SettingsPresentationModel::SetPrefixDialingStatus(bool enablePrefixDialing) +{ + return __pSettingsMgr->SetPrefixDialingStatus(enablePrefixDialing); +} + +result +SettingsPresentationModel::GetActivePrefixDialNumber(Tizen::Base::String& phoneNumber) +{ + result r = E_FAILURE; + if(__pSettingsMgr->GetPrefixDialingStatus() == true) + { + int activePrefixIndex = -1; + //fetch active prefix index + r = __pSettingsMgr->GetActivePrefixDialingValue(activePrefixIndex); + TryReturn(r == E_SUCCESS, r, "Error while fetching Active Prefix Dialing Index"); + + //fetch phone number mapped to fetched index + r = __pSettingsMgr->GetPrefixDialNumberAtIndex(activePrefixIndex, phoneNumber); + } + return r; +} + +int +SettingsPresentationModel::SetCallBarringStatus(const String& password, CallBarringType callBarringType, bool activateBarring) +{ + return __pSettingsMgr->SetCallBarringStatus(password, callBarringType, activateBarring); +} + +int +SettingsPresentationModel::GetCallForwardStatus(CallForwardCondition callFwdCondition) +{ + return __pSettingsMgr->GetCallForwardStatus(callFwdCondition); +} + +int +SettingsPresentationModel::SetCallForwardStatus(const String& phoneNumber, CallForwardCondition callFwdCondition, bool activateFwding, int noReplyTime) +{ + return __pSettingsMgr->SetCallForwardStatus(phoneNumber, callFwdCondition, activateFwding, noReplyTime); +} + +int +SettingsPresentationModel::GetCallBarringStatus(CallBarringType callBarringType) +{ + return __pSettingsMgr->GetCallBarringStatus(callBarringType); +} + +int +SettingsPresentationModel::SetCallWaitingStatus(bool activateWaiting) +{ + return __pSettingsMgr->SetCallWaitingStatus(activateWaiting); +} + +int +SettingsPresentationModel::GetCallWaitingStatus(void) +{ + return __pSettingsMgr->GetCallWaitingStatus(); +} + +result +SettingsPresentationModel::SetCallConnectToneStatus(bool activate) +{ + return __pSettingsMgr->SetCallConnectToneStatus(activate); +} +bool +SettingsPresentationModel::GetCallConnectToneStatus(void) +{ + return __pSettingsMgr->GetCallConnectToneStatus(); +} + +result +SettingsPresentationModel::SetMinuteMinderToneStatus(bool activate) +{ + return __pSettingsMgr->SetMinuteMinderToneStatus(activate); +} + +bool +SettingsPresentationModel::GetMinuteMinderToneStatus(void) +{ + return __pSettingsMgr->GetMinuteMinderToneStatus(); +} + +result +SettingsPresentationModel::SetCallEndToneStatus(bool activate) +{ + return __pSettingsMgr->SetCallEndToneStatus(activate); +} + +bool +SettingsPresentationModel::GetCallEndToneStatus(void) +{ + return __pSettingsMgr->GetCallEndToneStatus(); +} + +result +SettingsPresentationModel::UpdateCallRejectRow(int rowId, const String& phoneNumber, bool activate, CallRejectMatchCondition rejectCondition) +{ + return __pSettingsMgr->UpdateCallRejectRow(rowId, phoneNumber, activate, rejectCondition); +} + +result +SettingsPresentationModel::RemoveCallRejectRow(int rowId) +{ + return __pSettingsMgr->RemoveCallRejectRow(rowId); +} + +result +SettingsPresentationModel::SetRejectMessage(int messageIndex, const String& rejectMessage) +{ + return __pSettingsMgr->SetRejectMessage(messageIndex, rejectMessage); +} + +result +SettingsPresentationModel::RemoveRejectMessage(const Tizen::Base::Collection::IListT& deleteKeyList) +{ + return __pSettingsMgr->RemoveRejectMessage(deleteKeyList); +} + +result +SettingsPresentationModel::SetSpeedDialMapping(const String& contactId, int numberToMap) +{ + return __pSettingsMgr->SetSpeedDialMapping(contactId,numberToMap); +} + +IMapT* +SettingsPresentationModel::GetSpeedDialMappingN(void) +{ + return __pSettingsMgr->GetSpeedDialMappingN(); +} + +bool +SettingsPresentationModel::IsCallToBeRejected(Tizen::Base::String& phoneNumber) +{ + return __pSettingsMgr->IsCallToBeRejected(phoneNumber); +} + +result +SettingsPresentationModel::RemoveSpeedDialMapping(int rowId) +{ + return __pSettingsMgr->RemoveSpeedDialMapping(rowId); +} + +result +SettingsPresentationModel::UpdateSpeedDialMapping(int rowId, const String& contactId, int numberToMap) +{ + return __pSettingsMgr->UpdateSpeedDialMapping(rowId, contactId, numberToMap); +} + +result +SettingsPresentationModel::SetCallLineIdentity(CallLineIdentity identity) +{ + return __pSettingsMgr->SetCallLineIdentity(identity); +} + +result +SettingsPresentationModel::GetCallLineIdentity(CallLineIdentity& identity) +{ + return __pSettingsMgr->GetCallLineIdentity(identity); +} + +result +SettingsPresentationModel::SetCallAlertStatus(CallAlertStatus callAlertStatus) +{ + return __pSettingsMgr->SetCallAlertStatus(callAlertStatus); +} + +result +SettingsPresentationModel::GetCallAlertStatus(CallAlertStatus& callAlertStatus) +{ + return __pSettingsMgr->GetCallAlertStatus(callAlertStatus); +} + +result +SettingsPresentationModel::SetUnknownRejectStatus(bool activate) +{ + return __pSettingsMgr->SetUnknownRejectStatus(activate); +} + +bool +SettingsPresentationModel::GetUnknownRejectStatus(void) +{ + return __pSettingsMgr->GetUnknownRejectStatus(); +} + +Contact* +SettingsPresentationModel::FetchContactDetailsN(const String& contactId) +{ + return __pSettingsMgr->FetchContactDetailsN(contactId); +} + +////////////////////////////////////////////////// +// Settings Event Listener Methods // +////////////////////////////////////////////////// + +void +SettingsPresentationModel::HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleGetCallWaitingResponse(isCallSuccessful, callWaitingActivated); + } +} + +void +SettingsPresentationModel::HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleSetCallWaitingResponse(isCallSuccessful, isCallWaitingEnabled); + } +} + +void +SettingsPresentationModel::HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleGetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, callForwardActivated, noReplyWaitTime); + } +} + +void +SettingsPresentationModel::HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleSetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, isCallForwardActivated, noReplyWaitTime); + } +} + +void +SettingsPresentationModel::HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleGetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated); + } +} + +void +SettingsPresentationModel::HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated) +{ + if (__pSettingsEventListener != null) + { + __pSettingsEventListener->HandleSetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated); + } +} + +result +SettingsPresentationModel::SetCallState(CallState callState) +{ + return __pSettingsMgr->SetCallState(callState); +} diff --git a/src/PhnSettingsRejectListForm.cpp b/src/PhnSettingsRejectListForm.cpp new file mode 100644 index 0000000..fc9f949 --- /dev/null +++ b/src/PhnSettingsRejectListForm.cpp @@ -0,0 +1,452 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsRejectListForm.cpp + * @brief Setting Reject list form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSettingsRejectListForm.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int IDI_TOTAL_GROUP_COUNT = 1; +const int IDI_DEFAULT_LIST_ITEMID = 500; +//by default, list has 1 item +const int IDI_DEFAULT_LIST_COUNT = 1; +const int IDI_ADD_FOOTER_INDEX = 0; +const int IDI_DEL_FOOTER_INDEX = 1; +static const wchar_t* IDL_SETTINGS_REJECTLIST_FORM = L"IDL_SETTINGS_REJECTLIST_FORM"; + +SettingsRejectListForm::SettingsRejectListForm(void) + : __pNumbersList(null) + , __pSettingsPresentor(null) +{ +} + +SettingsRejectListForm::~SettingsRejectListForm(void) +{ +} + +bool +SettingsRejectListForm::Initialize(void) +{ + Construct(IDL_SETTINGS_REJECTLIST_FORM); + return true; +} + +result +SettingsRejectListForm::OnInitializing(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + + // Setup back event listener + SetFormBackEventListener(this); + //Initialize Footer + InitializeFooter(); + //initialize list view + r = InitializeGroupedTableView(); + return r; +} + +void +SettingsRejectListForm::InitializeFooter(void) +{ + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT); + + //Add footer item + String footerItemName(L""); + footerItemName.Append(AppUtility::GetResourceString(IDS_ADD_BTN_STRING)); + FooterItem addFooterItem; + addFooterItem.Construct(IDA_ADD_FOOTER_ITEMID); + addFooterItem.SetText(footerItemName); + pFooter->InsertItemAt(IDI_ADD_FOOTER_INDEX,addFooterItem); + + //Delete footer item + footerItemName.Clear(); + footerItemName.Append(AppUtility::GetResourceString(IDS_DELETE_BTN_STRING)); + FooterItem delFooterItem; + delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID); + delFooterItem.SetText(footerItemName); + pFooter->InsertItemAt(IDI_DEL_FOOTER_INDEX,delFooterItem); + //back button + pFooter->SetBackButton(); + + pFooter->AddActionEventListener(*this); + } +} + +result +SettingsRejectListForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pNumbersList) + { + delete __pNumbersList; + __pNumbersList = null; + } + __pSettingsPresentor = null; + return r; +} + +void +SettingsRejectListForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_ADD_FOOTER_ITEMID: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ADD_REJECT_NUMBER), null); + } + break; + + case IDA_DELETE_FOOTER_ITEMID: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_DEL_NUMBER), null); + } + break; + + default: + break; + } +} + +void +SettingsRejectListForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MAIN_SETTING_MENU), null); +} + +void +SettingsRejectListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + // Add your scene activate code here + FetchNumbersRejectList(); + GroupedTableView* pMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMenuTableView != null) + { + //fetch latest added numbers + pMenuTableView->UpdateTableView(); + + //set item's check status + for (int itemIndex = 0; itemIndex < GetItemCount(0); itemIndex++) + { + bool isItemActivated = false; + if(itemIndex == 0) + { + isItemActivated = __pSettingsPresentor->GetUnknownRejectStatus(); + } + else + { + int listIndex = itemIndex - 1; + if (__pNumbersList != null && listIndex < __pNumbersList->GetCount()) + { + //numbers from fetched list + CallRejectInfo rejectInfo; + __pNumbersList->GetAt(listIndex, rejectInfo); + isItemActivated = rejectInfo.isActivated; + } + } + pMenuTableView->SetItemChecked(0, itemIndex, isItemActivated); + } + pMenuTableView->Invalidate(true); + } + + //Enable or Disable delete footer button + bool enableItem = true; + if (__pNumbersList == null || __pNumbersList->GetCount() <= 0) + { + enableItem = false; + } + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetItemEnabled(IDI_DEL_FOOTER_INDEX, enableItem); + } + +} + +void +SettingsRejectListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +void +SettingsRejectListForm::FetchNumbersRejectList(void) +{ + if (__pNumbersList != null) + { + delete __pNumbersList; + __pNumbersList = null; + } + __pNumbersList = static_cast*>(__pSettingsPresentor->GetCallRejectList()); +} + +result +SettingsRejectListForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMenuTableView != null) + { + pMenuTableView->SetGroupedLookEnabled(true); + pMenuTableView->SetItemProvider(this); + r = pMenuTableView->AddGroupedTableViewItemEventListener(*this); + pMenuTableView->UpdateTableView(); + } + return r; +} + +void +SettingsRejectListForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + if(status == TABLE_VIEW_ITEM_STATUS_SELECTED) + { + if(itemIndex == 0) + { + if(tableView.IsItemChecked(groupIndex,itemIndex) == true) + { + tableView.SetItemChecked(groupIndex,itemIndex,false); + __pSettingsPresentor->SetUnknownRejectStatus(false); + } + else + { + tableView.SetItemChecked(groupIndex,itemIndex,true); + __pSettingsPresentor->SetUnknownRejectStatus(true); + } + } + else + { + CallRejectInfo rejectInfo; + __pNumbersList->GetAt((itemIndex -1), rejectInfo); + // "unknown number" element status changed + if (tableView.IsItemChecked(groupIndex,itemIndex) == true) + { + tableView.SetItemChecked(groupIndex,itemIndex,false); + __pSettingsPresentor->UpdateCallRejectRow(rejectInfo.rowId,rejectInfo.phoneNumber,false,rejectInfo.rejectCondition); + } + else + { + tableView.SetItemChecked(groupIndex,itemIndex,true); + __pSettingsPresentor->UpdateCallRejectRow(rejectInfo.rowId,rejectInfo.phoneNumber,true,rejectInfo.rejectCondition); + } + + } + + } + if (itemIndex == 0) + { + // "unknown number" element status changed + if (status == TABLE_VIEW_ITEM_STATUS_CHECKED) + { + __pSettingsPresentor->SetUnknownRejectStatus(true); + } + else if(status == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + __pSettingsPresentor->SetUnknownRejectStatus(false); + } + } + else + { + CallRejectInfo rejectInfo; + __pNumbersList->GetAt((itemIndex -1), rejectInfo); + // "unknown number" element status changed + if (status == TABLE_VIEW_ITEM_STATUS_CHECKED) + { + __pSettingsPresentor->UpdateCallRejectRow(rejectInfo.rowId,rejectInfo.phoneNumber,true,rejectInfo.rejectCondition); + } + else if(status == TABLE_VIEW_ITEM_STATUS_UNCHECKED) + { + __pSettingsPresentor->UpdateCallRejectRow(rejectInfo.rowId,rejectInfo.phoneNumber,false,rejectInfo.rejectCondition); + } + } +} + +int +SettingsRejectListForm::GetGroupCount(void) +{ + return IDI_TOTAL_GROUP_COUNT; +} + +int +SettingsRejectListForm::GetItemCount(int groupIndex) +{ + int itemCount = IDI_DEFAULT_LIST_COUNT; + if (__pNumbersList != null) + { + itemCount += __pNumbersList->GetCount(); + } + return itemCount; +} + +TableViewGroupItem* +SettingsRejectListForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG); + return pItem; +} + +bool +SettingsRejectListForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsRejectListForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsRejectListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + //sub text rectangle + Rectangle criteriaRect(X_LIST_MENU_TEXT_ITEM, H_LIST_NORMAL_TXT_ITEM, + (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_SUB_TXT_ITEM); + String criteria(L""); + //text item rectangle + Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM - W_SLIDER_ICON), H_LIST_NORMAL_MENU_ITEM); + String itemName(L""); + + switch (itemIndex) + { + case 0: + { + //default "unknown" item + itemName.Append(AppUtility::GetResourceString(IDS_DEFAULT_REJECT_ITEM_STRING)); + } + break; + + default: + { + int listIndex = itemIndex - 1; + if (__pNumbersList != null && listIndex < __pNumbersList->GetCount()) + { + //numbers from fetched list + CallRejectInfo rejectInfo; + __pNumbersList->GetAt(listIndex, rejectInfo); + itemName.Append(rejectInfo.phoneNumber); + //update item name rectangle + itemNameRect.y = Y_LIST_MENU_TEXT_ITEM; + itemNameRect.height = H_LIST_NORMAL_TXT_ITEM; + //criteria string + switch (rejectInfo.rejectCondition) + { + case CALL_REJECT_MATCH_EXACTLY: + { + criteria.Append(AppUtility::GetResourceString(IDS_MATCHCRITERIA_EXACT)); + } + break; + + case CALL_REJECT_MATCH_START: + { + criteria.Append(AppUtility::GetResourceString(IDS_MATCHCRITERIA_START)); + } + break; + + case CALL_REJECT_MATCH_END: + { + criteria.Append(AppUtility::GetResourceString(IDS_MATCHCRITERIA_END)); + } + break; + + case CALL_REJECT_MATCH_INCLUDE: + { + criteria.Append(AppUtility::GetResourceString(IDS_MATCHCRITERIA_INCLUDE)); + } + break; + } + } + } + break; + } + + TableViewItem* pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING); + //item name + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(itemNameRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_MAIN_TXT); + pItem->AddControl(*pItemLbl); + //criteria + if(criteria.IsEmpty() == false) + { + Label* pCriteriaLbl = new (std::nothrow) Label(); + pCriteriaLbl->Construct(criteriaRect, criteria); + pCriteriaLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pCriteriaLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pCriteriaLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL); + pCriteriaLbl->SetTextColor(COLOR_NORMAL_SUB_TXT); + pItem->AddControl(*pCriteriaLbl); + } + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return pItem; +} + +bool +SettingsRejectListForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsRejectListForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + return; +} + +int +SettingsRejectListForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsRejectListForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} diff --git a/src/PhnSettingsRejectMsgsForm.cpp b/src/PhnSettingsRejectMsgsForm.cpp new file mode 100644 index 0000000..d8c7909 --- /dev/null +++ b/src/PhnSettingsRejectMsgsForm.cpp @@ -0,0 +1,342 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsRejectMsgsForm.cpp + * @brief Setting Reject message form + */ +#include +#include "PhnAppUtility.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnSettingsRejectMsgsForm.h" +#include "PhnSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +//contants +const int IDI_TOTAL_GROUP_COUNT = 1; +const int IDI_ADD_FOOTER_INDEX = 0; +const int IDI_DEL_FOOTER_INDEX = 1; +static const wchar_t* IDL_SETTINGS_REJECTMSGS_FORM = L"IDL_SETTINGS_REJECTMSGS_FORM"; + +SettingsRejectMsgsForm::SettingsRejectMsgsForm(void) + : __pMsgsMap(null) + , __pSettingsPresentor(null) +{ +} + +SettingsRejectMsgsForm::~SettingsRejectMsgsForm(void) +{ +} + +bool +SettingsRejectMsgsForm::Initialize(void) +{ + Construct(IDL_SETTINGS_REJECTMSGS_FORM); + return true; +} + +result +SettingsRejectMsgsForm::OnInitializing(void) +{ + result r = E_SUCCESS; + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + // Setup back event listener + SetFormBackEventListener(this); + //Initialize Footer + InitializeFooter(); + //initialize list view + r = InitializeGroupedTableView(); + return r; +} + +void +SettingsRejectMsgsForm::InitializeFooter(void) +{ + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT); + + //Add footer item + String footerItemName(L""); + footerItemName.Append(AppUtility::GetResourceString(IDS_ADD_BTN_STRING)); + FooterItem addFooterItem; + addFooterItem.Construct(IDA_ADD_FOOTER_ITEMID); + addFooterItem.SetText(footerItemName); + pFooter->InsertItemAt(IDI_ADD_FOOTER_INDEX, addFooterItem); + + //Delete footer item + footerItemName.Clear(); + footerItemName.Append(AppUtility::GetResourceString(IDS_DELETE_BTN_STRING)); + FooterItem delFooterItem; + delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID); + delFooterItem.SetText(footerItemName); + pFooter->InsertItemAt(IDI_DEL_FOOTER_INDEX, delFooterItem); + + //back button + pFooter->SetBackButton(); + + pFooter->SetItemColor(FOOTER_ITEM_STATUS_DISABLED, pFooter->GetColor()); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + pFooter->AddActionEventListener(*this); + } +} + +result +SettingsRejectMsgsForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pMsgsMap) + { + delete __pMsgsMap; + __pMsgsMap = null; + } + __pSettingsPresentor = null; + return r; +} + +void +SettingsRejectMsgsForm::OnActionPerformed(const Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + switch (actionId) + { + case IDA_ADD_FOOTER_ITEMID: + { + //switch to Add New Reject Msg form + int msgCount = 0; + if (__pMsgsMap != null) + { + msgCount = __pMsgsMap->GetCount(); + } + + if(msgCount < 6) + { + IList* pArgList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgList->Add((new (std::nothrow) Integer(msgCount))); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ADD_REJECT_MSG), pArgList); + } + } + break; + + case IDA_DELETE_FOOTER_ITEMID: + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_DEL_MESSAGE), null); + } + break; + + default: + break; + } +} + +void +SettingsRejectMsgsForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MAIN_SETTING_MENU), null); +} + +void +SettingsRejectMsgsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + //Fetch the latest message list + FetchRejectMsgs(); + GroupedTableView* pMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMenuTableView != null) + { + pMenuTableView->UpdateTableView(); + } + //Enable or Disable delete footer button + bool enableDelItem = true; + bool enableAddItem = true; + if (__pMsgsMap == null || __pMsgsMap->GetCount() <= 0) + { + enableDelItem = false; + } + if(__pMsgsMap != null && __pMsgsMap->GetCount() >= 6) + { + enableAddItem = false; + } + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetItemEnabled(IDI_DEL_FOOTER_INDEX, enableDelItem); + pFooter->SetItemEnabled(IDI_ADD_FOOTER_INDEX, enableAddItem); + } +} + +void +SettingsRejectMsgsForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} + +void +SettingsRejectMsgsForm::FetchRejectMsgs(void) +{ + if (__pMsgsMap != null) + { + __pMsgsMap->RemoveAll(); + delete __pMsgsMap; + } + //item to be fetched from Db + __pMsgsMap = __pSettingsPresentor->GetRejectMessageListN(); +} + +result +SettingsRejectMsgsForm::InitializeGroupedTableView(void) +{ + result r = E_FAILURE; + GroupedTableView* pMenuTableView = static_cast(GetControl(IDC_GROUPEDTABLEVIEW)); + if (pMenuTableView != null) + { + pMenuTableView->SetGroupedLookEnabled(true); + pMenuTableView->SetItemProvider(this); + r = pMenuTableView->AddGroupedTableViewItemEventListener(*this); + } + return r; +} + +void +SettingsRejectMsgsForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + + if(__pMsgsMap != null) + { + int listIndex = itemIndex; + IListT *pRejectMsgList = __pMsgsMap->GetValuesN(); + if (pRejectMsgList != null && listIndex < pRejectMsgList->GetCount()) + { + //switch to edit message form + String msgToBeEdited; + pRejectMsgList->GetAt(listIndex, msgToBeEdited); + //Ownership - transferred to next form + IList* pArgList = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgList->Add((new Integer(listIndex))); + pArgList->Add(new String(msgToBeEdited)); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_EDIT_REJECT_MSG), pArgList); + } + } +} + +int +SettingsRejectMsgsForm::GetGroupCount(void) +{ + return IDI_TOTAL_GROUP_COUNT; +} + +int +SettingsRejectMsgsForm::GetItemCount(int groupIndex) +{ + int itemCount = 0; + if (__pMsgsMap != null) + { + itemCount += __pMsgsMap->GetCount(); + } + return itemCount; +} + +TableViewGroupItem* +SettingsRejectMsgsForm::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM)); + pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG); + return pItem; +} + +bool +SettingsRejectMsgsForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsRejectMsgsForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + return; +} + +TableViewItem* +SettingsRejectMsgsForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + int listIndex = itemIndex; + //main text item rectangle + Rectangle mainItemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM); + + TableViewItem* pItem = null; + if (__pMsgsMap != null && listIndex < __pMsgsMap->GetCount()) + { + //messages are from fetched list + String itemName; + __pMsgsMap->GetValue(listIndex, itemName); + + pItem = new (std::nothrow) TableViewItem(); + pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL); + //main text + Label* pItemLbl = new (std::nothrow) Label(); + pItemLbl->Construct(mainItemRect, itemName); + pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL); + pItemLbl->SetTextColor(COLOR_MAIN_TXT); + pItem->AddControl(*pItemLbl); + pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + } + return pItem; +} + +bool +SettingsRejectMsgsForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + pItem = null; + return true; +} + +void +SettingsRejectMsgsForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + return; +} + +int +SettingsRejectMsgsForm::GetDefaultGroupItemHeight(void) +{ + return H_LIST_HIDDENGROUP_ITEM; +} + +int +SettingsRejectMsgsForm::GetDefaultItemHeight(void) +{ + return H_LIST_NORMAL_MENU_ITEM; +} diff --git a/src/PhnSettingsSpeedDialForm.cpp b/src/PhnSettingsSpeedDialForm.cpp new file mode 100644 index 0000000..c2cb337 --- /dev/null +++ b/src/PhnSettingsSpeedDialForm.cpp @@ -0,0 +1,866 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsSpeedDialForm.cpp + * @brief Setting Speed dial form + */ +#include +#include +#include "PhnAppUtility.h" +#include "PhnSettingsConstants.h" +#include "PhnSettingsSpeedDialForm.h" +#include "PhnSceneRegister.h" +#include "PhnSpeedDialInfo.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +//constants +const int H_DELETE_ICON_BMP = 56; +const int W_DELETE_ICON_BMP = 56; +const int W_VOICEMAIL_ICON_BG = 213; +const int H_VOICEMAIL_ICON_BG = 213; +const int W_VOICEMAIL_ICON = 100; +const int H_VOICEMAIL_ICON = 100; +const int W_SPEED_DIAL_CHECK_ICON = 64; +const int H_SPEED_DIAL_CHECK_ICON = 64; +const unsigned int COLOR_EMPTY_PHOTO = Color32<103, 103, 103>::Value; +//String contants for control name +static const wchar_t* IDL_SETTINGS_SPEEDDIAL_FORM = L"IDL_SETTINGS_SPEEDDIAL_FORM"; +static const wchar_t* IDC_PHOTO_BTN2 = L"IDC_PHOTO_BUTTON2"; +static const wchar_t* IDC_PHOTO_BTN3 = L"IDC_PHOTO_BUTTON3"; +static const wchar_t* IDC_PHOTO_BTN4 = L"IDC_PHOTO_BUTTON4"; +static const wchar_t* IDC_PHOTO_BTN5 = L"IDC_PHOTO_BUTTON5"; +static const wchar_t* IDC_PHOTO_BTN6 = L"IDC_PHOTO_BUTTON6"; +static const wchar_t* IDC_PHOTO_BTN7 = L"IDC_PHOTO_BUTTON7"; +static const wchar_t* IDC_PHOTO_BTN8 = L"IDC_PHOTO_BUTTON8"; +static const wchar_t* IDC_PHOTO_BTN9 = L"IDC_PHOTO_BUTTON9"; + +static const wchar_t* IDC_NAME_LABEL2 = L"IDC_NAME_LABEL2"; +static const wchar_t* IDC_NAME_LABEL3 = L"IDC_NAME_LABEL3"; +static const wchar_t* IDC_NAME_LABEL4 = L"IDC_NAME_LABEL4"; +static const wchar_t* IDC_NAME_LABEL5 = L"IDC_NAME_LABEL5"; +static const wchar_t* IDC_NAME_LABEL6 = L"IDC_NAME_LABEL6"; +static const wchar_t* IDC_NAME_LABEL7 = L"IDC_NAME_LABEL7"; +static const wchar_t* IDC_NAME_LABEL8 = L"IDC_NAME_LABEL8"; +static const wchar_t* IDC_NAME_LABEL9 = L"IDC_NAME_LABEL9"; + +static const wchar_t* IDB_SPEED_DIAL_CHECK = L"C01-5_icon_speeddial_check.png"; + +SettingsSpeedDialForm::SettingsSpeedDialForm(void) +{ + __pSpeedDialMappingList = null; + __pSettingsPresentor = null; + __keyToMap = 0; + __isUpdate = false; + __isDeleteMode = false; + __pAddressbook = null; + __pSpeedDialPopup = null; + __pDeleteList = null; + __pPreviousSceneId = null; + __isContactAppControlLaunched = false; +} + +SettingsSpeedDialForm::~SettingsSpeedDialForm(void) +{ +// SettingsPresentationModel::DeleteInstance(); + if(__pPreviousSceneId != null) + { + delete __pPreviousSceneId; + } +} + +bool +SettingsSpeedDialForm::Initialize(void) +{ + Construct(IDL_SETTINGS_SPEEDDIAL_FORM); + //Initialise voice mail + InitializeVoiceMail(); + return true; +} + +result +SettingsSpeedDialForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Setup back event listener + SetFormBackEventListener(this); + __pSettingsPresentor = SettingsPresentationModel::GetInstance(); + AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); + __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); + if (__pAddressbook == null) + { + r = E_FAILURE; + } + return r; +} + +void +SettingsSpeedDialForm::InitializeFooter(void) +{ + Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->RemoveAllButtons(); + pFooter->RemoveAllItems(); + pFooter->RemoveBackButton(); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT); + + //Delete footer item + String footerItemName(L""); + footerItemName.Append(AppUtility::GetResourceString(IDS_REMOVE_CONTACT)); + FooterItem delFooterItem; + delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID); + delFooterItem.SetText(footerItemName); + pFooter->AddItem(delFooterItem); + if(__isDeleteMode == false) + { + if(__pSpeedDialMappingList != null) + { + if(__pSpeedDialMappingList->GetCount() == 0) + { + pFooter->SetItemEnabled(0,false); + } + else + { + pFooter->SetItemEnabled(0,true); + } + } + else + { + pFooter->SetItemEnabled(0,false); + } + + + //back button + pFooter->SetBackButton(); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor()); + pFooter->AddActionEventListener(*this); + pFooter->RequestRedraw(true); + } + else + { + + if(__pDeleteList != null) + { + if(__pDeleteList->GetCount() == 0) + { + pFooter->SetItemEnabled(0,false); + } + else + { + pFooter->SetItemEnabled(0,true); + } + } + else + { + pFooter->SetItemEnabled(0,false); + } + + FooterItem cancelFooterItem; + cancelFooterItem.Construct(IDA_CANCEL_FOOTER_ITEMID); + String cancelString = AppUtility::GetResourceString(L"IDS_CANCEL"); + cancelFooterItem.SetText(cancelString); + pFooter->AddItem(cancelFooterItem); + pFooter->RequestRedraw(true); + } + } +} + +void +SettingsSpeedDialForm::InitializeVoiceMail(void) +{ + Button* pVoiceMailBtn = static_cast(GetControl(IDC_VOICEMAIL_BUTTON)); + if (pVoiceMailBtn != null) + { + Bitmap* pIcon = AppUtility::GetBitmapFromResourcesN(IDB_VOICECALL_ICON, W_VOICEMAIL_ICON, H_VOICEMAIL_ICON); + Point iconPos(((pVoiceMailBtn->GetBounds().width - W_VOICEMAIL_ICON) / 2), ((pVoiceMailBtn->GetBounds().height - H_VOICEMAIL_ICON) / 2)); + pVoiceMailBtn->SetNormalBitmap(iconPos, *pIcon); + pVoiceMailBtn->SetPressedBitmap(iconPos, *pIcon); + pVoiceMailBtn->SetColor(BUTTON_STATUS_NORMAL, COLOR_EMPTY_PHOTO); + pVoiceMailBtn->SetActionId(IDA_VOICEMAIL); + pVoiceMailBtn->AddActionEventListener(*this); + delete pIcon; + pIcon = null; + } +} + +void +SettingsSpeedDialForm::InitializePhotoButtons(const String& btnName, const String& lblName, ActionId actionId) +{ + Button* pButton = static_cast(GetControl(btnName)); + Label* pNameLabel = static_cast(GetControl(lblName)); + if (pButton != null && pNameLabel != null) + { + String contactId; + RecordId recordId = INVALID_RECORD_ID; + SpeedDialInfo speedDialInfo; + + if (__pSpeedDialMappingList != null) + { + __pSpeedDialMappingList->GetValue(actionId,speedDialInfo); + if (speedDialInfo.keyMapping == actionId && speedDialInfo.contactId.IsEmpty() == false) + { + // Convert String value to long long type value + Integer::Parse(speedDialInfo.contactId, recordId); + } + } + + //Fetch contacts Photo and name + Bitmap* pContactPhoto = null; + String contactName(L""); + Contact* pMappedContact = null; + if (recordId != Tizen::Social::INVALID_RECORD_ID) + { + pMappedContact = __pAddressbook->GetContactN(recordId); + if(pMappedContact != null) + { + pContactPhoto = pMappedContact->GetThumbnailN(); + if (pContactPhoto != null) + { + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + //draw the contact bitmap + pCanvas->DrawBitmap(canvasRect,*pContactPhoto); + delete pContactPhoto; + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + + } + + } + } + + if (recordId != Tizen::Social::INVALID_RECORD_ID) + { + + if (pMappedContact != null) + { + + if (pContactPhoto != null) + { + if ((__isDeleteMode == true) && (__pDeleteList != null)) + { + if(actionId == __keyToMap) + { + if(__pDeleteList->Contains(__keyToMap) == true) + { + __pDeleteList->Remove(__keyToMap); + } + else + { + //update photo bitmap with check icon + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + //draw the contact bitmap + pCanvas->DrawBitmap(canvasRect,*pContactPhoto); + //apply color + pCanvas->DrawRectangle(canvasRect); + pCanvas->FillRectangle(Color(103,103,103,127),canvasRect); + //draw check icon + Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPEED_DIAL_CHECK,W_SPEED_DIAL_CHECK_ICON,H_SPEED_DIAL_CHECK_ICON); + pCanvas->DrawBitmap(Point((((canvasRect.width)/2) - (W_SPEED_DIAL_CHECK_ICON/2)),(((canvasRect.height)/2)- (H_SPEED_DIAL_CHECK_ICON/2))),*pBitmap); + + //construct the final Bitmap to Button + delete pContactPhoto; + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + delete pBitmap; + __pDeleteList->Add(__keyToMap); + } + } + } + } + else + { + if (__isDeleteMode == false) + { + //Create a new canvas + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + pCanvas->DrawRectangle(canvasRect); + pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect); + //create the final Bitmap + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + } + else + { + if ((__pDeleteList != null)) + { + if(__pDeleteList->Contains(__keyToMap) == true) + { + //Create a new canvas + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + pCanvas->DrawRectangle(canvasRect); + pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect); + //Set the final Bitmap to Button + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + __pDeleteList->Remove(__keyToMap); + } + else + { + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + //apply color + pCanvas->DrawRectangle(canvasRect); + pCanvas->FillRectangle(Color(103,103,103,127),canvasRect); + //draw check icon + Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPEED_DIAL_CHECK,W_SPEED_DIAL_CHECK_ICON,H_SPEED_DIAL_CHECK_ICON); + pCanvas->DrawBitmap(Point((((canvasRect.width)/2) - (W_SPEED_DIAL_CHECK_ICON/2)),(((canvasRect.height)/2)- (H_SPEED_DIAL_CHECK_ICON/2))),*pBitmap); + //Set the final Bitmap to Button + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + delete pBitmap; + __pDeleteList->Add(__keyToMap); + } + } + } + } + + //fetch Display name for selected contact + pMappedContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME,contactName); + if (contactName.IsEmpty() == true) + { + String firstName; + pMappedContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME,firstName); + String lastName; + pMappedContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME,lastName); + contactName.Append(firstName + L" " + lastName); + } + delete pMappedContact; + } + } + else + { + //Create a new canvas - invalid record + Canvas* pCanvas = new (std::nothrow) Canvas; + Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height)); + pCanvas->Construct(canvasRect); + pCanvas->DrawRectangle(canvasRect); + pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect); + //create the final Bitmap + pContactPhoto = new Bitmap(); + pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds()); + delete pCanvas; + + //reset display name - invalid record + contactName.Append(actionId); + contactName.Append(AppUtility::GetResourceString(L"IDS_DEFAULT_SPEED_DIAL_TEXT")); + } + + pButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_EMPTY_PHOTO); + //set contact photo to button + if(pContactPhoto != null) + { +// pButton->SetNormalBackgroundBitmap(*pContactPhoto); + pButton->SetNormalBitmap(Point(0,0),*pContactPhoto); + pButton->Invalidate(true); + delete pContactPhoto; + } + //update contacts name + if (pNameLabel != null) + { + pNameLabel->SetText(contactName); + pNameLabel->Invalidate(true); + } + + if(pButton->GetActionId() != actionId) + { + pButton->SetActionId(actionId); + pButton->AddActionEventListener(*this); + } + } +} + + +result +SettingsSpeedDialForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pSpeedDialMappingList) + { + delete __pSpeedDialMappingList; + __pSpeedDialMappingList = null; + } + + __pSettingsPresentor = null; + if (__pAddressbook) + { + delete __pAddressbook; + } + + if (__pDeleteList != null) + { + delete __pDeleteList; + } + return r; +} + +void +SettingsSpeedDialForm::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case IDA_CANCEL_FOOTER_ITEMID: + { + String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_TITLE"); + Header* pHeader = GetHeader(); + pHeader->SetTitleText(titleString); + pHeader->RequestRedraw(true); + if (__pDeleteList != null) + { + __pDeleteList->RemoveAll(); + + } + __isDeleteMode = false; + UpdateAllButtons(); + + } + break; + case IDA_DELETE_FOOTER_ITEMID: + { + Header* pHeader = GetHeader(); + if (__isDeleteMode == false) + { + __isDeleteMode = true; + String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_DELETE_TITLE"); + pHeader->SetTitleText(titleString); + pHeader->RequestRedraw(true); + InitializeFooter(); +/* Footer* pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->RemoveAllButtons(); + pFooter->RemoveAllItems(); + pFooter->RemoveBackButton(); + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT); + + //Delete footer item + String footerItemName(L""); + footerItemName.Append(AppUtility::GetResourceString(IDS_REMOVE_CONTACT)); + FooterItem delFooterItem; + delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID); + delFooterItem.SetText(footerItemName); + pFooter->AddItem(delFooterItem); + + FooterItem cancelFooterItem; + cancelFooterItem.Construct(IDA_CANCEL_FOOTER_ITEMID); + String cancelString = AppUtility::GetResourceString(L"IDS_CANCEL"); + cancelFooterItem.SetText(cancelString); + pFooter->AddItem(cancelFooterItem); + pFooter->RequestRedraw(true); + }*/ + } + else + { + String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_TITLE"); + pHeader->SetTitleText(titleString); + pHeader->RequestRedraw(true); + if (__pDeleteList != null) + { + for (int index = 0; index < __pDeleteList->GetCount(); index++) + { + int keyToDelete; + __pDeleteList->GetAt(index,keyToDelete); + SpeedDialInfo speedDialInfo; + __pSpeedDialMappingList->GetValue(keyToDelete,speedDialInfo); + __pSettingsPresentor->RemoveSpeedDialMapping(speedDialInfo.rowId); + } + } + if (__pSpeedDialMappingList) + { + delete __pSpeedDialMappingList; + __pSpeedDialMappingList = null; + } + __pSpeedDialMappingList = static_cast*>(__pSettingsPresentor->GetSpeedDialMappingN()); + if (__pDeleteList != null) + { + __pDeleteList->RemoveAll(); + } + __isDeleteMode = false; + UpdateAllButtons(); + + } + } + break; + default: + if (actionId > IDA_VOICEMAIL && actionId < IDA_SELECT_CONTACT) + { + __keyToMap = actionId; + if (__isDeleteMode == false) + { + __isUpdate = false; + if (__pSpeedDialMappingList != null) + { + SpeedDialInfo speedDialInfo; + result r = __pSpeedDialMappingList->GetValue(actionId,speedDialInfo); + if (!IsFailed(r)) + { + __isUpdate = true; + } + } + if (__isUpdate == true) + { + if (__pSpeedDialPopup) + { + delete __pSpeedDialPopup; + __pSpeedDialPopup = null; + } + __pSpeedDialPopup = new (std::nothrow) SpeedDialPopup(*this); + __pSpeedDialPopup->Initialize(); + __pSpeedDialPopup->SetShowState(true); + __pSpeedDialPopup->Draw(); + __pSpeedDialPopup->Show(); + + } + else + { + LaunchAppControl(); + } + } + else + { + UpdateButton(); + __keyToMap = 0; + } + } + break; + } +} + +void +SettingsSpeedDialForm::LaunchAppControl(void) +{ + if(__isContactAppControlLaunched == true) + { + //app control already launched. + return; + } + __isContactAppControlLaunched = true; + result r = E_SUCCESS; + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(SELECTION_MODE), new (std::nothrow) String(SELECTION_MODE_SINGLE)); + extraData.Add(new (std::nothrow) String(RETURN_TYPE), new (std::nothrow) String(RETURN_TYPE_CONTACT_ID)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_PICK); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, this); + if(r != E_SUCCESS) + { + //app control request failed + __isContactAppControlLaunched = false; + } + delete pAc; + } + extraData.RemoveAll(true); +} + +void +SettingsSpeedDialForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData) +{ + + if (appId.Equals(String(PROVIDER_ID_CONTACTS)) && operationId.Equals(String(OPERATION_ID_PICK))) + { + //app control request completed + __isContactAppControlLaunched = false; + //check if results are available. + if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) + { + const String* rettype = static_cast(pExtraData->GetValue(String(RETURN_TYPE))); + if (rettype->Equals(String(RETURN_TYPE_CONTACT_ID),false)) + { + const String* pPickResult = static_cast(pExtraData->GetValue(String(RETURN_KEY_VALUE))); + if (pPickResult != null && pPickResult->IsEmpty() == false) + { + if (__isUpdate == true) + { + SpeedDialInfo speedDialInfo; + __pSpeedDialMappingList->GetValue(__keyToMap,speedDialInfo); + __pSettingsPresentor->UpdateSpeedDialMapping(speedDialInfo.rowId,*pPickResult,__keyToMap); + __isUpdate = false; + } + else + { + __pSettingsPresentor->SetSpeedDialMapping(*pPickResult,__keyToMap); + } + UpdateButton(); + } + } + } + __keyToMap = 0; + } +} + +void +SettingsSpeedDialForm::UpdateAllButtons(void) +{ + //Initialise photos + InitializePhotoButtons(IDC_PHOTO_BTN2, IDC_NAME_LABEL2, IDA_SELECT_PHOTO2); + InitializePhotoButtons(IDC_PHOTO_BTN3, IDC_NAME_LABEL3, IDA_SELECT_PHOTO3); + InitializePhotoButtons(IDC_PHOTO_BTN4, IDC_NAME_LABEL4, IDA_SELECT_PHOTO4); + InitializePhotoButtons(IDC_PHOTO_BTN5, IDC_NAME_LABEL5, IDA_SELECT_PHOTO5); + InitializePhotoButtons(IDC_PHOTO_BTN6, IDC_NAME_LABEL6, IDA_SELECT_PHOTO6); + InitializePhotoButtons(IDC_PHOTO_BTN7, IDC_NAME_LABEL7, IDA_SELECT_PHOTO7); + InitializePhotoButtons(IDC_PHOTO_BTN8, IDC_NAME_LABEL8, IDA_SELECT_PHOTO8); + InitializePhotoButtons(IDC_PHOTO_BTN9, IDC_NAME_LABEL9, IDA_SELECT_PHOTO9); + InitializeFooter(); +} +void +SettingsSpeedDialForm::UpdateButton(void) +{ + if (__pSpeedDialMappingList) + { + delete __pSpeedDialMappingList; + __pSpeedDialMappingList = null; + } + __pSpeedDialMappingList = static_cast*>(__pSettingsPresentor->GetSpeedDialMappingN()); + switch (__keyToMap) + { + case IDA_SELECT_PHOTO2: + { + InitializePhotoButtons(IDC_PHOTO_BTN2, IDC_NAME_LABEL2, IDA_SELECT_PHOTO2); + } + break; + case IDA_SELECT_PHOTO3: + { + InitializePhotoButtons(IDC_PHOTO_BTN3, IDC_NAME_LABEL3, IDA_SELECT_PHOTO3); + } + break; + case IDA_SELECT_PHOTO4: + { + InitializePhotoButtons(IDC_PHOTO_BTN4, IDC_NAME_LABEL4, IDA_SELECT_PHOTO4); + } + break; + case IDA_SELECT_PHOTO5: + { + InitializePhotoButtons(IDC_PHOTO_BTN5, IDC_NAME_LABEL5, IDA_SELECT_PHOTO5); + } + break; + case IDA_SELECT_PHOTO6: + { + InitializePhotoButtons(IDC_PHOTO_BTN6, IDC_NAME_LABEL6, IDA_SELECT_PHOTO6); + } + break; + case IDA_SELECT_PHOTO7: + { + InitializePhotoButtons(IDC_PHOTO_BTN7, IDC_NAME_LABEL7, IDA_SELECT_PHOTO7); + } + break; + case IDA_SELECT_PHOTO8: + { + InitializePhotoButtons(IDC_PHOTO_BTN8, IDC_NAME_LABEL8, IDA_SELECT_PHOTO8); + } + break; + case IDA_SELECT_PHOTO9: + { + InitializePhotoButtons(IDC_PHOTO_BTN9, IDC_NAME_LABEL9, IDA_SELECT_PHOTO9); + } + break; + default: + break; + } + InitializeFooter(); +} +void +SettingsSpeedDialForm::OnFormBackRequested(Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager != null); + pSceneManager->GoForward(ForwardSceneTransition(*__pPreviousSceneId), null); +} + +void +SettingsSpeedDialForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + __isDeleteMode = false; + __isContactAppControlLaunched = false; + //save previous scene id + __pPreviousSceneId = new (std::nothrow) SceneId(previousSceneId); + + if (__pSpeedDialMappingList != null) + { + delete __pSpeedDialMappingList; + __pSpeedDialMappingList = null; + } + + if (__pDeleteList != null) + { + delete __pDeleteList; + __pDeleteList = null; + } + + __pSpeedDialMappingList = static_cast*>(__pSettingsPresentor->GetSpeedDialMappingN()); + //Initialise photos + UpdateAllButtons(); + __pDeleteList = new (std::nothrow) ArrayListT(); + if(__pAddressbook != null) + { + __pAddressbook->SetEventListener(this); + } +} + +void +SettingsSpeedDialForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if(__pPreviousSceneId != null) + { + delete __pPreviousSceneId; + __pPreviousSceneId = null; + } + if(__pAddressbook != null) + { + __pAddressbook->SetEventListener(null); + } +} + +void +SettingsSpeedDialForm::OnItemSelected(int itemIndex) +{ + switch (itemIndex) + { + case IDA_UPDATE_SPEED_DIAL: + { + __isUpdate = true; + LaunchAppControl(); + } + break; + + case IDA_REMOVE_SPEED_DIAL: + { + SpeedDialInfo speedDialInfo; + __pSpeedDialMappingList->GetValue(__keyToMap,speedDialInfo); + __pSettingsPresentor->RemoveSpeedDialMapping(speedDialInfo.rowId); + UpdateButton(); + } + break; + default: + break; + } +} + +void +SettingsSpeedDialForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList) +{ + IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent(); + switch(pInfo->GetChangeType()) + { + case RECORD_CHANGE_TYPE_REMOVED: + { + if(__pSpeedDialMappingList == null || __pSpeedDialMappingList->GetCount() == 0) + { + break; + } + IListT* pSpeedDialList = __pSpeedDialMappingList->GetValuesN(); + IEnumeratorT *pSpeedDialListEnum = pSpeedDialList->GetEnumeratorN(); + bool bFound = false; + while(pSpeedDialListEnum->MoveNext() == E_SUCCESS) + { + SpeedDialInfo speeDialInfo; + RecordId recordId = INVALID_RECORD_ID; + pSpeedDialListEnum->GetCurrent(speeDialInfo); + Integer::Parse(speeDialInfo.contactId, recordId); + if(recordId == pInfo->GetContactId()) + { + __pSettingsPresentor->RemoveSpeedDialMapping(speeDialInfo.rowId); + bFound = true; + + } + } + delete pSpeedDialListEnum; + delete pSpeedDialList; + if(bFound == true) + { + if (__pSpeedDialMappingList) + { + delete __pSpeedDialMappingList; + __pSpeedDialMappingList = null; + } + __pSpeedDialMappingList = static_cast*>(__pSettingsPresentor->GetSpeedDialMappingN()); + UpdateAllButtons(); + } + + } + break; + case RECORD_CHANGE_TYPE_UPDATED: + { + if(__pSpeedDialMappingList == null || __pSpeedDialMappingList->GetCount() == 0) + { + break; + } + IListT* pSpeedDialList = __pSpeedDialMappingList->GetValuesN(); + IEnumeratorT *pSpeedDialListEnum = pSpeedDialList->GetEnumeratorN(); + bool bFound = false; + while(pSpeedDialListEnum->MoveNext() == E_SUCCESS) + { + SpeedDialInfo speeDialInfo; + RecordId recordId = INVALID_RECORD_ID; + pSpeedDialListEnum->GetCurrent(speeDialInfo); + Integer::Parse(speeDialInfo.contactId, recordId); + if(recordId == pInfo->GetContactId()) + { + bFound = true; + + } + } + delete pSpeedDialListEnum; + delete pSpeedDialList; + if(bFound == true) + { + UpdateAllButtons(); + } + + } + break; + case RECORD_CHANGE_TYPE_ADDED: + break; + default: + break; + } + AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContactId(), pInfo->GetVersion()); + } + delete pEnum; +} diff --git a/src/PhnSoundManager.cpp b/src/PhnSoundManager.cpp new file mode 100644 index 0000000..a640fee --- /dev/null +++ b/src/PhnSoundManager.cpp @@ -0,0 +1,312 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSettingsMoreOptionsForm.cpp + * @brief Sound manager class + */ +#include "PhnSoundManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Media; +using namespace Tizen::Social; +using namespace Tizen::System; +using namespace Tizen::Base::Collection; + +static const wchar_t* RINGTONE_PATH = L"/opt/usr/apps/zktdpemtmw/shared/data/ringtone_sdk.mp3"; + +SoundManager::SoundManager(void) + : __pSoundCallSession(null) + , __pVibrator(null) + , __pPlayer(null) +{ + __isSoundStatusOn = false; + __isVibrateStatusOn = false; +} + +SoundManager::~SoundManager(void) +{ + if(__pSoundCallSession != null) + { + sound_manager_call_session_destroy(__pSoundCallSession); + } + if (__pVibrator != null) + { + delete __pVibrator; + } + if (__pPlayer != null) + { + delete __pPlayer; + } +} + +result +SoundManager::StopSession(void) +{ + AppLogDebug("Enter"); + if(__pSoundCallSession != null) + { + AppLogDebug("sound_manager_call_session_destroy"); + sound_manager_call_session_destroy(__pSoundCallSession); + __pSoundCallSession = null; + } + + return E_SUCCESS; +} + +result +SoundManager::StartSession(void) +{ + AppLogDebug("Enter"); + if (__pSoundCallSession != null) + { + sound_manager_call_session_set_mode(__pSoundCallSession,(sound_call_session_mode_e)SOUND_CALL_SESSION_MODE_VOICE); + sound_manager_set_active_route((sound_route_e)SOUND_ROUTE_IN_MIC_OUT_RECEIVER); + sound_manager_set_volume((sound_type_e)SOUND_TYPE_CALL,5); + return E_SUCCESS; + } + int res = sound_manager_call_session_create((sound_call_session_type_e)SOUND_SESSION_TYPE_CALL, &__pSoundCallSession); + if (res != SOUND_MANAGER_ERROR_NONE) + { + AppLogDebug("Sound manager creation failed"); + return E_FAILURE; + } + res = sound_manager_call_session_set_mode(__pSoundCallSession,(sound_call_session_mode_e)SOUND_CALL_SESSION_MODE_VOICE); + sound_manager_set_active_route((sound_route_e)SOUND_ROUTE_IN_MIC_OUT_RECEIVER); + //todo start listening for volume key and set the volume + sound_manager_set_volume((sound_type_e)SOUND_TYPE_CALL,5); + return E_SUCCESS; +} + +result +SoundManager::SetSpeakerStatus(bool setSpeaker) +{ + result r = E_FAILURE; + int res = -1; + bool isEarJackPresent = IsEarJackConnected(); + sound_route_e soundRoute; + if (setSpeaker == true) + { + soundRoute = SOUND_ROUTE_IN_MIC_OUT_SPEAKER; + } + else + { + if (isEarJackPresent == true) + { + soundRoute = SOUND_ROUTE_IN_MIC_OUT_HEADPHONE; + } + else + { + soundRoute = SOUND_ROUTE_IN_MIC_OUT_RECEIVER; + } + } + res = sound_manager_set_active_route(soundRoute); + if (res == SOUND_MANAGER_ERROR_NONE) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + return r; +} + +result +SoundManager::SetSoundMode(SoundMode soundMode) +{ + if (__pSoundCallSession == null) + { + return E_FAILURE; + } + sound_call_session_mode_e sessionMode; + switch (soundMode) + { + case SOUND_MODE_RINGTONE: + { + sessionMode = SOUND_CALL_SESSION_MODE_RINGTONE; + break; + } + case SOUND_MODE_MEDIA: + { + sessionMode = SOUND_CALL_SESSION_MODE_MEDIA; + break; + } + case SOUND_MODE_VOICE: + { + sessionMode = SOUND_CALL_SESSION_MODE_VOICE; + } + break; + default: + { + sessionMode = SOUND_CALL_SESSION_MODE_RINGTONE; + break; + } + } + int res = sound_manager_call_session_set_mode(__pSoundCallSession,sessionMode); + if (res != SOUND_MANAGER_ERROR_NONE) + { + return E_FAILURE; + } + return E_SUCCESS; +} + +void +SoundManager::StartAlert(String& contactRingTone) +{ + AppLogDebug("Enter"); + if(__pSoundCallSession != null) + { + AppLogDebug("No Alert already in call"); + return; + } + else + { + StartSession(); + } + result r = E_FAILURE; + if(__pVibrator == null) + { + __pVibrator = new (std::nothrow) Vibrator(); + r = __pVibrator->Construct(); + } + if(__pPlayer == null) + { + __pPlayer = new (std::nothrow) Player(); + r = __pPlayer->Construct(*this); + } + int retVal = -1; + vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &retVal); + __isSoundStatusOn = retVal; + vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &retVal); + __isVibrateStatusOn = retVal; + //todo: do only if call alert mode is set + if (__isSoundStatusOn == true) + { + String ringTonePath; + //Check if contact has any custom ringtone, else play defautl ringtone. + if(contactRingTone.IsEmpty() == true) + { + char* pRingTonePtr = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR); + ringTonePath.Append(pRingTonePtr); + } + else + { + ringTonePath.Append(contactRingTone); + } + + //Check if file is present + File file; + result res = file.Construct(ringTonePath, "r"); + if(res != E_SUCCESS ) + { + ringTonePath.Clear(); + ringTonePath.Append(RINGTONE_PATH); + } + r = __pPlayer->OpenFile(ringTonePath,false); + r = __pPlayer->SetLooping(true); + r = __pPlayer->SetVolume(80); + r = SetSoundMode(SOUND_MODE_VOICE); + r = __pPlayer->Play(); + } + if (__isVibrateStatusOn == true) + { + //todo: Get the level from settings + r = __pVibrator->Start(3000,1000,1000); + } + AppLogDebug("Exit"); + return; +} + +void +SoundManager::StopAlert(void) +{ + AppLogDebug("Enter"); + if (__isSoundStatusOn == true) + { + //todo: stop player + AppLogDebug("Stopping ring tone"); + __pPlayer->Stop(); + __pPlayer->Close(); + SetSoundMode(SOUND_MODE_VOICE); + __isSoundStatusOn = false; + StopSession(); + } + if (__isVibrateStatusOn == true) + { + __pVibrator->Stop(); + __isVibrateStatusOn = false; + } + AppLogDebug("Exit"); +} + +void +SoundManager::OnPlayerOpened(result r) +{ +} + +void +SoundManager::OnPlayerEndOfClip(void) +{ +} + +void +SoundManager::OnPlayerSeekCompleted(result r) +{ +} + +void +SoundManager::OnPlayerBuffering(int percent) +{ +} + +void +SoundManager::OnPlayerErrorOccurred(Tizen::Media::PlayerErrorReason r) +{ +} + +void +SoundManager::OnPlayerInterrupted(void) +{ +} + +void +SoundManager::OnPlayerReleased(void) +{ +} + +bool +SoundManager::IsEarJackConnected(void) +{ + int earJackStatus = -1; + if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earJackStatus) == 0) + { + if (earJackStatus == VCONFKEY_SYSMAN_EARJACK_REMOVED) + { + return false; + } + else + { + return true; + } + } + else + { + return false; + } +} diff --git a/src/PhnSpeedDialInfo.cpp b/src/PhnSpeedDialInfo.cpp new file mode 100644 index 0000000..be1f9ed --- /dev/null +++ b/src/PhnSpeedDialInfo.cpp @@ -0,0 +1,57 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSpeedDialInfo.cpp + * @brief Speed dial Info class + */ + +#include "PhnSpeedDialInfo.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +SpeedDialInfo::SpeedDialInfo(void) +{ +} + +SpeedDialInfo::~SpeedDialInfo(void) +{ +} + +bool +SpeedDialInfo::operator ==(const SpeedDialInfo& rhs) const +{ + return (this->rowId == rhs.rowId); +} + +bool +SpeedDialInfo::operator !=(const SpeedDialInfo& rhs) const +{ + return (!(this->rowId == rhs.rowId)); +} + +SpeedDialInfo& +SpeedDialInfo::operator =(const SpeedDialInfo& rhs) +{ + if (this != null) + { + this->rowId = rhs.rowId; + this->contactId.Append(rhs.contactId); + this->keyMapping = rhs.keyMapping; + } + return *this; +} diff --git a/src/PhnSpeedDialPopup.cpp b/src/PhnSpeedDialPopup.cpp new file mode 100644 index 0000000..c85f461 --- /dev/null +++ b/src/PhnSpeedDialPopup.cpp @@ -0,0 +1,185 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSpeedDialPopup.cpp + * @brief Speed dial popup class + */ +#include +#include +#include +#include +#include +#include + +#include "PhnSpeedDialPopup.h" +#include "PhnSettingsConstants.h" +#include "PhnAppUtility.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +const int W_POPUP = 620; +const int H_POPUP = 712; +const int W_CANCEL_BUTTON = 400; +const int H_CANCEL_BUTTON = 72; +const int CANCEL_BUTTON_PADDING = 40; +const int H_LIST_ITEM = 112; +const int W_LIST_ITEM = 112; +const int HORIZONTAL_PADDING = 16; +const int VERTICAL_PADDING = 110; +static const wchar_t* IDL_SPEED_DIAL_POPUP = L"IDL_SPEED_DIAL_POPUP"; + +SpeedDialPopup::SpeedDialPopup(IPopupItemSelectListener& listener) + : __pCancelButton(null) + , __popupListener(listener) + , __pListItemArray(null) +{ + +} + +SpeedDialPopup::~SpeedDialPopup(void) +{ + if (__pListItemArray != null) + { + delete __pListItemArray; + } +} + +int +SpeedDialPopup::Initialize(void) +{ + result r = E_SUCCESS; + Construct(IDL_SPEED_DIAL_POPUP); + ConstructListData(); + String strText; + __pCancelButton = static_cast (GetControl(L"IDC_CLOSE_BUTTON")); + __pCancelButton->SetActionId(IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP); + __pCancelButton->AddActionEventListener(*this); + + ListView* __pList = static_cast (GetControl(L"IDC_LISTVIEW")); + __pList->AddListViewItemEventListener(*this); + __pList->SetItemProvider(*this); + AddControl(*__pList); + + return r; + +} + +void +SpeedDialPopup::ConstructListData(void) +{ + __pListItemArray = new (std::nothrow) ArrayList(); + __pListItemArray->Construct(2); + String optionStr = AppUtility::GetResourceString(L"IDS_CHANGE_CONTACT"); + String* listItem1 = new (std::nothrow) String(optionStr); + __pListItemArray->Add(*listItem1); + optionStr.Clear(); + optionStr = AppUtility::GetResourceString(L"IDS_REMOVE_CONTACT"); + String* listItem2 = new (std::nothrow) String(optionStr); + __pListItemArray->Add(*listItem2); +} + +void +SpeedDialPopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status) +{ + Popup::SetShowState(false); + __popupListener.OnItemSelected(elementId); + return; +} + +void +SpeedDialPopup::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction) +{ + return; +} + +void +SpeedDialPopup::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListContextItemStatus state) +{ + + return; +} + +void +SpeedDialPopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + bool& invokeListViewItemCallback) +{ + return; +} + +int +SpeedDialPopup::GetItemCount(void) +{ + if (__pListItemArray != null) + { + return __pListItemArray->GetCount(); + } + return 0; +} + +Tizen::Ui::Controls::ListItemBase* +SpeedDialPopup::CreateItem(int index, int itemWidth) +{ + int elementId = 0; + String* strText = static_cast(__pListItemArray->GetAt(index)); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + CustomItem* pItem = new (std::nothrow) CustomItem(); + pItem->Construct(Dimension(itemWidth, W_LIST_ITEM), style); + if (index == 0) + { + elementId = IDA_UPDATE_SPEED_DIAL; + } + else + { + elementId = IDA_REMOVE_SPEED_DIAL; + } + pItem->AddElement(Rectangle(HORIZONTAL_PADDING, 0, W_POPUP - HORIZONTAL_PADDING, H_LIST_ITEM), elementId, *strText); + return pItem; +} + +bool +SpeedDialPopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + + +void +SpeedDialPopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch (actionId) + { + case IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP: + { + Popup::SetShowState(false); + __popupListener.OnItemSelected(IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP); + break; + } + } +} diff --git a/src/PhnSuggestionItemProvider.cpp b/src/PhnSuggestionItemProvider.cpp new file mode 100644 index 0000000..8e74586 --- /dev/null +++ b/src/PhnSuggestionItemProvider.cpp @@ -0,0 +1,183 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnSuggestionItemProvider.cpp + * @brief Suggestion list item provider class + */ +#include +#include +#include +#include +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" +#include "PhnDialContactInfo.h" +#include "PhnDialPresentationModel.h" +#include "PhnSuggestionItemProvider.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::System; +using namespace Tizen::Social; +using namespace Tizen::Base::Collection; + +SuggestionItemProvider::SuggestionItemProvider( + DialPresentationModel& pDialPresentationModel) : + __dialPresentationModel(pDialPresentationModel) +{ +} + +SuggestionItemProvider::~SuggestionItemProvider(void) +{ +} + +ListItemBase* +SuggestionItemProvider::CreateItem(int index, int itemWidth) +{ + CustomItem* pItem = null; + //Check if any suggestion exist at 'index+1'. + DialContactInfo* pDialInfo = __dialPresentationModel.GetSuggestionAtIndex(index+1); + if(pDialInfo == null) + { + return pItem; + } + //Construct List view item + pItem = new (std::nothrow) CustomItem(); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + pItem->Construct(Dimension(itemWidth, 128), style); + + //create enriched text - Display name with Keyword + String* keyWord = pDialInfo->GetSearchKey(); + EnrichedText* pEnrichedName = ConstructEnrichedTextN(pDialInfo->GetDisplayName(), *keyWord , FONT_SUGGESTION_NAME, BUTTON_STATUS_NORMAL); + pItem->AddElement(Rectangle(16, 10, 445, 60), 202, *pEnrichedName); + delete pEnrichedName; + pEnrichedName = null; + + //create text element - Phone number with Keyword + String phoneNumber(L"Mobile "); + phoneNumber.Append(pDialInfo->GetPhoneNumber()); + EnrichedText* pEnrichedMobile = ConstructEnrichedTextN(phoneNumber, *keyWord, FONT_SUGGESTION_MOBILE, BUTTON_STATUS_NORMAL); + pItem->AddElement(Rectangle(16, 70, 445, 48), 204, *pEnrichedMobile); + delete pEnrichedMobile; + pEnrichedMobile =null; + + //Fetch contact's thumbnail + Bitmap* pContactBitmap = pDialInfo->GetThumbnailN(); + //show default TN + if(pContactBitmap == null) + { + pContactBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-1_icon_contacts.png"); + } + pItem->AddElement(Rectangle(445, 16, 96, 96), 206, *pContactBitmap); + delete pContactBitmap; + + return pItem; +} + +EnrichedText* +SuggestionItemProvider::ConstructEnrichedTextN(String& text, String& keyword, int textFontStyle, int buttonStatus) +{ + //get text font + Font* fontName = DialUtil::GetTextFontN(textFontStyle); + //get text color + Color* textColor = DialUtil::GetTextColorN(textFontStyle, buttonStatus); + //highlighted text Color + Color* highlightedTxtColor = DialUtil::GetTextColorN(FONT_HIGHLIGHT_SEARCH_KEYWORD,buttonStatus); + + EnrichedText* pEnrichedName = new (std::nothrow) EnrichedText(); + pEnrichedName->Construct(Dimension(400, 60)); + + //Text is divided in 3 parts - pre-text, highlighted keyword, post-text. + String preTxt(L""); + String highlightTxt(L""); + String postTxt(L""); + if(keyword.IsEmpty() == false) + { + int searchIndex; + result r = text.IndexOf(keyword,0,searchIndex); + if(r == E_SUCCESS) + { + if(searchIndex > 0) + { + text.SubString(0,searchIndex,preTxt); + } + text.SubString(searchIndex,keyword.GetLength(),highlightTxt); + text.SubString((searchIndex+keyword.GetLength()),postTxt); + } + else + { + preTxt = text; + } + } + + TextElement* pTextName = null; + if(preTxt.IsEmpty() == false) + { + //create text element + pTextName = new (std::nothrow) TextElement(); + pTextName->Construct(preTxt); + pTextName->SetFont(*fontName); + pTextName->SetTextColor(*textColor); + //ownership of 'pTextName' transferred to 'pEnrichedName' + pEnrichedName->Add(*pTextName); + } + + if(highlightTxt.IsEmpty() == false) + { + //create text element + pTextName = new (std::nothrow) TextElement(); + pTextName->Construct(highlightTxt); + pTextName->SetFont(*fontName); + // Highlighted search text + pTextName->SetTextColor(*highlightedTxtColor); + pEnrichedName->Add(*pTextName); + } + + if(postTxt.IsEmpty() == false) + { + //create text element + pTextName = new (std::nothrow) TextElement(); + pTextName->Construct(postTxt); + pTextName->SetFont(*fontName); + pTextName->SetTextColor(*textColor); + pEnrichedName->Add(*pTextName); + } + + delete fontName; + delete textColor; + delete highlightedTxtColor; + + return pEnrichedName; +} + +bool +SuggestionItemProvider::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + if (pItem != null) + { + delete pItem; + pItem = null; + } + return true; +} + +int +SuggestionItemProvider::GetItemCount(void) +{ + return __dialPresentationModel.GetNumberOfSuggestions() - 1; +} diff --git a/src/PhnTabContacts.cpp b/src/PhnTabContacts.cpp new file mode 100644 index 0000000..5262153 --- /dev/null +++ b/src/PhnTabContacts.cpp @@ -0,0 +1,92 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabContacts.cpp + * @brief The contacts Tab + */ + +#include "PhnTabContacts.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +static const wchar_t* IDL_PANEL_CONTACTS = L"IDL_PANEL_CONTACTS"; + +DialTabContacts::DialTabContacts(void) +{ +} + +DialTabContacts::~DialTabContacts(void) +{ +} + +bool +DialTabContacts::Initialize(void) +{ + result r = Construct(IDL_PANEL_CONTACTS); + if (IsFailed(r)) + return false; + + return true; +} + +result +DialTabContacts::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Layout setting + const Form* pForm = dynamic_cast(GetParent()); + if (pForm != null) + { + RelativeLayout* pRelativeLayout = dynamic_cast(pForm->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + pRelativeLayout = dynamic_cast(pForm->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + } + return r; +} + +result +DialTabContacts::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +DialTabContacts::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ +} + +void +DialTabContacts::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} diff --git a/src/PhnTabDialer.cpp b/src/PhnTabDialer.cpp new file mode 100644 index 0000000..8f3d1de --- /dev/null +++ b/src/PhnTabDialer.cpp @@ -0,0 +1,1433 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabDialer.cpp + * @brief The dialer Tab + */ +#include +#include +#include +#include "PhnAppUtility.h" +#include "PhnPhoneApp.h" +#include "PhnCalllogManager.h" +#include "PhnCallPresentationModel.h" +#include "PhnCommonUtils.h" +#include "PhnDialAppForm.h" +#include "PhnDialContactInfo.h" +#include "PhnDialerKeypad.h" +#include "PhnTabDialer.h" +#include "PhnSceneRegister.h" +#include "PhnSettingsPresentationModel.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Social; +using namespace Tizen::System; + +//Constants +const int H_SPEEDDIAL_POPUP = 300; +const int H_POPUP_MSG_LABEL = 100; +const int H_POPUP_BTN = 90; +const int H_SEARCHLIST_ITEM = 129; +const int IDI_PADDING = 15; +const int IDI_MAX_LIMIT_LENGTH = 18; +const int IDI_MAX_TXT_FONT = 94; +const int IDI_MIN_TXT_FONT = 67; +const int IDI_DELTA_FONT_SIZE = 5; +const wchar_t* IDI_ADD_TO_CONTACTS_STR = L"Add To Contacts"; +const int MAX_SEARCH_LIST_ITEMS = 5; +const int MIN_CONTEXT_MENU_ITEMS = 4; +const int X_CONTEXT_MENU_ANCHOR = 614; +const int Y_CONTEXT_MENU_ANCHOR = 504; +const int MAX_NUMBER_WITH_SEPERATOR = 11; +const int MIN_NUMBER_WITH_ONE_SEPERATOR = 3; +const int MIN_NUMBER_WITH_TWO_SEPERATOR = 7; +const int MAX_TXT_LENGTH_WITH_SEPERATOR = 12; +const int MAX_VISIBLE_TXT_WITH_MIN_FONT = 18; +const int W_MORE_BUTTON = 65; +const int H_MORE_BUTTON = 65; +const int W_SUGGESTION_POPUP_BUBBLE_ICON = 45; +const int H_SUGGESTION_POPUP_BUBBLE_ICON = 30; + +//resources +const wchar_t* IDL_PANEL_DIALER = L"IDL_PANEL_DIALER"; +const wchar_t* IDC_NUMERIC_EDITFIELD = L"IDC_EDITFIELD"; +const wchar_t* IDC_PANEL_SEARCH_BOX = L"IDC_PANEL_SEARCH_BOX"; +const wchar_t* IDC_BUTTON_ADD_CONTACTS = L"IDC_BUTTON_ADD_CONTACTS"; +const wchar_t* IDC_BUTTON_USE_CONTACT = L"IDC_BUTTON_USE_CONTACT"; +const wchar_t* IDC_BUTTON_DROP_DOWN = L"IDC_BUTTON_DROP_DOWN"; +const wchar_t* IDC_PANEL_SEARCH_LIST = L"IDC_PANEL_SEARCH_LIST"; +static const wchar_t* IDC_PANEL_DISPLAY_DATA = L"IDC_PANEL_DISPLAY_DATA"; +const wchar_t* IDC_PANEL_MENU = L"IDC_PANEL_MENU"; +const wchar_t* IDC_BUTTON_MENU = L"IDC_BUTTON_MENU"; +const wchar_t* IDC_LISTVIEW_SEARCH = L"IDC_LISTVIEW_SEARCH"; + +//Button Dimensions +const int DialTabDialer::IDI_BGBITMAP_WIDTH = 75; +const int DialTabDialer::IDI_BGBITMAP_HEIGHT = 75; +const int DialTabDialer::IDI_BGBITMAP_POS_X = 56; +const int DialTabDialer::IDI_BGBITMAP_POS_Y = 56; +const int DialTabDialer::IDI_TEXT1_SIZE = 116; +const int DialTabDialer::IDI_TEXT2_SIZE = 40; + +//color +const unsigned int COLOR_SEARCHLIST_BG = Color32<43, 107, 144>::Value; + +DialTabDialer::DialTabDialer(void) +{ + AppLogDebug("ENTER"); + __pDialPresentationModel = null; + __pSuggestionListProvider = null; + __pSearchListView = null; + __isSearchListOpened = false; + __pErrorMsgPopup = null; + __pCallPresentor = null; + __pContextMenu = null; + __pPreviousSceneId = null; + __pDialKeypad = null; + __pConfirmationPopup = null; + __isAppForeground = true; + __pAddressBook = null; + __isAppControlLaunched = false; + AppLogDebug("EXIT"); +} + +DialTabDialer::~DialTabDialer(void) +{ + AppLogDebug("ENTER"); + + if(__pDialKeypad != null) + { + //RemoveControl() also deletes the child control. + RemoveControl(*__pDialKeypad); + __pDialKeypad = null; + } + if(__pConfirmationPopup != null) + { + delete __pConfirmationPopup; + __pConfirmationPopup = null; + } + if (__pAddressBook != null) + { + delete __pAddressBook; + __pAddressBook = null; + } + delete __pContextMenu; + AppLogDebug("EXIT"); +} + +bool +DialTabDialer::Initialize(void) +{ + AppLogDebug("ENTER"); + Construct(IDL_PANEL_DIALER); + AppLogDebug("EXIT"); + return true; +} + +result +DialTabDialer::OnInitializing(void) +{ + AppLogDebug("ENTER"); + result r = E_SUCCESS; + + // Layout setting + Form* pForm = dynamic_cast(GetParent()); + if(pForm == null) + { + return E_FAILURE; + } + + __pDialPresentationModel = new DialPresentationModel(*this); + __pSuggestionListProvider = new SuggestionItemProvider(*__pDialPresentationModel); + __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN(); + + RelativeLayout* pRelativeLayout = dynamic_cast(pForm->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + pRelativeLayout = dynamic_cast(pForm->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + + //hide footer + pForm->GetFooter()->SetShowState(false); + pForm->AddOrientationEventListener(*this); + + //Construct menu + ConstructMenu(); + //Initialize text box + InitializeContactsTextBox(); + //Create and hide Search data display panel + InitializeSearchBox(); + //initialize search list view and hide it. + InitializeSearchListView(); + HideSearchListView(); + AppLogDebug("EXIT"); + return r; +} + +result +DialTabDialer::OnTerminating(void) +{ + result r = E_SUCCESS; + if (__pDialPresentationModel != null) + { + delete __pDialPresentationModel; + __pDialPresentationModel = null; + } + if (__pSuggestionListProvider != null) + { + delete __pSuggestionListProvider; + __pSuggestionListProvider = null; + } + // Add your termination code here + return r; +} + +void +DialTabDialer::InitializeContactsTextBox(void) +{ + AppLogDebug("ENTER"); + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField != null) + { + //clear text + pEditField->Clear(); + } + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::ShowFormattedText(EditField* pEditField, int actionId) +{ + AppLogDebug("ENTER"); + String contactNumber = pEditField->GetText(); + contactNumber.Replace(L"-",L""); + if(actionId == CLEAR_KEY) + { + contactNumber.Remove(contactNumber.GetLength() - 1, 1); + } + else + { + contactNumber.Append(DialUtil::ConvertDialedNumberToString(actionId)); + } + + int textLength = contactNumber.GetLength(); + if(textLength == 0) + { + pEditField->Clear(); + pEditField->SetCursorPosition(0); + pEditField->SetFocus(); + pEditField->Invalidate(true); + AppLogDebug("EXIT"); + return; + } + + //Insert separator if required + if(textLength < MAX_NUMBER_WITH_SEPERATOR) + { + if(textLength > MIN_NUMBER_WITH_TWO_SEPERATOR) + { + contactNumber.Insert(L"-",MIN_NUMBER_WITH_TWO_SEPERATOR); + } + if(textLength > MIN_NUMBER_WITH_ONE_SEPERATOR) + { + contactNumber.Insert(L"-",MIN_NUMBER_WITH_ONE_SEPERATOR); + } + } + //update text length + textLength = contactNumber.GetLength(); + + //need to change font to fit inside text box + //With size 94 -> 12 chars, 67 -> 18 chars + int fontSize = pEditField->GetTextSize(); + if((actionId == CLEAR_KEY) && (textLength < MAX_VISIBLE_TXT_WITH_MIN_FONT)) + { + //clearing + fontSize += IDI_DELTA_FONT_SIZE; + } + else if(textLength > MAX_TXT_LENGTH_WITH_SEPERATOR) + { + //appending + fontSize -= IDI_DELTA_FONT_SIZE; + } + + if(fontSize > IDI_MAX_TXT_FONT) + { + fontSize = IDI_MAX_TXT_FONT; + } + if(fontSize < IDI_MIN_TXT_FONT) + { + fontSize = IDI_MIN_TXT_FONT; + } + pEditField->SetTextSize(fontSize); + //set text to edit field + pEditField->SetText(contactNumber); + pEditField->SetCursorPosition(contactNumber.GetLength()); + pEditField->SetFocus(); + AppLogDebug("EXIT"); + return; +} + +//search box +void +DialTabDialer::InitializeSearchBox(void) +{ + AppLogDebug("ENTER"); + + //search panel + Panel* pSearchPanel = static_cast(GetControl(IDC_PANEL_SEARCH_BOX, true)); + pSearchPanel->SetShowState(false); + pSearchPanel->Invalidate(true); + + //"Add to contacts" button + Button* pButtonAddContacts = static_cast(GetControl(IDC_BUTTON_ADD_CONTACTS, true)); + pButtonAddContacts->SetActionId(IDA_BTN_ADD_TO_CONTACTS); + pButtonAddContacts->AddActionEventListener(*this); + Canvas pCanvasNormalAdd; + pCanvasNormalAdd.Construct(pButtonAddContacts->GetBounds()); + Canvas pCanvasPressedAdd; + pCanvasPressedAdd.Construct(pButtonAddContacts->GetBounds()); + DialUtil::Draw9PatchToCanvas(pCanvasNormalAdd, IDB_BTN_OPTION_BG_ICON); + DialUtil::Draw9PatchToCanvas(pCanvasPressedAdd, IDB_BTN_OPTION_PRESS_BG_ICON); + DialUtil::DrawTextToCanvas(IDI_ADD_TO_CONTACTS_STR, FONT_SUGGESTION_NAME, pCanvasNormalAdd, POSITION_CENTER, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(IDI_ADD_TO_CONTACTS_STR, FONT_SUGGESTION_NAME, pCanvasPressedAdd, POSITION_CENTER, BUTTON_STATUS_NORMAL); + DialUtil::DrawCanvasToButton(&pCanvasNormalAdd, &pCanvasPressedAdd, pButtonAddContacts); + pButtonAddContacts->SetShowState(false); + + //"Use Contacts" button + Button* pButtonContacts = static_cast(GetControl(IDC_BUTTON_USE_CONTACT, true)); + pButtonContacts->SetActionId(IDA_BTN_USE_CONTACT_DATA); + pButtonContacts->AddActionEventListener(*this); + //"Drop-Down" Button + Button* pButtonDropDown = static_cast(GetControl(IDC_BUTTON_DROP_DOWN, true)); + pButtonDropDown->SetActionId(IDA_BTN_DISPLAY_CONTACTS); + pButtonDropDown->AddActionEventListener(*this); + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::UpdateSearchResults(void) +{ + AppLogDebug("ENTER"); + + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + //send request to search for suggestion list + String searchStr = pEditField->GetText(); + searchStr.Replace(L"-",L""); + if(searchStr.IsEmpty() == false) + { + __pDialPresentationModel->FetchSuggestionList(searchStr); + } + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::HideSearchBox(void) +{ + Button* pButtonAddContacts = static_cast(GetControl(IDC_BUTTON_ADD_CONTACTS, true)); + pButtonAddContacts->SetShowState(false); + Button* pButtonContacts = static_cast(GetControl(IDC_BUTTON_USE_CONTACT, true)); + Button* pButtonDropDown = static_cast(GetControl(IDC_BUTTON_DROP_DOWN, true)); + pButtonContacts->SetShowState(true); + pButtonDropDown->SetShowState(true); + + Panel* pSearchPanel = static_cast(GetControl(IDC_PANEL_SEARCH_BOX, true)); + pSearchPanel->SetShowState(false); + pSearchPanel->Invalidate(true); + return; +} + +void +DialTabDialer::InitializeSearchListView(void) +{ + //update new bounds + __pSearchListView = static_cast(GetControl(IDC_LISTVIEW_SEARCH,true)); + if(__pSearchListView != null) + { + __pSearchListView->SetSweepEnabled(true); + __pSearchListView->SetItemProvider(*__pSuggestionListProvider); + __pSearchListView->AddListViewItemEventListener(*this); + __pSearchListView->SetBackgroundColor(Color(COLOR_SEARCHLIST_BG)); + Panel* pSearchListPanel = static_cast(GetControl(IDC_PANEL_SEARCH_LIST, true)); + if(pSearchListPanel != null) + { + SetControlAlwaysOnTop(*pSearchListPanel, true); + } + } +} + +void +DialTabDialer::ShowSearchListView(void) +{ + AppLogDebug("ENTER"); + + //find the no. of search rows to be shown - Maximum 5 can be shown. + int noOfItems = MAX_SEARCH_LIST_ITEMS; + if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1)) + { + noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1; + } + if(noOfItems <= 0) + { + return; + } + + + if (__pSearchListView != null) + { + //update new bounds + Rectangle searchListbounds = __pSearchListView->GetBounds(); + searchListbounds.height = H_SEARCHLIST_ITEM * noOfItems; + __pSearchListView->SetBounds(searchListbounds); + __pSearchListView->SetItemProvider(*__pSuggestionListProvider); + } + + Panel* pSearchListPanel = static_cast(GetControl(IDC_PANEL_SEARCH_LIST, true)); + if(pSearchListPanel != null) + { + pSearchListPanel->SetShowState(true); + pSearchListPanel->Invalidate(true); + } + + __isSearchListOpened = true; + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::HideSearchListView(void) +{ + Panel* pSearchListPanel = static_cast(GetControl(IDC_PANEL_SEARCH_LIST, true)); + pSearchListPanel->SetShowState(false); + pSearchListPanel->Invalidate(true); + __isSearchListOpened = false; + return; +} + +void +DialTabDialer::ConstructMenu(void) +{ + AppLogDebug("ENTER"); + + //Construct button for menu open and close + Panel* pDisplayPanel = static_cast(GetControl(IDC_PANEL_DISPLAY_DATA, true)); + Button* pButton = static_cast(GetControl(IDC_BUTTON_MENU, true)); + pButton->SetActionId(IDA_BTN_SHOW_CONTEXTMENU); + pButton->AddActionEventListener(*this); + + Canvas pCanvasNormal; + pCanvasNormal.Construct(pButton->GetBounds()); + Canvas pCanvasPressed; + pCanvasPressed.Construct(pButton->GetBounds()); + + DialUtil::Draw9PatchToCanvas(pCanvasNormal, IDB_BTN_OPTION_BG_ICON); + DialUtil::DrawImageToCanvas(IDB_BTN_MORE_ICON, Dimension(W_MORE_BUTTON, H_MORE_BUTTON), pCanvasNormal, POSITION_CENTER); + DialUtil::Draw9PatchToCanvas(pCanvasPressed, IDB_BTN_OPTION_PRESS_BG_ICON); + DialUtil::DrawImageToCanvas(IDB_BTN_MORE_PRESS_ICON, Dimension(W_MORE_BUTTON, H_MORE_BUTTON), pCanvasPressed, POSITION_CENTER); + DialUtil::DrawCanvasToButton(&pCanvasNormal, &pCanvasPressed, pButton); + pDisplayPanel->Invalidate(true); + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::ConstructKeypad(int dialerState) +{ + AppLogDebug("ENTER"); + if(__pDialKeypad != null) + { + //RemoveControl() also deletes the child control. + RemoveControl(*__pDialKeypad); + __pDialKeypad = null; + } + //Construct Alpha numeric Keypad + if(__pDialKeypad == null) + { + __pDialKeypad = new (std::nothrow) DialerKeypad(DialerKeypad::DialerState(dialerState)); + __pDialKeypad->ConstructPanel(this, this); + //add keypad to dial panel + AddControl(*__pDialKeypad); + } + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + AppLogDebug("ENTER"); + PhoneApp* pPhoneApp = static_cast(PhoneApp::GetInstance()); + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + String editText(L""); + + if(__pCallPresentor == null) + { + __pCallPresentor = CallPresentationModel::GetInstance(); + } + //While coming from Logs scene, disable footer + const Form* pForm = dynamic_cast(GetParent()); + if(pForm != null) + { + pForm->GetFooter()->SetShowState(false); + } + //If previous scene is present & it is either Single Active Call + //or Conf. Call with 'Add Call' scenario. + DialerKeypad::DialerState dialerState = DialerKeypad::DIALER_STATE_FIRST_SCENE; + if (__pCallPresentor->GetCurrentCallCount() > 0) + { + __pPreviousSceneId = new (std::nothrow) SceneId(previousSceneId); + dialerState = DialerKeypad::DIALER_STATE_ADD_CALL; + if(pArgs != null) + { + pArgs->RemoveAll(); + delete pArgs; + } + pArgs = null; + } + else + { + if (pArgs != null) + { + //From AppControl request for normal call + dialerState = DialerKeypad::DIALER_STATE_NORMAL_APPCONTROL; + String* tmpStr = static_cast(pArgs->GetAt(0)); + if(tmpStr != null) + { + editText.Append(*tmpStr); + } + delete pArgs; + pArgs = null; + } + } + + if(editText.IsEmpty() == true) + { + //Fetch auto area code setting, if present + int retvalue = 0; + result res; + SettingsPresentationModel::GetInstance()->GetActivePrefixDialNumber(editText); + res = Integer::Parse(editText,retvalue); + if(res != E_SUCCESS) + { + editText.Clear(); + } + } + + if(pEditField != null) + { + pEditField->SetText(editText); + pEditField->SetCursorPosition(editText.GetLength()); + pEditField->SetFocus(); + pEditField->Invalidate(true); + //show search results + if (editText.GetLength() == 0) + { + HideSearchBox(); + } + else + { + UpdateSearchResults(); + } + } + + //Construct keypad + ConstructKeypad(dialerState); + + //hide footer + Form* form = static_cast(GetParent()); + form->GetFooter()->SetShowState(false); + pPhoneApp->AddAppStateChangeListener(*this); + //Add addressbook listener to listen to contacts changed events + if(__pAddressBook != null) + { + __pAddressBook->SetEventListener(this); + } + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + AppLogDebug("ENTER"); + PhoneApp* pPhoneApp = static_cast(PhoneApp::GetInstance()); + //hide search result list, if shown. + if (__isSearchListOpened == true) + { + HideSearchListView(); + } + if(__pPreviousSceneId != null) + { + delete __pPreviousSceneId; + __pPreviousSceneId = null; + } + if(__pConfirmationPopup != null) + { + delete __pConfirmationPopup; + __pConfirmationPopup = null; + } + pPhoneApp->RemoveAppStateChangeListener(*this); + //remove contact change event listener + if(__pAddressBook != null) + { + __pAddressBook->SetEventListener(null); + } + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::OnActionPerformed(const Control& source, int actionId) +{ + AppLogDebug("ENTER"); + + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField == null || GetAppControlLaunched() == true) + { + AppLogDebug("GetAppControlLaunched() == true"); + return; + } + + switch (actionId) + { + case NUM_KEY1: + case NUM_KEY2: + case NUM_KEY3: + case NUM_KEY4: + case NUM_KEY5: + case NUM_KEY6: + case NUM_KEY7: + case NUM_KEY8: + case NUM_KEY9: + case NUM_KEY0: + case CLEAR_KEY: + { + //append / clear last character to contact + ShowFormattedText(pEditField, actionId); + if (pEditField->GetTextLength() == 0) + { + __pDialPresentationModel->ClearSearchResults(); + HideSearchBox(); + } + else + { + UpdateSearchResults(); + } + } + break; + + case CALL_KEY: + { + if (pEditField->GetTextLength() > 0) + { + String contactNo = pEditField->GetText(); + contactNo.Replace(L"-",L""); + SwitchToOutgoingCallScreen(contactNo); + return; + } + else + { + //show latest dialed or incoming number from Logs + String* number = __pDialPresentationModel->FetchLatestNumberFromLogsN(); + if(number != null) + { + pEditField->SetText(*number); + UpdateSearchResults(); + delete number; + } + } + } + break; + + case PAUSE_KEY: + { + pEditField->AppendText(L"*"); + if (pEditField->GetTextLength() == 0) + { + HideSearchBox(); + } + else + { + UpdateSearchResults(); + } + } + break; + + case HASH_KEY: + { + pEditField->AppendText(L"#"); + if (pEditField->GetTextLength() == 0) + { + HideSearchBox(); + } + else + { + UpdateSearchResults(); + } + } + break; + + case VIDEOCALL_KEY: + { + //Not yet Supported + } + break; + + case CANCEL_KEY: + { + PhoneApp* pApp = static_cast(UiApp::GetInstance()); + bool isAppControl = pApp->IsOpenAsAppControl(); + if(isAppControl == true && __pPreviousSceneId == null) + { + pApp->Terminate(); + } + else if(__pCallPresentor->GetCurrentCallCount() > 0) + { + //Switch back to previous screen + SwitchToPreviousActiveCallScreen(); + return; + } + } + break; + + case IDA_BTN_SHOW_CONTEXTMENU: + { + // Show the ContextMenu + String contactNo = pEditField->GetText(); + contactNo.Replace(L"-",L""); + ShowContextMenu(contactNo); + if (__isSearchListOpened == true) + { + HideSearchListView(); + } + } + break; + + case IDA_MENU_SEND_MESSAGE: + { + String contactNo = pEditField->GetText(); + contactNo.Replace(L"-",L""); + __pDialPresentationModel->OpenMessagingAppControl(contactNo); + return; + } + break; + + case IDA_BTN_ADD_TO_CONTACTS: + case IDA_MENU_ADD_CONTACT: + { + if(pEditField->GetTextLength() > 0) + { + String contactNo = pEditField->GetText(); + contactNo.Replace(L"-",L""); + __pDialPresentationModel->AddContactsToAddressBook(contactNo); + SetAppControlLaunched(true); + return; + } + } + break; + + case IDA_SPEEDDIAL_POPUP_YES: + { + __pConfirmationPopup->SetShowState(false); + SwitchToSpeedDialForm(); + } + break; + + case IDA_SPEEDDIAL_POPUP_NO: + { + __pConfirmationPopup->SetShowState(false); + Invalidate(true); + } + break; + + case IDA_MENU_SPEED_DIAL: + { + SwitchToSpeedDialForm(); + return; + } + break; + + case IDA_MENU_ADD_PAUSE: + { + AddPause(); + } + break; + + case IDA_MENU_ADD_WAIT: + { + AddWait(); + } + break; + + case IDA_MENU_EXIT: + { + if(__pCallPresentor->GetCurrentCallCount() > 0) + { + //Switch back to previous screen + SwitchToPreviousActiveCallScreen(); + return; + } + else + { + //Close Phone App + UiApp::GetInstance()->Terminate(); + } + } + break; + + case IDA_BTN_USE_CONTACT_DATA: + { + DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0); + if(pDialInfo != null) + { + //fetch contact number + String phNumber = pDialInfo->GetPhoneNumber(); + if(phNumber.Equals(pEditField->GetText()) == false) + { + pEditField->Clear(); + pEditField->SetText(phNumber); + pEditField->Invalidate(true); + if (__isSearchListOpened == true) + { + HideSearchListView(); + } + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } + } + } + break; + + case IDA_BTN_DISPLAY_CONTACTS: + { + if (__isSearchListOpened == true) + { + HideSearchListView(); + } + else + { + ShowSearchListView(); + } + } + break; + + default: + break; + } + pEditField->Invalidate(true); + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector) +{ + AppLogDebug("ENTER"); + + if (gestureDetector.GetControl() != null) + { + Button* pButton = static_cast(gestureDetector.GetControl()); + int actionId = pButton->GetActionId(); + switch(actionId) + { + case NUM_KEY2: + case NUM_KEY3: + case NUM_KEY4: + case NUM_KEY5: + case NUM_KEY6: + case NUM_KEY7: + case NUM_KEY8: + case NUM_KEY9: + { + //Check if Speed Dial setting exist for pressed key + String* contactNumber = __pDialPresentationModel->FetchSpeedDialNumberN(actionId); + if(contactNumber != null) + { + ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pArgs->Construct(); + //pass ownership to arraylist + pArgs->Add(contactNumber); + SendUserEvent(REQUEST_CALL_SPEED_DIAL_NUM,pArgs); + } + else + { + //show speed Dial Confirmation Popup msg + SendUserEvent(REQUEST_SHOW_SPEED_DIAL_POPUP,null); + } + + } + break; + + case PAUSE_KEY: + { + AddPause(); + } + break; + + case HASH_KEY: + { + //Handle Mute / UnMute + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if(pEditField->GetTextLength() == 0) + { + bool enabled = false; + String title = L"http://tizen.org/setting/sound.silent_mode"; + SettingInfo::GetValue(title, enabled); + //enable or disable the phone silent mode. + result r = E_FAILURE; + r = SettingInfo::SetValue(title, !enabled); + if(r == E_OBJ_NOT_FOUND) + { + AppLog("Object not found"); + } + } + } + break; + + case CLEAR_KEY: + { + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField != null && pEditField->GetTextLength() > 0) + { + pEditField->Clear(); + pEditField->SetTextSize(IDI_MAX_TXT_FONT); + pEditField->SetCursorPosition(0); + pEditField->SetFocus(); + pEditField->Invalidate(true); + HideSearchBox(); + } + } + break; + case NUM_KEY0: + { + AddPlus(); + } + break; + + default: + break; + } + } + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::ShowContextMenu(String& contactNumber) +{ + AppLogDebug("ENTER"); + + if(__pContextMenu != null) + { + delete __pContextMenu; + __pContextMenu = null; + } + __pContextMenu = new (std::nothrow) ContextMenu(); + __pContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST); + + //minimum available option count + int visibleItems = MIN_CONTEXT_MENU_ITEMS; + + //Show SendMsg Option only if NOT opened from Outgoing Call + if(__pPreviousSceneId == null) + { + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SEND_MSG), IDA_MENU_SEND_MESSAGE); + visibleItems++; + } + //Don't show 'AddContact' if empty text field + //or contact number is already saved. + if(contactNumber.IsEmpty() != true) + { + Contact* pContact = __pCallPresentor->GetContactN(contactNumber); + if(pContact == null) + { + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_CONTACT), IDA_MENU_ADD_CONTACT); + visibleItems++; + } + else + { + delete pContact; + } + } + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SPEED_DIAL), IDA_MENU_SPEED_DIAL); + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_PAUSE), IDA_MENU_ADD_PAUSE); + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_WAIT), IDA_MENU_ADD_WAIT); + __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_EXIT), IDA_MENU_EXIT); + __pContextMenu->AddActionEventListener(*this); + + __pContextMenu->SetMaxVisibleItemsCount(visibleItems); + // Set the anchor position of the ContextMenu + __pContextMenu->SetAnchorPosition(Point(X_CONTEXT_MENU_ANCHOR, Y_CONTEXT_MENU_ANCHOR)); + // Show the ContextMenu + __pContextMenu->Show(); + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::AddPause(void) +{ + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField != null) + { + pEditField->AppendText(L";"); + if (pEditField->GetTextLength() == 0) + { + HideSearchBox(); + } + else + { + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } + pEditField->Invalidate(true); + } + return; +} + +void +DialTabDialer::AddWait(void) +{ + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField != null) + { + pEditField->AppendText(L","); + if (pEditField->GetTextLength() == 0) + { + HideSearchBox(); + } + else + { + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } + pEditField->Invalidate(true); + } + return; +} + +void +DialTabDialer::AddPlus(void) +{ + EditField* pEditField = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if (pEditField != null) + { + pEditField->AppendText(L"+"); + if (pEditField->GetTextLength() == 0) + { + HideSearchBox(); + } + else + { + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } + pEditField->Invalidate(true); + } + return; +} + +void +DialTabDialer::SwitchToPreviousActiveCallScreen(void) +{ + AppLogDebug("ENTER"); + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + if(__pCallPresentor == null) + { + __pCallPresentor = CallPresentationModel::GetInstance(); + } + //Fetch call info list + IListT* pCallList = __pCallPresentor->GetCallListN(); + IEnumeratorT* pCallEnum = pCallList->GetEnumeratorN(); + if(pCallEnum != null) + { + ArrayList* pCallArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + pCallArgs->Construct(); + while(pCallEnum->MoveNext() == E_SUCCESS) + { + CallInfo callInfo; + if(pCallEnum->GetCurrent(callInfo) == E_SUCCESS) + { + CallInfo* pActiveCall = new (std::nothrow) CallInfo(); + *pActiveCall = callInfo; + pCallArgs->Add(pActiveCall); + } + } + + if(pCallArgs->GetCount() == 1 && (static_cast(pCallArgs->GetAt(0)))->IsConferenceCall() == true) + { + //move back to previous conf. call screen - ownership of 'pCallArgs' transferred + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallArgs); + } + else + { + //move back to previous screen - ownership of 'pCallArgs' transferred + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallArgs); + } + + delete pCallEnum; + pCallEnum = null; + } + delete pCallList; + pCallList = null; + AppLogDebug("EXIT"); +} + +void +DialTabDialer::SwitchToOutgoingCallScreen(const String& contactNumber) +{ + AppLogDebug("ENTER"); + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + //Check if dialing a call is possible + if(__pCallPresentor == null) + { + __pCallPresentor = CallPresentationModel::GetInstance(); + } + bool isSimInitialized = __pCallPresentor->CheckSimInitializationIsCompleted(); + if (isSimInitialized == true) + { + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(contactNumber); + //switch to dialing outgoing call form + ArrayList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter); + pContact->Construct(1); + pContact->Add(contactTxt); + //Check if dialing an emergency call + bool isEmergencyCall = __pCallPresentor->IsEmergencyNumber(*contactTxt, true); + if (isEmergencyCall) + { + pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact); + } + else + { + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact); + } + } + else + { + //TODO: check what to do for SOS calls + //Show error message Popup + if (__pErrorMsgPopup == null) + { + __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this); + } + __pErrorMsgPopup->ShowErrorMsgPopupN(ERROR_CODE_SIM_INITIALIZATION_FAILED); + } + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::SwitchToSpeedDialForm(void) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null); + return; +} + +void +DialTabDialer::ShowSpeedDialConfirmationPopup(void) +{ + if(__pConfirmationPopup == null) + { + Rectangle rect = GetBounds(); + __pConfirmationPopup = new (std::nothrow) Popup(); + __pConfirmationPopup->Construct(false, Dimension(rect.width, H_SPEEDDIAL_POPUP)); + + rect = __pConfirmationPopup->GetBounds(); + Label* pMsgLabel = new (std::nothrow) Label(); + String popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG); + pMsgLabel->Construct(Rectangle(0, IDI_PADDING, rect.width, H_POPUP_MSG_LABEL), popupMsg); + pMsgLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pMsgLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + __pConfirmationPopup->AddControl(*pMsgLabel); + + rect = pMsgLabel->GetBounds(); + Button *pButtonYes = new (std::nothrow) Button(); + String btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_YES_BTN_STRING); + pButtonYes->Construct(Rectangle(rect.x, (rect.y + rect.height + IDI_PADDING), ((rect.width - (6 * IDI_PADDING)) / 2), H_POPUP_BTN), btnName); + pButtonYes->SetActionId(IDA_SPEEDDIAL_POPUP_YES); + pButtonYes->AddActionEventListener(*this); + __pConfirmationPopup->AddControl(*pButtonYes); + + rect = pButtonYes->GetBounds(); + Button *pButtonNo = new (std::nothrow) Button(); + btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_NO_BTN_STRING); + pButtonNo->Construct(Rectangle((rect.x + rect.width + IDI_PADDING), rect.y, rect.width, rect.height), btnName); + pButtonNo->SetActionId(IDA_SPEEDDIAL_POPUP_NO); + pButtonNo->AddActionEventListener(*this); + __pConfirmationPopup->AddControl(*pButtonNo); + } + //Show Popup message + __pConfirmationPopup->SetShowState(true); + __pConfirmationPopup->Show(); +} + +void +DialTabDialer::ShowAddToContactsButton(void) +{ + Panel* pSearchPanel = static_cast(GetControl(IDC_PANEL_SEARCH_BOX, true)); + Button* pButtonContacts = static_cast(GetControl(IDC_BUTTON_USE_CONTACT, true)); + Button* pButtonDropDown = static_cast(GetControl(IDC_BUTTON_DROP_DOWN, true)); + Button* pButtonAddContacts = static_cast(GetControl(IDC_BUTTON_ADD_CONTACTS, true)); + pButtonContacts->SetShowState(false); + pButtonDropDown->SetShowState(false); + pButtonAddContacts->SetShowState(true); + pSearchPanel->SetShowState(true); + pSearchPanel->Invalidate(true); + return; +} + +void +DialTabDialer::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs) +{ + switch(requestId) + { + case REQUEST_SHOW_SUGGESTION: + { + String *displayname = static_cast (pArgs->GetAt(0)); + String *mobileNo = static_cast (pArgs->GetAt(1)); + String *resultCount = static_cast (pArgs->GetAt(2)); + if(displayname != null && mobileNo != null && resultCount != null) + { + ShowSuggestionBox(*displayname, *mobileNo, *resultCount); + } + delete pArgs; + } + break; + + case REQUEST_SHOW_ADD_TO_CONTACTS: + { + ShowAddToContactsButton(); + } + break; + + case REQUEST_CALL_SPEED_DIAL_NUM: + { + if(pArgs != null) + { + String *number = static_cast (pArgs->GetAt(0)); + //dial a call. + if(number != null) + { + SwitchToOutgoingCallScreen(*number); + } + delete pArgs; + } + } + break; + + case REQUEST_SHOW_SPEED_DIAL_POPUP: + { + //show speed Dial Confirmation Popup msg + ShowSpeedDialConfirmationPopup(); + } + break; + } + +} +void +DialTabDialer::ShowSuggestionBox(String& name, String& mobileNo, String& resultCount) +{ + AppLogDebug("ENTER"); + + //"UseContact" Button + Button* pButtonContacts = static_cast(GetControl(IDC_BUTTON_USE_CONTACT, true)); + Canvas pCanvasNormalContacts; + pCanvasNormalContacts.Construct(pButtonContacts->GetBounds()); + Canvas pCanvasPressedContacts; + pCanvasPressedContacts.Construct(pButtonContacts->GetBounds()); + String mobileStr = AppUtility::GetResourceString(IDS_DIALER_MOBILE_STR); + //Add text, Bg to normal state + DialUtil::Draw9PatchToCanvas(pCanvasNormalContacts, IDB_BTN_OPTION_BG_ICON); + DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasNormalContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasNormalContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasNormalContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL); + //Add text, Bg to pressed state + DialUtil::Draw9PatchToCanvas(pCanvasPressedContacts, IDB_BTN_OPTION_PRESS_BG_ICON); + DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasPressedContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasPressedContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL); + DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasPressedContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL); + //add normal, pressed bg bitmap to button + DialUtil::DrawCanvasToButton(&pCanvasNormalContacts, &pCanvasPressedContacts, pButtonContacts); + + //"DropDown" Button + Button* pButtonDropDown = static_cast(GetControl(IDC_BUTTON_DROP_DOWN, true)); + Canvas pCanvasNormalDropDown; + pCanvasNormalDropDown.Construct(pButtonDropDown->GetBounds()); + Canvas pCanvasPressedDropDown; + pCanvasPressedDropDown.Construct(pButtonDropDown->GetBounds()); + //Add text, Bg to normal state + DialUtil::Draw9PatchToCanvas(pCanvasNormalDropDown, IDB_BTN_OPTION_BG_ICON); + DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasNormalDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL); + DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalDropDown, POSITION_BOTTOM_CENTER); + //Add text, Bg to pressed state + DialUtil::Draw9PatchToCanvas(pCanvasPressedDropDown, IDB_BTN_OPTION_PRESS_BG_ICON); + DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasPressedDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL); + DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedDropDown, POSITION_BOTTOM_CENTER); + //add background to button + DialUtil::DrawCanvasToButton(&pCanvasNormalDropDown, &pCanvasPressedDropDown, pButtonDropDown); + + Button* pButtonAddContacts = static_cast(GetControl(IDC_BUTTON_ADD_CONTACTS, true)); + pButtonContacts->SetShowState(true); + pButtonDropDown->SetShowState(true); + pButtonDropDown->Invalidate(true); + pButtonAddContacts->SetShowState(false); + + Panel* pSearchPanel = static_cast(GetControl(IDC_PANEL_SEARCH_BOX, true)); + pSearchPanel->SetShowState(true); + pSearchPanel->Invalidate(true); + + AppLogDebug("EXIT"); + return; +} + +void +DialTabDialer::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status) +{ + DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(index+1); + if(pDialInfo != null) + { + String phNumber = pDialInfo->GetPhoneNumber(); + EditField* pTextBox = static_cast(GetControl(IDC_NUMERIC_EDITFIELD, true)); + if(pTextBox != null) + { + pTextBox->Clear(); + pTextBox->SetText(phNumber); + pTextBox->Invalidate(true); + } + HideSearchListView(); + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } + return; +} + +void +DialTabDialer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus) +{ + Form* pForm = static_cast(GetParent()); + pForm->SetOrientation(ORIENTATION_PORTRAIT); + pForm->Invalidate(true); + return; +} + +void +DialTabDialer::HandlePopupClosed(void) +{ + Draw(); + delete __pErrorMsgPopup; + __pErrorMsgPopup = null; + return; +} + +bool +DialTabDialer::IsOpenedFromOtherView(void) +{ + if(__pPreviousSceneId != null) + { + return true; + } + return false; +} + +void +DialTabDialer::OnForeground(void) +{ + AppLogDebug("Enter"); + __isAppForeground = true; + //If app control was launched + //as we do not know if it success or failed + // we need to UpdateSearchResults + //Returned from app control if app control does not + //send any response we need to do this + SetAppControlLaunched(false); +} + +void +DialTabDialer::OnBackground(void) +{ + AppLogDebug("Enter"); + __isAppForeground = false; +} + +bool +DialTabDialer::IsForeground() +{ + AppLogDebug("Enter %d",__isAppForeground); + return __isAppForeground; +} + +void +DialTabDialer::OnContactsChanged(const IList& contactChangeInfoList) +{ + if(contactChangeInfoList.GetCount() > 0) + { + //clear old search results + __pDialPresentationModel->ClearSearchResults(); + UpdateSearchResults(); + } +} + +void +DialTabDialer::SetAppControlLaunched(bool launched) +{ + AppLogDebug("%d",__isAppControlLaunched); + __isAppControlLaunched = launched; +} + +bool +DialTabDialer::GetAppControlLaunched(void) +{ + AppLogDebug("%d",__isAppControlLaunched); + return __isAppControlLaunched; +} + + diff --git a/src/PhnTabFavorites.cpp b/src/PhnTabFavorites.cpp new file mode 100644 index 0000000..92c1664 --- /dev/null +++ b/src/PhnTabFavorites.cpp @@ -0,0 +1,92 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabFavorites.cpp + * @brief The Favorites Tab + */ + +#include "PhnTabFavorites.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +DialTabFavorites::DialTabFavorites(void) +{ + +} + +DialTabFavorites::~DialTabFavorites(void) +{ + +} + +bool +DialTabFavorites::Initialize(void) +{ + result r = Construct(L"IDL_PANEL_FAVORITES"); + if (IsFailed(r)) + return false; + + return true; +} + +result +DialTabFavorites::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Layout setting + const Form* pForm = dynamic_cast(GetParent()); + if (pForm != null) + { + RelativeLayout* pRelativeLayout = dynamic_cast(pForm->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + pRelativeLayout = dynamic_cast(pForm->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + } + return r; +} + +result +DialTabFavorites::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +DialTabFavorites::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ +} + +void +DialTabFavorites::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ +} diff --git a/src/PhnTabLogs.cpp b/src/PhnTabLogs.cpp new file mode 100644 index 0000000..7f2a478 --- /dev/null +++ b/src/PhnTabLogs.cpp @@ -0,0 +1,638 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabLogs.cpp + * @brief The Logs Tab + */ + +#include +#include +#include +#include "PhnPhoneApp.h" +#include "PhnAppUtility.h" +#include "PhnSettingsConstants.h" +#include "PhnCommonUtils.h" +#include "PhnTabLogs.h" +#include "PhnSceneRegister.h" +#include "PhnCalllogManager.h" +#include "PhnCallPresentationModel.h" +#include "PhnTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Scenes; + +const int W_NOCONTENTS_IMAGE = 280; +const int H_NOCONTENTS_IMAGE = 280; +//List view height +const int H_TOAST_MSG = 48; +const int H_SELECTALL_CHK_BOX = 112; + +const wchar_t* IDL_PANEL_LOGS = L"IDL_PANEL_LOGS"; +const wchar_t* IDC_LABEL_SELECTED_POPUP = L"IDC_LABEL_SELECTED_POPUP"; +const unsigned int COLOR_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value; + +DialTabLogs::DialTabLogs(void) +{ + __pDataProvider = new CustomDataProvider(); + __pFormFooter = null; + __plogsListView = null; + __isEditMode = false; + __pButtonSelectAll = null; + __groupCount = 0; + __itemCount = 0; + __isSelectAll = false; + __selectedItemCount = 0; + __pCallMgr = null; + __pArgs = null; +} + +DialTabLogs::~DialTabLogs(void) +{ + if (__pDataProvider != null) + { + delete __pDataProvider; + __pDataProvider = null; + } + if (__pCallMgr != null) + { + __pCallMgr = null; + } +} + +bool +DialTabLogs::Initialize(void) +{ + result r = Construct(IDL_PANEL_LOGS); + TryCatch(r == E_SUCCESS, , "DialTabLogs::Initialise() - Fail to initialise Call log panel"); + return true; + + CATCH: + return false; +} + +result +DialTabLogs::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Layout setting + const Form* pForm = dynamic_cast(GetParent()); + if(pForm == null) + { + return E_FAILURE; + } + + RelativeLayout* pRelativeLayout = dynamic_cast(pForm->GetLandscapeLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + + pRelativeLayout = dynamic_cast(pForm->GetPortraitLayoutN()); + if (pRelativeLayout != null) + { + pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); + pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); + delete pRelativeLayout; + } + + __pFormFooter = pForm->GetFooter(); + if (__pFormFooter != null) + { + __pFormFooter->SetShowState(true); + __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + __pFormFooter->AddActionEventListener(*this); + + __footerItemDelete.Construct(IDA_FOOTER_LOG_DELETE); + String delStr = AppUtility::GetResourceString(IDS_DELETE_BTN_STRING); + __footerItemDelete.SetText(delStr); + __pFormFooter->AddItem(__footerItemDelete); + String cancelStr = AppUtility::GetResourceString(IDS_CANCEL_BTN_STRING); + __footerItemCancel.Construct(IDA_FOOTER_LOG_CANCEL); + __footerItemCancel.SetText(cancelStr); + } + + __pButtonSelectAll = static_cast(GetControl("IDC_CHECKBUTTON_SELECTALL")); + if (__pButtonSelectAll != null) + { + __pButtonSelectAll->SetShowState(false); + __pButtonSelectAll->SetActionId(IDA_CHECKBUTTON_SELECT_ALL, IDA_CHECKBUTTON_UNSELECT_ALL); + __pButtonSelectAll->AddActionEventListener(*this); + __pButtonSelectAll->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + } + + //create a list view + __plogsListView = new (std::nothrow) GroupedListView(); + if (__plogsListView != null) + { + __plogsListView->Construct(Rectangle(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT); + __plogsListView->AddGroupedListViewItemEventListener(*this); + Bitmap* pNoContentBitmap = AppUtility::GetBitmapFromResourcesN(IDB_LOG_NO_CONTENT,W_NOCONTENTS_IMAGE,H_NOCONTENTS_IMAGE); + if(pNoContentBitmap != null) + { + __plogsListView->SetBitmapOfEmptyList(pNoContentBitmap); + } + __plogsListView->SetTextOfEmptyList(AppUtility::GetResourceString(IDS_NO_LOGS)); + __plogsListView->SetTextColorOfEmptyList(Color(128,128,128)); + r = AddControl(*__plogsListView); + TryCatch(r == E_SUCCESS, , "Calllog list control not added"); + } + + __pSelectedLabel = static_cast(GetControl(IDC_LABEL_SELECTED_POPUP)); + if(__pSelectedLabel != null) + { + SetControlAlwaysOnTop(*__pSelectedLabel,true); + __pSelectedLabel->SetBackgroundColor(COLOR_LABEL_SELECTED); + __pSelectedLabel->SetShowState(false); + } + + CATCH: + return r; +} + +result +DialTabLogs::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +DialTabLogs::DeleteSelectedCalllog(void) +{ + CallLogDetails* pCalllogInfo = null; + int itemCount = 0; + + if(__selectedItemCount == __pCallMgr->GetAllCalllogCount()) + { + __pCallMgr->DeleteAllCalllog(); + __pDataProvider->DeleteAllItems(); + } + else + { + for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++) + { + itemCount = __plogsListView->GetItemCountAt(groupIndex); + for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--) + { + bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex); + if(isSelected == true) + { + __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo); + if(pCalllogInfo != null) + { + __pCallMgr->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId()); + __pDataProvider->DeleteItemAtGroupIndex(groupIndex, itemIndex); + } + } + } + } + } +} + +void +DialTabLogs::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + __pCallMgr = CallLogManager::GetInstance(); + __pCallMgr->AddCalllogChangeListener(*this); + + __plogsListView->SetItemProvider(*__pDataProvider); + //Reset the delete status + //SetCallLogDisplayMode(false); + + //Check if opened in edit mode + if(__isEditMode == true) + { + //Check if "select all" is already selected + if (__pButtonSelectAll->IsSelected() == true) + { + HandleAllItemSelection(); + } + //If there is no items selected the reset the display mode + else if(__selectedItemCount == 0) + { + SetCallLogDisplayMode(false); + } + } + + if (__pFormFooter != null) + { + __pFormFooter->SetShowState(true); + __pFormFooter->SetBackButton(); + if(__pCallMgr->GetAllCalllogCount() > 0) + { + __pFormFooter->SetItemEnabled(0, true); + } + else + { + __pFormFooter->SetItemEnabled(0, false); + } + } +} + +void +DialTabLogs::HandleAllItemSelection(void) +{ + SetListItemSelectStatus(true); + __itemCount = __pCallMgr->GetAllCalllogCount(); + __selectedItemCount = __itemCount; + String text; + String selItemStr = L""; + if(__selectedItemCount > 1) + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING); + } + else + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING); + } + text.Format(100, selItemStr.GetPointer(), __itemCount); + __pSelectedLabel->SetText(text); + __pSelectedLabel->Invalidate(false); +} + +void +DialTabLogs::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + if (__pCallMgr != null) + { + __pCallMgr->RemoveCalllogChangeListner(*this); + __pCallMgr = null; + } + __pFormFooter->RemoveBackButton(); +} + +void +DialTabLogs::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus state) +{ + if (__isEditMode == false) + { + __pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); + __pArgs->Construct(); + CallLogDetails* pCalllogInfo = null; + __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo); + if(pCalllogInfo != null && pCalllogInfo->GetPhoneNumber() == null) + { + //handling hidden call + return; + } + if(pCalllogInfo != null) + { + __pArgs->Add((new String(pCalllogInfo->GetPhoneNumber()))); + } + SceneManager* pSceneManager = SceneManager::GetInstance(); + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_CALL_LOG_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY), __pArgs); + __pArgs = null; + } + else + { + String text; + if (state == LIST_ITEM_STATUS_CHECKED) + { + __selectedItemCount++; + } + else if (state == LIST_ITEM_STATUS_UNCHECKED) + { + __selectedItemCount--; + } + if (__selectedItemCount == __itemCount) + { + __pButtonSelectAll->SetSelected(true); + } + else + { + __pButtonSelectAll->SetSelected(false); + } + if (__selectedItemCount == 0) + { + __pFormFooter->SetItemEnabled(0, false); + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + } + else + { + __pFormFooter->SetItemEnabled(0, true); + String selItemStr = L""; + if(__selectedItemCount > 1) + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING); + } + else + { + selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING); + } + text.Format(100, selItemStr.GetPointer(), __selectedItemCount); + __pSelectedLabel->SetText(text); + } + __pFormFooter->Invalidate(true); + __pButtonSelectAll->Invalidate(false); + __pSelectedLabel->Invalidate(false); + } +} + +void +DialTabLogs::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus state) +{ + //Empty implementation + CallLogDetails* pCalllogInfo = null; + __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo); + if(pCalllogInfo != null) + { + + switch (elementId) + { + case IDA_LIST_ELEMENT_DELETE: + { + if(pCalllogInfo != null) + { + __pCallMgr->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId()); + __pDataProvider->DeleteItemAtGroupIndex(groupIndex, itemIndex); + if(__pCallMgr->GetAllCalllogCount() > 0) + { + __pFormFooter->SetItemEnabled(0, true); + } + else + { + __pFormFooter->SetItemEnabled(0, false); + } + __pFormFooter->Invalidate(true); + } + } + break; + case IDA_LIST_ELEMENT_CALL: + { + SceneManager* pSceneManager = SceneManager::GetInstance(); + CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); + char* pPhoneNumber = pCalllogInfo->GetPhoneNumber(); + if(pPhoneNumber == null) + { + break; + } + String phoneNumber=L""; + phoneNumber.Append(pPhoneNumber); + //make an outgoing call with given number + String* contactTxt = new (std::nothrow) String(phoneNumber); + //switch to dialing outgoing call form + IList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter); + pContact->Add(contactTxt); + //Check if dialing an emergency call + bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true); + if (isEmergencyCall) + { + pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact); + } + else + { + pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact); + } + + } + break; + case IDA_LIST_ELEMENT_MESSAGE: + { + result r = E_SUCCESS; + char* pPhoneNumber = pCalllogInfo->GetPhoneNumber(); + if(pPhoneNumber == null) + { + break; + } + String phoneNumber=L""; + phoneNumber.Append(pPhoneNumber); + + HashMap extraData; + extraData.Construct(); + + extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE)); + extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(phoneNumber)); + + AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE); + if (pAc != null) + { + r = pAc->Start(null, null, &extraData, null); + + delete pAc; + } + + extraData.RemoveAll(true); + + } + break; + case IDA_LIST_ELEMENT_VIDEO_CALL: + { + //todo: call once video call implemented + } + break; + default: + break; + } + } + listView.UpdateList(); +} + +void +DialTabLogs::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction) +{ + //Empty implementation +} + +void +DialTabLogs::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case IDA_FOOTER_LOG_DELETE: + { + if (__isEditMode == false) + { + SetCallLogDisplayMode(true); + } + else + { + //Delete selected items + DeleteSelectedCalllog(); + SetCallLogDisplayMode(false); + } + } + break; + + case IDA_FOOTER_LOG_CANCEL: + { + SetCallLogDisplayMode(false); + } + break; + + case IDA_CHECKBUTTON_SELECT_ALL: + { + HandleAllItemSelection(); + } + break; + + case IDA_CHECKBUTTON_UNSELECT_ALL: + { + SetListItemSelectStatus(false); + __selectedItemCount = 0; + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + __pSelectedLabel->Invalidate(false); + } + break; + + default: + break; + } +} + +void +DialTabLogs::SetListItemSelectStatus(bool status) +{ + int groupIndex = 0; + int itemIndex = 0; + int itemCount = 0; + + __isSelectAll = status; + for (; groupIndex < __groupCount; groupIndex++) + { + itemCount = __plogsListView->GetItemCountAt(groupIndex); + for (itemIndex = 0; itemIndex < itemCount; itemIndex++) + { + __plogsListView->SetItemChecked(groupIndex, itemIndex, status); + } + } + __pFormFooter->SetItemEnabled(0, status); + __pFormFooter->Invalidate(true); + __plogsListView->Invalidate(true); +} + +void +DialTabLogs::SetCallLogDisplayMode(bool isEdit) +{ + int groupIndex = 0; + int itemCount = 0; + + if(isEdit == __isEditMode) + { + return; + } + + for (; groupIndex < __groupCount; groupIndex++) + { + itemCount += __plogsListView->GetItemCountAt(groupIndex); + } + __itemCount = __pCallMgr->GetAllCalllogCount();//itemCount; + __groupCount = __plogsListView->GetGroupCount(); + __pButtonSelectAll->SetSelected(false); + if (isEdit == false) + { + __isEditMode = false; + __pDataProvider->SetListItemStyle(false); + __plogsListView->SetSweepEnabled(true); + const Form* pForm = dynamic_cast(GetParent()); + if(pForm == null) + { + return; + } + __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height); + __plogsListView->UpdateList(); + __pFormFooter->RemoveItemAt(1); + __pFormFooter->SetBackButton(); + if(__pCallMgr->GetAllCalllogCount() > 0) + { + __pFormFooter->SetItemEnabled(0, true); + } + else + { + __pFormFooter->SetItemEnabled(0, false); + } + + __pButtonSelectAll->SetShowState(false); + __pSelectedLabel->SetShowState(false); + __pSelectedLabel->Invalidate(false); + } + else + { + __isEditMode = true; + const Form* pForm = dynamic_cast(GetParent()); + if(pForm == null) + { + return; + } + __pDataProvider->SetListItemStyle(isEdit); + __plogsListView->SetSweepEnabled(false); + + //reset size to allow "SELECT ALL" & "TOAST MSG" + Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG)); + __plogsListView->SetBounds(newRect); + UnCheckAllItems(); + __plogsListView->UpdateList(); + __pFormFooter->AddItem(__footerItemCancel); + __pFormFooter->RemoveBackButton(); + __pButtonSelectAll->SetShowState(true); + __pFormFooter->SetItemEnabled(0, false); + __pFormFooter->Invalidate(false); + __selectedItemCount = 0; + String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG); + __pSelectedLabel->SetText(selStr); + __pSelectedLabel->SetShowState(true); + __pSelectedLabel->Invalidate(false); + } + Draw(); +} + +void +DialTabLogs::UnCheckAllItems(void) +{ + int itemCount = 0; + for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++) + { + itemCount = __plogsListView->GetItemCountAt(groupIndex); + for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--) + { + bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex); + if(isSelected == true) + { + __plogsListView->SetItemChecked(groupIndex,itemIndex,false); + } + } + } + __selectedItemCount = 0; +} + +void DialTabLogs::OnCalllogChanged(void) +{ + // If select all was selected before and some new calls are added (Auto rejeted call) + //Then we will not update the call log list. + if(__isEditMode == false) + { + if(__pCallMgr->GetAllCalllogCount() > 0) + { + __pFormFooter->SetShowState(true); + __pFormFooter->SetItemEnabled(0,true); + __pFormFooter->Invalidate(true); + } + __plogsListView->UpdateList(); + __plogsListView->Invalidate(false); + } +} diff --git a/src/PhnTabLogsItemProvider.cpp b/src/PhnTabLogsItemProvider.cpp new file mode 100644 index 0000000..973c5bd --- /dev/null +++ b/src/PhnTabLogsItemProvider.cpp @@ -0,0 +1,709 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTabLogsItemProvider.cpp + * @brief Call log item provider + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "PhnAppUtility.h" +#include "PhnCommonUtils.h" +#include "PhnSettingsConstants.h" +#include "PhnTabLogsItemProvider.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Media; +using namespace Tizen::Social; +using namespace Tizen::System; + +const int MAX_TWELVEHOUR_FORMAT = 12; +const int MAX_TWELVEHOUR_FORMAT_LENGTH = 8; +const int H_LOG_ITEM = 128; +const int H_LOG_ITEM_TEXT = 50; +const int W_LOG_ITEM_TEXT = 50; +const int LOG_ITEM_FONT_SIZE = 32; + +const wchar_t* IDS_MSG_CONTEXT_ITEM = L"IDS_MSG_BTN_NAME"; +const wchar_t* IDS_VIDEO_CALL_CONTEXT_ITEM = L"IDS_VIDEO_CALL_BTN_NAME"; +const wchar_t* IDS_VOICE_CALL_CONTEXT_ITEM = L"IDS_VOICE_CALL_BTN_NAME"; + +CustomDataProvider::CustomDataProvider(void) +{ + __isEditStyle = false; + __pGroupData = null; + __pAddressBook = new (std::nothrow) Addressbook(); + __pAddressBook->Construct(); + __pItemContext = new ListContextItem(); + __pItemContext->Construct(); + String voiceCallStr = AppUtility::GetResourceString(IDS_VOICE_CALL_CONTEXT_ITEM); + __pItemContext->AddElement(IDA_LIST_ELEMENT_CALL, voiceCallStr); + String messageStr = AppUtility::GetResourceString(IDS_MSG_CONTEXT_ITEM); + __pItemContext->AddElement(IDA_LIST_ELEMENT_MESSAGE, messageStr); + String videoCallStr = AppUtility::GetResourceString(IDS_VIDEO_CALL_CONTEXT_ITEM); + __pItemContext->AddElement(IDA_LIST_ELEMENT_VIDEO_CALL, videoCallStr); + String delStr = AppUtility::GetResourceString(IDS_DELETE_BTN_STRING); + __pItemContext->AddElement(IDA_LIST_ELEMENT_DELETE, delStr); + return; +} + +CustomDataProvider::~CustomDataProvider(void) +{ + ArrayList* pCalllogList = null; + GroupItemClass* pGroupInfo = null; + + if(__pGroupData != null) + { + for(int index = 0; index < __pGroupData->GetCount(); index++) + { + pGroupInfo = static_cast(__pGroupData->GetAt(index)); + + if(pGroupInfo != null) + { + pCalllogList = pGroupInfo->GetLogData(); + if(pCalllogList != null) + { + AppLog(" data cnt = %d", pCalllogList->GetCount()); + pCalllogList->RemoveAll(true); + + delete pCalllogList; + pCalllogList = null; + } + delete pGroupInfo; + pGroupInfo = null; + } + } + __pGroupData->RemoveAll(false); + delete __pGroupData; + } + + if(__pAddressBook != null) + { + delete __pAddressBook; + } + if (__pItemContext != null) + { + delete __pItemContext; + __pItemContext = null; + } +} + +GroupItemClass::GroupItemClass() +{ + __pData = null; +} + +GroupItemClass::~GroupItemClass() +{ + /*if(__pData) + { + delete __pData; + }*/ +} + +void +GroupItemClass::SetTitleText(String titleText) +{ + __titleText = titleText; +} + +void +GroupItemClass::SetLogData(ArrayList* pData) +{ + __pData = pData; +} + +String +GroupItemClass::GetTitleText(void) +{ + return __titleText; +} + +ArrayList* +GroupItemClass::GetLogData(void) +{ + return __pData; +} + + +void +CustomDataProvider::GetItemAtGroupIndex(int groupIndex, int itemIndex, CallLogDetails** pCalllogDetails) +{ + if(__pGroupData != null) + { + GroupItemClass* pGroupInfo = null; + ArrayList* list = null; + pGroupInfo = static_cast(__pGroupData->GetAt(groupIndex)); + if(pGroupInfo != null) + { + list = pGroupInfo->GetLogData(); + *pCalllogDetails = static_cast(list->GetAt(itemIndex)); + } + } +} + +void +CustomDataProvider::DeleteItemAtGroupIndex(int groupIndex, int itemIndex) +{ + if(__pGroupData != null) + { + GroupItemClass* pGroupInfo = null; + ArrayList* list = null; + pGroupInfo = static_cast(__pGroupData->GetAt(groupIndex)); + if(pGroupInfo != null) + { + list = pGroupInfo->GetLogData(); + list->RemoveAt(itemIndex,true); + } + } +} + +void +CustomDataProvider::DeleteAllItems(void) +{ + ArrayList* pCalllogList = null; + GroupItemClass* pGroupInfo = null; + if(__pGroupData != null) + { + for(int index = 0; index < __pGroupData->GetCount(); index++) + { + pGroupInfo = static_cast(__pGroupData->GetAt(index)); + + if(pGroupInfo != null) + { + pCalllogList = pGroupInfo->GetLogData(); + if(pCalllogList != null) + { + AppLog(" data cnt = %d", pCalllogList->GetCount()); + pCalllogList->RemoveAll(true); + + delete pCalllogList; + pCalllogList = null; + } + delete pGroupInfo; + pGroupInfo = null; + } + } + __pGroupData->RemoveAll(false); + delete __pGroupData; + __pGroupData = null; + } +} + +bool +CustomDataProvider::GetCurrentDateTime(DateTime& dt) +{ + DateTime dtNow; + LocaleManager localManager; + result r = E_FAILURE; + TimeZone tz; + + r = SystemTime::GetCurrentTime(UTC_TIME, dtNow); + if (IsFailed(r)) + { + return false; + } + localManager.Construct(); + tz = localManager.GetSystemTimeZone(); + dt = tz.UtcTimeToWallTime(dtNow); + + return true; +} + +bool +CustomDataProvider::IsGroupPresent(GroupItemClass* group) +{ + if(group == null) + { + return false; + } + GroupItemClass* pGroupInfo = null; + for(int index = 0; index < __pGroupData->GetCount(); index++) + { + pGroupInfo = static_cast(__pGroupData->GetAt(index)); + if(pGroupInfo == null) + { + return false; + } + String title1; + String title2; + title1 = group->GetTitleText(); + title2 = pGroupInfo->GetTitleText(); + if( title1.CompareTo(title2) == 0) + { + return true; + } + } + return false; +} + +GroupItemClass* +CustomDataProvider::GetGroupWithTitle(String title) +{ + GroupItemClass* pGroupInfo = null; + for(int index = 0; index < __pGroupData->GetCount(); index++) + { + pGroupInfo = static_cast(__pGroupData->GetAt(index)); + if(pGroupInfo == null) + { + return null; + } + String title1 = pGroupInfo->GetTitleText(); + if( title.CompareTo(title1) == 0) + { + return pGroupInfo; + } + } + return null; +} + +int +CustomDataProvider::GetDaysDifferenceBetweenDates(DateTime date1, DateTime date2) +{ + if(date1.GetYear() == date2.GetYear()) + { + if(date1.GetMonth() == date2.GetMonth()) + { + int days = date2.GetDay() - date1.GetDay(); + /* if(days < 0) + { + days = days * -1; + }*/ + return days; + } + else + { + int mIndex = 1; + int days1 = 0; + int days2 = 0; + int daysInMonth = 0; + int daysDifference = 0; + for(;mIndex < date1.GetMonth(); mIndex++) + { + DateTime::GetDaysInMonth(date1.GetYear(), mIndex, daysInMonth); + days1 += daysInMonth; + } + days1 += date1.GetDay(); + mIndex = 1; + daysInMonth = 0; + for(;mIndex < date2.GetMonth(); mIndex++) + { + DateTime::GetDaysInMonth(date2.GetYear(), mIndex, daysInMonth); + days2 += daysInMonth; + } + days2 += date2.GetDay(); + daysDifference = days2 - days1; + AppLog(" days %d %d %d", days1, days2, daysDifference); + return daysDifference; + } + } + TimeSpan t1 = date1.GetTimeOfDay(); + TimeSpan t2 = date2.GetTimeOfDay(); + return 0; +} + +void +CustomDataProvider::CreateGroupItems(void) +{ + result r = E_FAILURE; + DateTime currentTime; + DateTime todaysDate; + GroupItemClass* pGroupItemClass = null; + CallLogManager* pManager = CallLogManager::GetInstance(); + CallLogDetails* pCalllogInfo = null; + ArrayList* data = null; + int key = 0; + + if(__pGroupData != null) + { + ArrayList* pCalllogList = null; + GroupItemClass* pGroupInfo = null; + for(int index = 0; index < __pGroupData->GetCount(); index++) + { + pGroupInfo = static_cast(__pGroupData->GetAt(index)); + + if(pGroupInfo != null) + { + pCalllogList = pGroupInfo->GetLogData(); + if(pCalllogList != null) + { + pCalllogList->RemoveAll(); + delete pCalllogList; + pCalllogList = null; + } + delete pGroupInfo; + pGroupInfo = null; + } + } + __pGroupData->RemoveAll(); + delete __pGroupData; + __pGroupData = null; + } + __pGroupData = new(std::nothrow) ArrayList(); + if(__pGroupData == null) + { + return; + } + r = __pGroupData->Construct(); + if(IsFailed(r)) + { + delete __pGroupData; + __pGroupData = null; + return; + } + + + int logCount = pManager->GetAllCalllogCount(); + int cmp = 0; + GetCurrentDateTime(todaysDate); + //todaysDate.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay()); + String title; + DateTime calllogDate = todaysDate; + + for(int index = 0; index < logCount; index++) + { + data = null; + title.Clear(); + key = 0; + cmp = 0; + pCalllogInfo = new (std::nothrow) CallLogDetails(); + pManager->GetCallLogItemAtIndex(index ,*pCalllogInfo); + pCalllogInfo->ConvertTimetoDateTime(); + calllogDate = pCalllogInfo->GetDateTime(); + AppLog(" info %d %d %d %s %d:%d:%d", key, pCalllogInfo->GetCalllogType(), pCalllogInfo->GetDuration(), pCalllogInfo->GetPhoneNumber(), calllogDate.GetYear(), calllogDate.GetMonth(), calllogDate.GetDay()); + + //Create a new group + pGroupItemClass = new(std::nothrow) GroupItemClass(); + if(pGroupItemClass == null) + { + return; + } + + int days = GetDaysDifferenceBetweenDates(calllogDate , todaysDate); + if(days == 0) + { + title.Append(L"Today"); + } + else if(days == 1) + { + title.Append(L"Yesterday"); + } + else + { + title.Format(30,L"%d/%d/%d",calllogDate.GetDay(), calllogDate.GetMonth(), calllogDate.GetYear()); + } + pGroupItemClass->SetTitleText(title); + + //Group already present + if(IsGroupPresent(pGroupItemClass) == true) + { + //Delete the created temp group class. Use the already existing group class variable from __pGroupData. + if(pGroupItemClass != null) + { + delete pGroupItemClass; + pGroupItemClass = null; + } + GroupItemClass* pGroup = GetGroupWithTitle(title); + data = pGroup->GetLogData(); + if(data == null) + { + data = new ArrayList(); + data->Construct(); + } + data->Add(*pCalllogInfo); + pGroup->SetLogData(data); + } + else + { + //Group not present in __pGroupData. So add this group + __pGroupData->Add(*pGroupItemClass); + data = pGroupItemClass->GetLogData(); + if(data == null) + { + data = new ArrayList(); + data->Construct(); + } + data->Add(*pCalllogInfo); + pGroupItemClass->SetLogData(data); + } + } +} + +int +CustomDataProvider::GetGroupCount(void) +{ + CreateGroupItems(); + if(__pGroupData != null) + { + return __pGroupData->GetCount(); + } + return 0; +} + +int +CustomDataProvider::GetItemCount(int groupIndex) +{ + GroupItemClass* group = null; + if(__pGroupData != null) + { + group = static_cast(__pGroupData->GetAt(groupIndex)); + if(group) + { + return (group->GetLogData())->GetCount(); + } + } + return 0; +} + +GroupItem* +CustomDataProvider::CreateGroupItem(int groupIndex, int itemWidth) +{ + AppResource* pAppResource = App::GetInstance()->GetAppResource(); + GroupItem* pItem = new GroupItem(); + pItem->Construct(Dimension(itemWidth, 48)); + + String appPath = (Application::GetInstance())->GetAppRootPath(); + Bitmap* pBitmap = null; + pBitmap = pAppResource->GetBitmapN(IDB_CALLOG_LIST_BG,BITMAP_PIXEL_FORMAT_ARGB8888); + + GroupItemClass* group = null; + if(__pGroupData != null) + { + group = static_cast(__pGroupData->GetAt(groupIndex)); + if(group) + { + pItem->SetElement(group->GetTitleText(), pBitmap); + } + else + { + return null; + } + } + return pItem; +} + +ListItemBase* +CustomDataProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + GroupItemClass* pGroup = null; + ArrayList* pCalllogList = null; + CallLogDetails* pCalllogData = null; + String phoneNumber(AppUtility::GetResourceString(IDS_CALLLOG_NO_NUMBER)); + String contactName(AppUtility::GetResourceString(IDS_CALLLOG_NO_NAME)); + DateTime calllogDate; + String dateText(L""); + String key(L"24HourFormatSelected"); + String amPm; + bool dateFormat24 = true; + Bitmap* pBitmap = null; + AppResource* pAppResource = App::GetInstance()->GetAppResource(); + + if(__pGroupData != null) + { + pGroup = static_cast(__pGroupData->GetAt(groupIndex)); + if(pGroup != null) + { + pCalllogList = pGroup->GetLogData(); + if(pCalllogList != null) + { + AppLog(" data cnt = %d", pCalllogList->GetCount()); + pCalllogData = static_cast(pCalllogList->GetAt(itemIndex)); + } + } + } + + if(pCalllogData == null) + { + return null; + } + else + { + if(pCalllogData->GetPhoneNumber() != null) + { + phoneNumber = pCalllogData->GetPhoneNumber(); + } + + CallLogManager* pManager = CallLogManager::GetInstance(); + pManager->GetCalllogContactName(phoneNumber,contactName); + pCalllogData->ConvertTimetoDateTime(); + calllogDate = pCalllogData->GetDateTime(); + int hour = calllogDate.GetHour(); + SettingInfo::GetValue(key, dateFormat24); + + if (dateFormat24 == false) + { + if (hour > MAX_TWELVEHOUR_FORMAT) + { + hour -= MAX_TWELVEHOUR_FORMAT; + amPm.Append(AppUtility::GetResourceString(IDS_PM_TIME)); + } + else if (hour < MAX_TWELVEHOUR_FORMAT) + { + amPm.Append(AppUtility::GetResourceString(IDS_AM_TIME)); + } + else if (hour == MAX_TWELVEHOUR_FORMAT) + { + amPm.Append(AppUtility::GetResourceString(IDS_PM_TIME)); + } + dateText.Format(MAX_TWELVEHOUR_FORMAT_LENGTH,L"%02d:%02d%ls", hour, calllogDate.GetMinute(), amPm.GetPointer()); + } + else + { + dateText.Format(MAX_TWELVEHOUR_FORMAT_LENGTH,L"%02d:02%d", calllogDate.GetHour(), calllogDate.GetMinute()); + } + + } + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + EnrichedText* text = new (std::nothrow) EnrichedText(); + TextElement* textElement = new (std::nothrow) TextElement(); + Font font; + String appPath = (Application::GetInstance())->GetAppRootPath(); + + CustomItem* pItem = new (std::nothrow) CustomItem(); + + if (__isEditStyle == true) + { + style = LIST_ANNEX_STYLE_MARK; + } + + pItem->Construct(Dimension(itemWidth, H_LOG_ITEM), style); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE)); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE)); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, Color::GetColor(COLOR_ID_WHITE)); + + if (__isEditStyle == false) + { + pItem->AddElement(Rectangle(X_TEXT_LINE1_ITEM, Y_TEXT_LINE1_ITEM, W_TEXT_LINE1_ITEM, H_TEXT_LINE1_ITEM), ID_NAME_STRING, contactName,44, Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_BLACK), true); + pItem->AddElement(Rectangle(X_TEXT_LINE2_ITEM, Y_TEXT_LINE2_ITEM, W_TEXT_LINE2_ITEM, H_TEXT_LINE2_ITEM), ID_NUMBER_STRING, phoneNumber, 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), true); + } + else + { + pItem->AddElement(Rectangle(X_TEXT_LINE1_ITEM, Y_TEXT_LINE1_ITEM, W_TEXT_LINE1_ITEM - 76, H_TEXT_LINE1_ITEM), ID_NAME_STRING, contactName, 44, Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_BLACK), true); + pItem->AddElement(Rectangle(X_TEXT_LINE2_ITEM, Y_TEXT_LINE2_ITEM, W_TEXT_LINE2_ITEM - 76, H_TEXT_LINE2_ITEM), ID_NUMBER_STRING, phoneNumber, 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_GREY), true); + } + + text->Construct(Dimension(W_LOG_ITEM_TEXT, H_LOG_ITEM_TEXT)); + text->SetHorizontalAlignment(TEXT_ALIGNMENT_RIGHT); + text->SetVerticalAlignment(TEXT_ALIGNMENT_BOTTOM); + font.Construct(FONT_STYLE_PLAIN, LOG_ITEM_FONT_SIZE); + textElement->Construct(dateText); + textElement->SetFont(font); + textElement->SetTextColor(Color::GetColor(COLOR_ID_GREY)); + text->Add(*textElement); + if (__isEditStyle == false) + { + pItem->AddElement(Rectangle(X_TEXT_TIME_ITEM, Y_TEXT_TIME_ITEM, W_TEXT_TIME_ITEM, H_TEXT_TIME_ITEM), ID_TIME_STRING, *text); + } + else + { + pItem->AddElement(Rectangle(X_TEXT_TIME_ITEM - 76, Y_TEXT_TIME_ITEM, W_TEXT_TIME_ITEM, H_TEXT_TIME_ITEM), ID_TIME_STRING, *text); + } + + if (pBitmap != null) + { + if (__isEditStyle == false) + { + pItem->AddElement(Rectangle(X_CONTACT_BITMAP_ITEM, Y_CONTACT_BITMAP_ITEM, W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM), ID_CONTACT_BITMAP, *pBitmap); + } + else + { + pItem->AddElement(Rectangle(X_CONTACT_BITMAP_ITEM - 76, Y_CONTACT_BITMAP_ITEM, W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM), ID_CONTACT_BITMAP, *pBitmap); + } + delete pBitmap; + pBitmap = null; + } + + switch(pCalllogData->GetCalllogType()) + { + case CALL_LOG_TYPE_VOICE_INCOMING: + { + pBitmap = pAppResource->GetBitmapN(IDB_LOG_RECEIVEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + + } + break; + case CALL_LOG_TYPE_VOICE_OUTGOING: + { + pBitmap = pAppResource->GetBitmapN(IDB_LOG_DIALEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + case CALL_LOG_TYPE_VOICE_REJECTED: + case CALL_LOG_TYPE_VOICE_MISSED: + { + pBitmap = pAppResource->GetBitmapN(IDB_LOG_MISSEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + case CALL_LOG_TYPE_VOICE_BLOCKED: + { + pBitmap = pAppResource->GetBitmapN(IDB_LOG_BLOCKEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + default: + { + pBitmap = pAppResource->GetBitmapN(IDB_LOG_MISSEDCALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888); + } + break; + } + + if (pBitmap != null) + { + pItem->AddElement(Rectangle(X_CALLTYPE_BITMAP_ITEM, Y_CALLTYPE_BITMAP_ITEM, W_CALLTYPE_BITMAP_ITEM, H_CALLTYPE_BITMAP_ITEM), ID_CALLTYPE_BITMAP, *pBitmap); + delete pBitmap; + } + + if (__isEditStyle == false) + { + pItem->SetContextItem(__pItemContext); + } + delete text; + return pItem; + return null; +} + +bool +CustomDataProvider::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + +bool +CustomDataProvider::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + +void +CustomDataProvider::SetListItemStyle(bool mode) +{ + __isEditStyle = mode; +} + + diff --git a/src/PhnTelephonyManager.cpp b/src/PhnTelephonyManager.cpp new file mode 100644 index 0000000..5c19c35 --- /dev/null +++ b/src/PhnTelephonyManager.cpp @@ -0,0 +1,2893 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTelephonyManager.cpp + * @brief Call log item provider + */ +#include +#include +#include +#include "ITapiModem.h" +#include "ITapiSim.h" +#include "PhnCallInfo.h" +#include "PhnTelephonyManager.h" +#include "PhnSettingsManager.h" +#include "PhnTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::System; +using namespace Tizen::Base::Collection; + +const char* callEventList[] = { + TAPI_NOTI_VOICE_CALL_STATUS_IDLE, + TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE, + TAPI_NOTI_VOICE_CALL_STATUS_HELD, + TAPI_NOTI_VOICE_CALL_STATUS_DIALING, + TAPI_NOTI_VOICE_CALL_STATUS_ALERT, + /*TAPI_NOTI_VOICE_CALL_STATUS_INCOMING,*/ + TAPI_NOTI_VOICE_CALL_STATUS_WAITING, + TAPI_NOTI_CALL_INFO_CALL_CONNECTED_LINE, + TAPI_NOTI_CALL_INFO_WAITING, + TAPI_NOTI_CALL_INFO_CUG, + TAPI_NOTI_CALL_INFO_FORWARDED, + TAPI_NOTI_CALL_INFO_BARRED_INCOMING, + TAPI_NOTI_CALL_INFO_BARRED_OUTGOING, + TAPI_NOTI_CALL_INFO_DEFLECTED, + TAPI_NOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT, + TAPI_NOTI_CALL_INFO_FORWARD_UNCONDITIONAL, + TAPI_NOTI_CALL_INFO_FORWARD_CONDITIONAL, + TAPI_NOTI_CALL_INFO_CALL_LINE_IDENTITY, + TAPI_NOTI_CALL_INFO_CALL_NAME_INFORMATION, + TAPI_NOTI_CALL_INFO_FORWARDED_CALL, + TAPI_NOTI_CALL_INFO_CUG_CALL, + TAPI_NOTI_CALL_INFO_DEFLECTED_CALL, + TAPI_NOTI_CALL_INFO_TRANSFERED_CALL, + TAPI_NOTI_CALL_INFO_HELD, + TAPI_NOTI_CALL_INFO_ACTIVE, + TAPI_NOTI_CALL_INFO_JOINED, + TAPI_NOTI_CALL_INFO_RELEASED_ON_HOLD, + TAPI_NOTI_CALL_INFO_TRANSFER_ALERT, + TAPI_NOTI_CALL_INFO_TRANSFERED, + TAPI_NOTI_CALL_INFO_CF_CHECK_MESSAGE, +}; + +TelephonyManager* TelephonyManager::__pManager = null; + +TelephonyManager::TelephonyManager(ITelephonyEventListener* pEventListener) +: __pEventListener(pEventListener) +{ + __pDialedCall = null; + __pIncomingCall = null; + __pActiveCallList = null; + __pSettingsManager = null; + __pTapiHandle = null; + __isIncomingCallPresent = false; + __pAddressBook = null; + __pCachedContact = null; + __isMuted = false; + __isSpeakerOn = false; + __pSoundManager = null; + __pCalllogMgr = null; +} + +TelephonyManager::~TelephonyManager(void) +{ + if (__pActiveCallList != null) + { + delete __pActiveCallList; + } + + if (__pDialedCall != null) + { + delete __pDialedCall; + __pDialedCall = null; + } + + if (__pIncomingCall != null) + { + delete __pIncomingCall; + __pIncomingCall = null; + } + + if (__pAddressBook != null) + { + delete __pAddressBook; + __pAddressBook = null; + } + if (__pCachedContact != null) + { + delete __pCachedContact; + __pCachedContact = null; + } + + //unregister for events from TAPI Lib. + UnregisterEvents(); + + //De-initialize the TAPI Library + if(__pTapiHandle != null) + { + tel_deinit(__pTapiHandle); + } + + if (__pSoundManager != null) + { + delete __pSoundManager; + } + + if (__pCalllogMgr) + { + __pCalllogMgr = null; + } +} + +TelephonyManager* +TelephonyManager::GetInstance(ITelephonyEventListener* pEventListener) +{ + if (__pManager == null) + { + CreateInstance(pEventListener); + } + return __pManager; +} + +void +TelephonyManager::CreateInstance(ITelephonyEventListener* pEventListener) +{ + __pManager = new (std::nothrow) TelephonyManager(pEventListener); + result r = __pManager->Initialize(); + if (IsFailed(r)) + { + delete __pManager; + __pManager = null; + } + atexit(&(TelephonyManager::DestroyInstance)); +} + +void +TelephonyManager::DestroyInstance(void) +{ + if (__pManager != null) + { + __pManager->EndAllCalls(); + delete __pManager; + __pManager = null; + } +} + +result +TelephonyManager::Initialize(void) +{ + //Initialize telephony library + result r = InitializeTelephonyLibrary(); + if (IsFailed(r)) + { + return r; + } + __pActiveCallList = new (std::nothrow) HashMapT(); + __pActiveCallList->Construct(IDI_MAX_ACTIVE_CALLS); + + //Initialize the Settings Manager to fetch call settings + __pSettingsManager = SettingsManager::GetInstance(); + + //initialize address book to fetch contacts information + __pAddressBook = new (std::nothrow) Addressbook(); + r = __pAddressBook->Construct(); + if (IsFailed(r)) + { + //TODO: handle the issue: Out of memory, etx. + return r; + } + __pSoundManager = new (std::nothrow) SoundManager(); + __pCalllogMgr = CallLogManager::GetInstance(); + return r; +} + +result +TelephonyManager::InitializeTelephonyLibrary(void) +{ + result r = E_FAILURE; + + __pTapiHandle = tel_init(null); + if (__pTapiHandle != null) + { + //register telephony events + int errorCode = RegisterEvents(); + if (errorCode == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + } + + //TAPI Library is initialized and events registered successfully + return r; +} + +int +TelephonyManager::RegisterEvents(void) +{ + int errCode = -1; + int eventCount = sizeof(callEventList) / sizeof(char *); + for (int index = 0; index < eventCount; index++) + { + errCode = tel_register_noti_event(__pTapiHandle, callEventList[index], &HandleCallback, this); + if (errCode != TAPI_API_SUCCESS) + { + return errCode; + } + } + return errCode; +} + +void +TelephonyManager::UnregisterEvents(void) +{ + int eventCount = sizeof(callEventList) / sizeof(char *); + for (int index = 0; index < eventCount; index++) + { + tel_deregister_noti_event(__pTapiHandle, callEventList[index]); + } +} + +ErrorCodes +TelephonyManager::SetupMoCall(String& contactNumber, bool isEmergency) +{ + ErrorCodes r = ERROR_TAPI_ERROR; + result res = E_SUCCESS; + + res = CheckValidTelePhoneNumber(contactNumber); + if (IsFailed(res)) + { + return ERROR_INVALID_NUMBER; + } + + //if dialing an emeregency call and active calls exist + //then end all active calls. + if (isEmergency && __pActiveCallList->GetCount() > 0) + { + //Get first call handle + CallInfo endCallInfo; + IListT* pCallList = __pActiveCallList->GetValuesN(); + pCallList->GetAt(0, endCallInfo); + int callHandle = endCallInfo.GetCallHandle()->ToLong(); + delete pCallList; + pCallList = null; + + //release all active or held calls + int tapires = tel_end_call(__pTapiHandle, callHandle, TAPI_CALL_END_ALL, &HandleCallbackResponse, this); + if (tapires == TAPI_CAUSE_SUCCESS) + { + __pActiveCallList->RemoveAll(); + r = ERROR_NONE; + res = E_SUCCESS; + } + else + { + r = ERROR_TAPI_ERROR; + return r; + } + } + else if (__pActiveCallList->GetCount() == 1) + { + //Check if there is already an active call, + //Put the already active call on hold. + CallInfo holdCallInfo; + IListT* pCallList = __pActiveCallList->GetValuesN(); + + pCallList->GetAt(0, holdCallInfo); + //Check if call is active, then put on hold + if (holdCallInfo.IsOnHold() == false) + { + res = HoldActiveCall(&holdCallInfo, true); + } + delete pCallList; + pCallList = null; + } + + //make the next call, only if any existing active call + //is successfully put on hold or is already on hold. + //make the next call, only if any existing active call + //is successfully put on hold or is already on hold. + if (res == E_SUCCESS) + { + res = DialOutgoingCall(contactNumber, isEmergency); + } + if(res == E_SUCCESS) + { + return ERROR_NONE; + } + { + return ERROR_TAPI_ERROR; + } +} + +void +TelephonyManager::EndAllCalls(void) +{ + if(__pDialedCall != null) + { + if(__pDialedCall->GetCallHandle() != null) + { + tel_end_call(__pTapiHandle, __pDialedCall->GetCallHandle()->ToLong(), TAPI_CALL_END, &HandleCallbackResponse, this); + } + } + tel_end_call(__pTapiHandle, -1, TAPI_CALL_END_HOLD_ALL, &HandleCallbackResponse, this); + //end all active calls before terminating application + tel_end_call(__pTapiHandle, -1, TAPI_CALL_END_ALL, &HandleCallbackResponse, this); +} + +result +TelephonyManager::EndCall(Long callHandle) +{ + result r = E_SUCCESS; + CallInfo endCall; + bool endDialedCall = false; + + //fetch ended callInfo + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endCall); + if(endCall.GetCallHandle()->Equals(callHandle)) + { + //Found the call to be ended. + r = E_SUCCESS; + break; + } + + } + delete pCallList; + pCallList = null; + + if (r == E_SUCCESS && __pDialedCall != null) + { + if (__pDialedCall->GetCallHandle()->Equals(callHandle) ) + { + r = E_SUCCESS; + endCall = *__pDialedCall; + endDialedCall = true; + } + + } + + if (r == E_SUCCESS) + { + unsigned int callHandle = -1; + if (endCall.GetCallHandle() != null) + { + callHandle = endCall.GetCallHandle()->ToLong(); + TelCallEndType_t endType = TAPI_CALL_END; + int res = -1; + res = tel_end_call(__pTapiHandle, callHandle, endType, &HandleEndDialedCallResponse, this); + + if (res == TAPI_CAUSE_SUCCESS) + { + if (endDialedCall == true) + { + String endCause(L"Call Rejected"); + __pDialedCall->SetEndCallCause(endCause); + } + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + } + else + { + r = E_FAILURE; + } + } + return r; +} + +result +TelephonyManager::EndCall(String& contactNumber) +{ + result r = E_SUCCESS; + CallInfo endCall; + bool endDialedCall = false; + if (contactNumber.IsEmpty()) + { + return E_FAILURE; + } + + //fetch ended callInfo + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endCall); + if (endCall.GetContactNumber().Equals(contactNumber)) + { + //Found the call to be ended. + r = E_SUCCESS; + break; + } + } + delete pCallList; + pCallList = null; + + if (r == E_SUCCESS && __pDialedCall != null) + { + if (__pDialedCall->GetContactNumber().Equals(contactNumber)) + { + r = E_SUCCESS; + endCall = *__pDialedCall; + endDialedCall = true; + } + } + + if (r == E_SUCCESS) + { + unsigned int callHandle = -1; + if (endCall.GetCallHandle() != null) + { + callHandle = endCall.GetCallHandle()->ToLong(); + TelCallEndType_t endType = TAPI_CALL_END; + int res = -1; + res = tel_end_call(__pTapiHandle, callHandle, endType, &HandleEndDialedCallResponse, this); + + if (res == TAPI_CAUSE_SUCCESS) + { + if (endDialedCall == true) + { + String endCause(L"Call Rejected"); + __pDialedCall->SetEndCallCause(endCause); + } + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + } + else + { + r = E_FAILURE; + } + } + return r; +} + +result +TelephonyManager::AnswerCall(int callHandle, bool acceptCall) +{ + result r = E_FAILURE; + __pSoundManager->StopAlert(); + TelCallAnswerType_t answerType = TAPI_CALL_ANSWER_ACCEPT; + int res = -1; + if (acceptCall == true) + { + answerType = TAPI_CALL_ANSWER_ACCEPT; + // redirect to dummy call back handler as the flow already handled in registered event callback + res = tel_answer_call(__pTapiHandle, callHandle, answerType, &HandleCallbackResponse, this); + } + else + { + answerType = TAPI_CALL_ANSWER_REJECT; + // redirect to reject call back handler as the flow has to be handled + res = tel_answer_call(__pTapiHandle, callHandle, answerType, &HandleRejectCallbackResponse, this); + } + + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + return r; +} + +result +TelephonyManager::AcceptCall(CallAnswerOptions answerOptions,int callHandle) +{ + result r = E_FAILURE; + __pSoundManager->StopAlert(); + __pSoundManager->SetSoundMode(SOUND_MODE_VOICE); + + if (__pActiveCallList->GetCount()) + { + if (__pActiveCallList->GetCount() == 1) + { + r = AcceptSecondCall(answerOptions,callHandle); + } + else + { + r = AcceptMultipleCall(answerOptions,callHandle); + if (__pIncomingCall != null) + { + delete __pIncomingCall; + __pIncomingCall = null; + } + } + + return r; + } + else + { + return r; + } +} + +result +TelephonyManager::AcceptSecondCall(CallAnswerOptions answerOptions,int callHandle) +{ + result r = E_FAILURE; + IListT* pCallList = __pActiveCallList->GetValuesN(); + int res = -1; + CallInfo* pFirstCallInfo = new (std::nothrow) CallInfo(); + pCallList->GetAt(0,*pFirstCallInfo); + delete pCallList; + pCallList = null; + switch (answerOptions) + { + case CALL_ANSWER_HOLD_ACCEPT: + { + //todo: try answering call with option as TAPI_CALL_ANSWER_HOLD_AND_ACCEPT + if (pFirstCallInfo->IsConferenceCall() == false) + { + r = HoldActiveCall(pFirstCallInfo,true); + } + else + { + r = HoldConferenceCall(true); + } + + if (callHandle == (unsigned int)__pIncomingCall->GetCallHandle()->ToLong()) + { + //handle call connected - save info + String contactNo; + contactNo.Append(__pIncomingCall->GetContactNumber()); + result r = FetchContactInfoForNumber(contactNo); + if (!IsFailed(r)) + { + __pIncomingCall->SetContactInfo(*__pCachedContact); + } + } + else + { + delete __pIncomingCall; + TelCallStatus_t callStatus; + tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + __pIncomingCall = new (std::nothrow) CallInfo(); + __pIncomingCall->SetCallHandle(callHandle); + __pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + String contactNumber(callStatus.pNumber); + __pIncomingCall->SetContactNumber(contactNumber); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + __pIncomingCall->SetContactInfo(*__pCachedContact); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + __pIncomingCall->SetEmergency(true); + } + else + { + __pIncomingCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + __pIncomingCall->SetCallNotificationTime(startTime); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + __pIncomingCall->SetCallConnectTime(startTime); + r = E_SUCCESS; + break; + } + case CALL_ANSWER_END_ACTIVE_ACCEPT: + { + //todo: try answering call with option as TAPI_CALL_ANSWER_REPLACE + __pActiveCallList->RemoveAll(); + if (pFirstCallInfo->IsConferenceCall() == false) + { + r = HoldActiveCall(pFirstCallInfo,true); + } + else + { + res = tel_hold_call(__pTapiHandle, pFirstCallInfo->GetCallHandle()->ToLong(), &HandleCallbackResponse, this); + } + // call should be active now. end the active call now + if (pFirstCallInfo->IsConferenceCall() == false) + { + TelCallEndType_t endType = TAPI_CALL_END; + unsigned int callHandleToBeEnded = pFirstCallInfo->GetCallHandle()->ToLong(); + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(pFirstCallInfo); + } + else + { + int confCallCount = pFirstCallInfo->GetCallerListCount(); + IListT* pCallList = pFirstCallInfo->GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + } + unsigned int callHandleToBeEnded = pFirstCallInfo->GetCallHandle()->ToLong(); + TelCallEndType_t endType = TAPI_CALL_END_HOLD_ALL; + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + } + r = E_SUCCESS; + + if (callHandle == (unsigned int)__pIncomingCall->GetCallHandle()->ToLong()) + { + //handle call connected - save info + String contactNo; + contactNo.Append(__pIncomingCall->GetContactNumber()); + result r = FetchContactInfoForNumber(contactNo); + if (!IsFailed(r)) + { + __pIncomingCall->SetContactInfo(*__pCachedContact); + } + } + else + { + delete __pIncomingCall; + TelCallStatus_t callStatus; + tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + __pIncomingCall = new (std::nothrow) CallInfo(); + __pIncomingCall->SetCallHandle(callHandle); + __pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + String contactNumber(callStatus.pNumber); + __pIncomingCall->SetContactNumber(contactNumber); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + __pIncomingCall->SetContactInfo(*__pCachedContact); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + __pIncomingCall->SetEmergency(true); + } + else + { + __pIncomingCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + __pIncomingCall->SetCallNotificationTime(startTime); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + __pIncomingCall->SetCallConnectTime(startTime); + break; + } + default: + break; + } + delete pFirstCallInfo; + return r; +} + +result +TelephonyManager::AcceptMultipleCall(CallAnswerOptions answerOptions,int callHandle) +{ + result r = E_FAILURE; + IListT* pCallList = __pActiveCallList->GetValuesN(); + IListT* pKeyList = __pActiveCallList->GetKeysN(); + long firstKey; + long secondKey; + long activeCallKey; + long heldCallKey; + CallInfo* pFirstCallInfo = new (std::nothrow) CallInfo(); + pCallList->GetAt(0,*pFirstCallInfo); + pKeyList->GetAt(0,firstKey); + CallInfo* pSecondCallInfo = new (std::nothrow) CallInfo(); + pCallList->GetAt(1,*pSecondCallInfo); + pKeyList->GetAt(1,secondKey); + delete pCallList; + delete pKeyList; + CallInfo heldCall; + CallInfo activeCall; + if (pFirstCallInfo->IsOnHold() == false) + { + activeCall = *pFirstCallInfo; + activeCallKey = firstKey; + heldCall = *pSecondCallInfo; + heldCallKey = secondKey; + } + else + { + activeCall = *pSecondCallInfo; + activeCallKey = secondKey; + heldCall = *pFirstCallInfo; + heldCallKey = firstKey; + } + delete pFirstCallInfo; + delete pSecondCallInfo; + + switch (answerOptions) + { + case CALL_ANSWER_END_ACTIVE_ACCEPT: + { + //todo: try answering call with option as TAPI_CALL_ANSWER_REPLACE + __pActiveCallList->Remove(activeCallKey); + TelCallStatus_t callStatus; + int res = tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + CallInfo* pCallInfo = new (std::nothrow) CallInfo(); + pCallInfo->SetCallHandle(callHandle); + + String contactNumber(callStatus.pNumber); + pCallInfo->SetContactNumber(contactNumber); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pCallInfo->SetContactInfo(*__pCachedContact); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pCallInfo->SetEmergency(true); + } + else + { + pCallInfo->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pCallInfo->SetCallConnectTime(startTime); + pCallInfo->SetCallNotificationTime(startTime); + + //transfer ownership to Active calls list + __pActiveCallList->Add(callHandle, *(pCallInfo)); + pCallInfo = null; + } + + TelCallEndType_t endType = TAPI_CALL_END; + if (activeCall.IsConferenceCall() == false) + { + unsigned int callHandleToBeEnded = activeCall.GetCallHandle()->ToLong(); + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&activeCall); + } + else + { + int confCallCount = activeCall.GetCallerListCount(); + IListT* pCallList = activeCall.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + unsigned int calloBeEnded = callInfo.GetCallHandle()->ToLong(); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + tel_end_call(__pTapiHandle, calloBeEnded, endType, &HandleCallbackResponse, this); + } + } + if (callStatus.CallState == TAPI_CALL_STATE_WAITING || callStatus.CallState == TAPI_CALL_STATE_INCOMING) + { + res = tel_active_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + } + break; + } + case CALL_ANSWER_END_HELD_ACCEPT: + { + unsigned int callHandleToBeEnded = heldCall.GetCallHandle()->ToLong(); + __pActiveCallList->Remove(heldCallKey); + TelCallStatus_t callStatus; + int res = tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + CallInfo* pCallInfo = new (std::nothrow) CallInfo(); + pCallInfo->SetCallHandle(callHandle); + + String contactNumber(callStatus.pNumber); + pCallInfo->SetContactNumber(contactNumber); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pCallInfo->SetContactInfo(*__pCachedContact); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pCallInfo->SetEmergency(true); + } + else + { + pCallInfo->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pCallInfo->SetCallConnectTime(startTime); + pCallInfo->SetCallNotificationTime(__pIncomingCall->GetCallNotificationTime()); + + //transfer ownership to Active calls list + __pActiveCallList->Add(callHandle, *(pCallInfo)); + pCallInfo = null; + } + TelCallEndType_t endType = TAPI_CALL_END; + if (heldCall.IsConferenceCall() == false) + { + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&heldCall); + } + else + { + int confCallCount = heldCall.GetCallerListCount(); + IListT* pCallList = heldCall.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + unsigned int calloBeEnded = callInfo.GetCallHandle()->ToLong(); + tel_end_call(__pTapiHandle, calloBeEnded, endType, &HandleCallbackResponse, this); + } + } + //Set held flag on active call + CallInfo* pHeldCallInfo = new (std::nothrow) CallInfo(); + //copy state into new callinfo object + *pHeldCallInfo = activeCall; + //set call to hold state + pHeldCallInfo->SetOnHold(true); + //replace old object with new + __pActiveCallList->SetValue(activeCallKey, *pHeldCallInfo); + if (callStatus.CallState == TAPI_CALL_STATE_WAITING || callStatus.CallState == TAPI_CALL_STATE_INCOMING) + { + res = tel_active_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + } + break; + } + case CALL_ANSWER_END_ALL_ACCEPT: + { + unsigned int callHandleToBeEnded = activeCall.GetCallHandle()->ToLong(); + __pActiveCallList->RemoveAll(); + TelCallEndType_t endType = TAPI_CALL_END; + if (activeCall.IsConferenceCall() == false) + { + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&activeCall); + } + else + { + int confCallCount = activeCall.GetCallerListCount(); + IListT* pCallList = activeCall.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + unsigned int calloBeEnded = callInfo.GetCallHandle()->ToLong(); + tel_end_call(__pTapiHandle, calloBeEnded, endType, &HandleCallbackResponse, this); + } + } + callHandleToBeEnded = heldCall.GetCallHandle()->ToLong(); + if (heldCall.IsConferenceCall() == false) + { + tel_end_call(__pTapiHandle, callHandleToBeEnded, endType, &HandleCallbackResponse, this); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&heldCall); + } + else + { + int confCallCount = heldCall.GetCallerListCount(); + IListT* pCallList = heldCall.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + //Add call ended to call log database + __pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + unsigned int calloBeEnded = callInfo.GetCallHandle()->ToLong(); + tel_end_call(__pTapiHandle, calloBeEnded, endType, &HandleCallbackResponse, this); + } + } + TelCallStatus_t callStatus; + int res = tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + if (callStatus.CallState == TAPI_CALL_STATE_WAITING || callStatus.CallState == TAPI_CALL_STATE_INCOMING) + { + res = tel_active_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + CallInfo* pCallInfo = null; + if (callHandle == (unsigned int)__pIncomingCall->GetCallHandle()->ToLong()) + { + //handle call connected - save info + pCallInfo = new (std::nothrow) CallInfo(); + *pCallInfo = *(__pIncomingCall); + String contactNo; + contactNo.Append(pCallInfo->GetContactNumber()); + result r = FetchContactInfoForNumber(contactNo); + if (!IsFailed(r)) + { + pCallInfo->SetContactInfo(*__pCachedContact); + } + } + else + { + TelCallStatus_t callStatus; + tel_get_call_status(__pTapiHandle, callHandle, &callStatus); + pCallInfo = new (std::nothrow) CallInfo(); + pCallInfo->SetCallHandle(callHandle); + pCallInfo->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + String contactNumber(callStatus.pNumber); + pCallInfo->SetContactNumber(contactNumber); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pCallInfo->SetContactInfo(*__pCachedContact); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pCallInfo->SetEmergency(true); + } + else + { + pCallInfo->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pCallInfo->SetCallNotificationTime(startTime); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pCallInfo->SetCallConnectTime(startTime); + + //transfer ownership to Active calls list + __pActiveCallList->Add(callHandle, *(pCallInfo)); + pCallInfo = null; + } + else + { + r = E_FAILURE; + } + } + break; + } + default: + break; + } + return r; +} + +result +TelephonyManager::HoldCall(Tizen::Base::Long callHandle, bool holdCall) +{ + result r = E_SUCCESS; + //Check if there are any existing active calls + if (__pActiveCallList->GetCount()) + { + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + CallInfo holdCallInfo; + + r = pCallList->GetAt(index, holdCallInfo); + //check if an active call is found with matching contact no. + if ((r == E_SUCCESS) && (holdCallInfo.GetCallHandle()->Equals(callHandle))) + { + r = HoldActiveCall(&holdCallInfo, holdCall); + break; + } + } + delete pCallList; + pCallList = null; + } + + return r; +} + +result +TelephonyManager::EndConferenceCall(void) +{ + result r = E_FAILURE; + //fetch ended callInfo + CallInfo endConfCall; + int res = -1; + bool isConferenceCallFound = false; + + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + break; + } + } + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return r; + } + unsigned int callHandle = endConfCall.GetCallHandle()->ToLong(); + if (callCount == 1) + { + if (endConfCall.IsOnHold() == false) + { + TelCallEndType_t endType = TAPI_CALL_END_ACTIVE_ALL; + res = tel_end_call(__pTapiHandle, callHandle, endType, &HandleEndDialedCallResponse, this); + } + else + { + TelCallEndType_t endType = TAPI_CALL_END_HOLD_ALL; + res = tel_end_call(__pTapiHandle, callHandle, endType, &HandleEndDialedCallResponse, this); + } + } + else + { + //End each call in conference as using the end_all/Hold_all + //automatically activates the held call + TelCallEndType_t endType = TAPI_CALL_END; + int confCallCount = endConfCall.GetCallerListCount(); + IListT* pConfCallList = endConfCall.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pConfCallList->GetAt(index, callInfo); + unsigned int calloBeEnded = callInfo.GetCallHandle()->ToLong(); + res = tel_end_call(__pTapiHandle, calloBeEnded, endType, &HandleEndDialedCallResponse, this); + } + } + + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + CallInfo* pConfCallInfo = new (std::nothrow) CallInfo(); + *pConfCallInfo = endConfCall; + __pActiveCallList->Remove(callHandle); + __pActiveCallList->Add(callHandle, *pConfCallInfo); + } + else + { + r = E_FAILURE; + } + + delete pCallList; + pCallList = null; + return r; +} + +result +TelephonyManager::HoldConferenceCall(bool holdCall) +{ + result r = E_FAILURE; + int confCallIndex = -1; + CallInfo endConfCall; + bool isConferenceCallFound = false; + + IListT* pCallList = __pActiveCallList->GetValuesN(); + int confCallCount = pCallList->GetCount(); + + for (int index = 0; index < confCallCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + confCallIndex = index; + //Found the Conference call to be ended. + break; + } + } + + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return r; + } + + unsigned int callHandle = endConfCall.GetCallHandle()->ToLong(); + int res = TAPI_API_INVALID_INPUT; + if (holdCall == true) + { + res = tel_hold_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + } + else + { + res = tel_active_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + } + if (res == TAPI_API_SUCCESS) + { + r = E_SUCCESS; + if (holdCall == true) + { + endConfCall.SetOnHold(true); + } + else + { + endConfCall.SetOnHold(false); + } + CallInfo* pConfCallInfo = new (std::nothrow) CallInfo(); + *pConfCallInfo = endConfCall; + __pActiveCallList->Remove(callHandle); + __pActiveCallList->Add(callHandle, *pConfCallInfo); + } + else + { + r = E_FAILURE; + } + + delete pCallList; + pCallList = null; + return r; +} + +result +TelephonyManager::JoinCall(void) +{ + result r = E_FAILURE; + int res = -1; + CallInfo activeCall; + CallInfo heldCall; + // Use enumerator to access elements in the map + IListT* pCallList = __pActiveCallList->GetValuesN(); + r = pCallList->GetAt(0, activeCall); + + if (r == E_SUCCESS) + { + r = pCallList->GetAt(1, heldCall); + if (r == E_SUCCESS) + { + unsigned int activeCallHandle = activeCall.GetCallHandle()->ToLong(); + unsigned int heldCallHandle = heldCall.GetCallHandle()->ToLong(); + + //Check if participants in conference call are under limit. + if ((heldCall.IsConferenceCall() == true) && (heldCall.GetCallerListCount() < IDI_MAX_CONF_CALL_PARTICIPANTS)) + { + res = tel_join_call(__pTapiHandle, heldCallHandle, activeCallHandle, &HandleJoinCallbackResponse, this); + } + else if (activeCall.GetCallerListCount() < IDI_MAX_CONF_CALL_PARTICIPANTS) + { + res = tel_join_call(__pTapiHandle, activeCallHandle, heldCallHandle, &HandleJoinCallbackResponse, this); + } + } + } + delete pCallList; + pCallList = null; + if (res == TAPI_API_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + return r; +} + +result +TelephonyManager::HoldActiveCall(CallInfo* pActiveCallInfo, bool holdCall) +{ + unsigned int callHandle = pActiveCallInfo->GetCallHandle()->ToLong(); + int retStatus = -1; + if (holdCall == true) + { + retStatus = tel_hold_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + } + else + { + retStatus = tel_active_call(__pTapiHandle, callHandle, &HandleCallbackResponse, this); + } + + if (retStatus == TAPI_CAUSE_SUCCESS) + { + CallInfo* pHeldCallInfo = new (std::nothrow) CallInfo(); + //copy state into new callinfo object + *pHeldCallInfo = *pActiveCallInfo; + + //set call to hold state + pHeldCallInfo->SetOnHold(holdCall); + + __pActiveCallList->Remove(callHandle); + //replace old object with new + __pActiveCallList->Add(callHandle, *pHeldCallInfo); + return E_SUCCESS; + } + else + { + return E_FAILURE; + } +} + +result +TelephonyManager::DialOutgoingCall(String& contactNumber, bool isEmergency) +{ + TelCallDial_t structDialCall; + + //conversion "contactNumber" to char* + const wchar_t* pContact = contactNumber.GetPointer(); + int len = contactNumber.GetLength()+1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + + //initialize request parameter + memset(&structDialCall, '\0', sizeof(TelCallDial_t)); + memcpy(structDialCall.szNumber, pNumber, strlen(pNumber)); + + if(isEmergency == true) + { + structDialCall.CallType = TAPI_CALL_TYPE_E911; + } + else + { + structDialCall.CallType = TAPI_CALL_TYPE_VOICE; + } + + int res = tel_dial_call(__pTapiHandle, &structDialCall, &HandleDialCallbackResponse, this); + if (__pSoundManager == null) + { + __pSoundManager = new (std::nothrow) SoundManager(); + } + __pSoundManager->StartSession(); + delete[] pNumber; + pNumber = null; + + if (res == TAPI_CAUSE_SUCCESS) + { + if (__pDialedCall != null) + { + delete __pDialedCall; + __pDialedCall = null; + } + __pDialedCall = new (std::nothrow) CallInfo(); + __pDialedCall->SetContactNumber(contactNumber); + __pDialedCall->SetEmergency(isEmergency); + result r = FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + __pDialedCall->SetContactInfo(*__pCachedContact); + } + return E_SUCCESS; + } + else + { + return E_FAILURE; + } +} + +result +TelephonyManager::SwapCalls(void) +{ + result r = E_FAILURE; + + //check if there are atleast 2 active calls + if (__pActiveCallList->GetCount() == IDI_MAX_ACTIVE_CALLS) + { + int retStatus = 0; + + //fetch call handles + IListT* pCallHandleList = __pActiveCallList->GetKeysN(); + long callHandle1 = 0; + pCallHandleList->GetAt(0, callHandle1); + long callHandle2 = 0; + pCallHandleList->GetAt(1, callHandle2); + + retStatus = tel_swap_call(__pTapiHandle, callHandle1, callHandle2, &HandleSwapCallbackResponse, this); + + if (retStatus == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + delete pCallHandleList; + pCallHandleList = null; + } + + return r; +} + +result +TelephonyManager::SendCallDTMF(String& textToBeSent) +{ + result r = E_FAILURE; + //check if there is an active Call + if (__pActiveCallList->GetCount() > 0) + { + //conversion "textToBeSent" to char* + const wchar_t* pTextToBeSent = textToBeSent.GetPointer(); + int len = textToBeSent.GetLength() + 1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pTextToBeSent, len); + int retStatus = tel_call_dtmf(__pTapiHandle, pNumber, &HandleCallbackResponse, this); + delete []pNumber; + pNumber = null; + if (retStatus == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + } + return r; +} + +result +TelephonyManager::EndFromConference(int callHandle) +{ + result r = E_FAILURE; + int confCallIndex = -1; + CallInfo endConfCall; + bool isConferenceCallFound = false; + + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + confCallIndex = index; + //Found the Conference call to be ended. + break; + } + } + + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return r; + } + delete pCallList; + pCallList = null; + //Identify the call to be ended and remove from list on API success + CallInfo callToBeEnded; + pCallList = endConfCall.GetCallerList(); + callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, callToBeEnded); + if (callToBeEnded.GetCallHandle()->ToLong() == callHandle) + { + //Identify the call to be ended and remove from list on API success + TelCallEndType_t endType = TAPI_CALL_END; + + int res = tel_end_call(__pTapiHandle, callHandle, endType, &HandleEndFromConferenceCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + break; + } + } + + return r; +} + +result +TelephonyManager::SplitFromConference(int callHandle) +{ + result r = E_FAILURE; + int confCallIndex = -1; + CallInfo endConfCall; + bool isConferenceCallFound = false; + + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + confCallIndex = index; + //Found the Conference call to be ended. + break; + } + } + + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return r; + } + pCallList = null; + //Identify the call to be ended and remove from list on API success + CallInfo callToBeEnded; + pCallList = endConfCall.GetCallerList(); + callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, callToBeEnded); + if (callToBeEnded.GetCallHandle()->ToLong() == callHandle) + { + int res = tel_split_call(__pTapiHandle, callHandle, &HandleSplitFromConferenceCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + break; + } + } + + return r; +} + +result +TelephonyManager::SetMuteStatus(bool setMute) +{ + TelSoundMuteStatus_t muteStatus; + result r = E_FAILURE; + if (setMute == true) + { + muteStatus = TAPI_SOUND_MUTE_STATUS_ON; + } + else + { + muteStatus = TAPI_SOUND_MUTE_STATUS_OFF; + } + int res = tel_set_call_mute_status(__pTapiHandle, muteStatus, &HandleCallbackResponse, this); + if (res == TAPI_CAUSE_SUCCESS) + { + __isMuted = setMute; + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + return r; +} + +bool +TelephonyManager::IsCallMuted(void) +{ + return __isMuted; +} + +result +TelephonyManager::SetSpeakerStatus(bool setSpeaker) +{ + result r = E_FAILURE; + TelCallSoundPathInfo_t callSoundPathInfo; + __pSoundManager->SetSpeakerStatus(setSpeaker); + if (setSpeaker == true) + { + callSoundPathInfo.path = TAPI_SOUND_PATH_SPK_PHONE; + } + else + { + callSoundPathInfo.path = TAPI_SOUND_PATH_HANDSET; + } + callSoundPathInfo.ex_volume = TelCallSoundPathInfo_t::TAPI_SOUND_EX_VOLUME_ON; + + int res = tel_set_call_sound_path(__pTapiHandle, &callSoundPathInfo, &HandleCallbackResponse, this); + + if (res == TAPI_CAUSE_SUCCESS) + { + __isSpeakerOn = setSpeaker; + r = E_SUCCESS; + } + else + { + r = E_FAILURE; + } + return r; +} + +bool +TelephonyManager::IsSpeakerOn(void) +{ + return __isSpeakerOn; +} + +bool +TelephonyManager::IsSplitAllowed(void) +{ + // Split functionality is allowed only if a one call is present. + // The call can be a single call or a conference call + if (__pActiveCallList->GetCount() == 1) + { + return true; + } + return false; +} +//Currently does nothing +void +TelephonyManager::HandleCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ +} + +void +TelephonyManager::HandleEndDialedCallResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelCallEndCnf_t callEndInfo; + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + //Handle ending of dialed call + if (pTelManager->__pDialedCall != null) + { + unsigned int dialedCallHandle = (unsigned int)pTelManager->__pDialedCall->GetCallHandle()->ToLong(); + memset(&callEndInfo, 0,sizeof(TelCallEndCnf_t)); + memcpy(&callEndInfo, pData,sizeof(TelCallEndCnf_t)); + if (callEndInfo.id == dialedCallHandle) + { + //Get current status of the call. idle callback received if call has been ended + TelCallStatus_t callStatus; + tel_get_call_status(pTelManager->__pTapiHandle,callEndInfo.id,&callStatus); + if (callStatus.CallState == TAPI_CALL_STATE_IDLE) + { + //check if the ended call was the last call + bool isLastCall = (pTelManager->__pActiveCallList->GetCount() == 0); + ArrayListT* pCallList = null; + if (isLastCall) + { + pCallList = new (std::nothrow) ArrayListT(); + } + else + { + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } + //notify listener that call is connected. + pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); + delete pCallList; + pCallList = null; + delete pTelManager->__pDialedCall; + pTelManager->__pDialedCall = null; + pTelManager->__pSoundManager->SetSoundMode(SOUND_MODE_VOICE); + } + } + } +} + +void +TelephonyManager::HandleDialCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (callBackResult != TAPI_CAUSE_SUCCESS) + { + if (pTelManager->__pDialedCall != null) + { + delete pTelManager->__pDialedCall; + pTelManager->__pDialedCall = null; + } + pTelManager->__pEventListener->HandleTelephonyError(ERROR_DIAL_FAILED); + } +} + +void +TelephonyManager::HandleRejectCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + // This callback comes only if user has either rejected an incoming call from IncomingCallForm. + // or the incoming call was automatically rejected. + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (pData != null && callBackResult == TAPI_API_SUCCESS) + { + unsigned int tempHandle = 0; + TelCallStatus_t callStatus; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + int res = tel_get_call_status(pTelManager->__pTapiHandle, tempHandle, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + String contactNumber(callStatus.pNumber); + //Fetch contact details from address book. + Contact* pContactDetails = pTelManager->GetContactN(contactNumber); + + //Check if number was automatically rejected using settings, then don't give any notification to user. + bool showIncomingCallRejectedNotification = true; + if (((pTelManager->__pSettingsManager->GetUnknownRejectStatus() == true) && (pContactDetails == null)) + || (pTelManager->__pSettingsManager->IsCallToBeRejected(contactNumber) == true)) + { + showIncomingCallRejectedNotification = false; + } + + if (showIncomingCallRejectedNotification == true) + { + long long phNumber = 0; + LongLong::Parse(contactNumber, phNumber); + //handle call connected - save info + if (pTelManager->__pIncomingCall != null) + { + CallInfo* pIncomingCall = new (std::nothrow) CallInfo(); + *pIncomingCall = *(pTelManager->__pIncomingCall); + pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_REJECTED); + result r = pTelManager->FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pIncomingCall->SetContactInfo(*(pTelManager->__pCachedContact)); + } + //check if the ended call was the last call + bool isLastCall = (pTelManager->__pActiveCallList->GetCount() == 0); + ArrayListT* pCallList = null; + if (isLastCall) + { + pCallList = new (std::nothrow) ArrayListT(); + pCallList->Construct(1); + + //save end call details + String endCause(L"Call Rejected"); + pIncomingCall->SetEndCallCause(endCause); + + //save to list + pCallList->Add(*pIncomingCall); + } + else + { + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } + + //Add to call log + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(pIncomingCall); + + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = null; + + if (pTelManager->__isIncomingCallPresent == true) + { + if(pTelManager->__pSoundManager != null) + { + pTelManager->__pSoundManager->StopAlert(); + //Do not call stop session if there is already a call going on + if(pTelManager->__pActiveCallList->GetCount() == 0) + { + pTelManager->__pSoundManager->StopSession(); + } + } + pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); + delete pCallList; + pCallList = null; + } + pTelManager->__isIncomingCallPresent = false; + delete pIncomingCall; + pIncomingCall = null; + } + } + } + } + else + { + pTelManager->__pEventListener->HandleTelephonyError(ERROR_REJECT_FAILED); + } +} + +void +TelephonyManager::HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (callBackResult == TAPI_API_SUCCESS && pData != null) + { + unsigned int tempHandle = 0; + TelCallInfoJoinedNoti_t joinedInfoNotification; + CallInfo confCallInfo; + + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + joinedInfoNotification.id = tempHandle; + CallInfo activeCall; + CallInfo heldCall; + // Use enumerator to access elements in the map + IListT* pCallList = pTelManager->__pActiveCallList->GetValuesN(); + result r = pCallList->GetAt(0, activeCall); + + if (r == E_SUCCESS) + { + r = pCallList->GetAt(1, heldCall); + if (r == E_SUCCESS) + { + CallInfo* pConfCallInfo = new (std::nothrow) CallInfo(); + unsigned int activeCallHandle = activeCall.GetCallHandle()->ToLong(); + unsigned int heldCallHandle = heldCall.GetCallHandle()->ToLong(); + if (activeCall.IsConferenceCall() == true) + { + r = E_SUCCESS; + //When joined both become active + activeCall.SetOnHold(false); + heldCall.SetOnHold(false); + *pConfCallInfo = activeCall; + pConfCallInfo->AddCallToCallerList(heldCall); + pConfCallInfo->SetCallHandle(activeCallHandle); + //Set call start time + if (pConfCallInfo->GetCallConnectTime() > heldCall.GetCallConnectTime()) + { + pConfCallInfo->SetCallConnectTime(heldCall.GetCallConnectTime()); + pConfCallInfo->SetCallNotificationTime(heldCall.GetCallNotificationTime()); + } + } + else if (heldCall.IsConferenceCall() == true) + { + r = E_SUCCESS; + heldCall.SetOnHold(false); + activeCall.SetOnHold(false); + *pConfCallInfo = heldCall; + pConfCallInfo->AddCallToCallerList(activeCall); + pConfCallInfo->SetCallHandle(heldCallHandle); + //Set call start time + if (pConfCallInfo->GetCallConnectTime() > activeCall.GetCallConnectTime()) + { + pConfCallInfo->SetCallConnectTime(activeCall.GetCallConnectTime()); + pConfCallInfo->SetCallNotificationTime(activeCall.GetCallNotificationTime()); + } + } + else + { + r = E_SUCCESS; + pConfCallInfo->SetConference(true); + heldCall.SetOnHold(false); + activeCall.SetOnHold(false); + pConfCallInfo->AddCallToCallerList(activeCall); + pConfCallInfo->AddCallToCallerList(heldCall); + pConfCallInfo->SetCallHandle(activeCallHandle); + //Set call start time + if (activeCall.GetCallConnectTime() > heldCall.GetCallConnectTime()) + { + pConfCallInfo->SetCallConnectTime(heldCall.GetCallConnectTime()); + pConfCallInfo->SetCallNotificationTime(heldCall.GetCallNotificationTime()); + } + else + { + pConfCallInfo->SetCallConnectTime(activeCall.GetCallConnectTime()); + pConfCallInfo->SetCallNotificationTime(activeCall.GetCallNotificationTime()); + } + } + pConfCallInfo->SetCallHandle(joinedInfoNotification.id); + pTelManager->__pActiveCallList->RemoveAll(); + //only one call in the list + pTelManager->__pActiveCallList->Add(joinedInfoNotification.id, *pConfCallInfo); + //notify listener that call is connected. + pTelManager->__pEventListener->HandleConferenceCall(*pConfCallInfo); + delete pCallList; + pCallList = null; + } + } + } + else + { + pTelManager->__pEventListener->HandleTelephonyError(ERROR_JOIN_FAILED); + } +} + +void +TelephonyManager::HandleSwapCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (callBackResult == TAPI_CAUSE_SUCCESS) + { + IListT* pCallList = pTelManager->__pActiveCallList->GetValuesN(); + IListT* pKeyList = pTelManager->__pActiveCallList->GetKeysN(); + int callCount = pTelManager->__pActiveCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + CallInfo* pTempCallInfo = new (std::nothrow) CallInfo(); + pCallList->GetAt(index, *pTempCallInfo); + (pTempCallInfo->IsOnHold() == false) ? pTempCallInfo->SetOnHold(true) : pTempCallInfo->SetOnHold(false); + long callHandle; + pKeyList->GetAt(index, callHandle); + pTelManager->__pActiveCallList->SetValue(callHandle, *pTempCallInfo); + } + delete pCallList; + pCallList = null; + delete pKeyList; + pKeyList = null; + pCallList = pTelManager->__pActiveCallList->GetValuesN(); + pTelManager->__pEventListener->HandleCallSwapOccured(*pCallList); + } + else + { + pTelManager->__pEventListener->HandleTelephonyError(ERROR_SWAP_FAILED); + } +} + +void +TelephonyManager::HandleEndFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (callBackResult == TAPI_CAUSE_SUCCESS && pData != null) + { + TelCallEndCnf_t callEndNotification; + memcpy(&callEndNotification, pData, sizeof(TelCallEndCnf_t)); + int confCallIndex = -1; + CallInfo endConfCall; + bool isConferenceCallFound = false; + + IListT* pCallList = pTelManager->__pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + confCallIndex = index; + //Found the Conference call to be ended. + break; + } + } + + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return; + } + delete pCallList; + pCallList = null; + //Identify the call to be ended and remove from list on API success + CallInfo callToBeEnded; + pCallList = endConfCall.GetCallerList(); + callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, callToBeEnded); + if ((unsigned int)callToBeEnded.GetCallHandle()->ToLong() == callEndNotification.id) + { + //Identified the call to be ended and remove from conference list + endConfCall.RemoveCallFromCallerList(index); + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(&callToBeEnded); + break; + } + } + unsigned int confCallHandle = (unsigned int)endConfCall.GetCallHandle()->ToLong(); + //Chk if last participant removed. if so switch to single active view + if (endConfCall.GetCallerListCount() == 1) + { + CallInfo callFromList; + pCallList = endConfCall.GetCallerList(); + pCallList->GetAt(0, callFromList); + CallInfo* pActiveCall = new (std::nothrow) CallInfo(); + *pActiveCall = callFromList; + pActiveCall->SetConference(false); + pTelManager->__pActiveCallList->Remove(confCallHandle); + pTelManager->__pActiveCallList->Add(pActiveCall->GetCallHandle()->ToLong(), *pActiveCall); + pActiveCall = null; + //using the callConnected to switch to single active screen + pCallList = pTelManager->__pActiveCallList->GetValuesN(); + pTelManager->__pEventListener->HandleCallConnected(*pCallList); + pCallList = null; + } + else + { + CallInfo callFromList; + pCallList = endConfCall.GetCallerList(); + pCallList->GetAt(0, callFromList); + + CallInfo* pConfCallInfo = new (std::nothrow) CallInfo(); + *pConfCallInfo = endConfCall; + if (confCallHandle == callEndNotification.id) + { + //Call Handle is same as conf call handle. + //Change conf call handle + pTelManager->__pActiveCallList->Remove(confCallHandle); + int tmpCallHandle = callFromList.GetCallHandle()->ToLong(); + pConfCallInfo->SetCallHandle(tmpCallHandle); + pTelManager->__pActiveCallList->Add(tmpCallHandle, *pConfCallInfo); + } + else + { + pTelManager->__pActiveCallList->SetValue(confCallHandle, *pConfCallInfo ); + } + pTelManager->__pEventListener->HandleConferenceChange(); + } + } + else + { + pTelManager->__pEventListener->HandleTelephonyError(ERROR_END_FROM_CONFERENCE_FAILED); + } +} + +void +TelephonyManager::HandleSplitFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (callBackResult == TAPI_CAUSE_SUCCESS && pData != null) + { + TelCallSplitCnf_t callSplitNotification; + memcpy(&callSplitNotification, pData, sizeof(TelCallSplitCnf_t)); + int confCallIndex = -1; + CallInfo endConfCall; + bool isConferenceCallFound = false; + + IListT* pCallList = pTelManager->__pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, endConfCall); + if (endConfCall.IsConferenceCall() == true) + { + isConferenceCallFound = true; + confCallIndex = index; + //Found the Conference call to be ended. + break; + } + } + + if (isConferenceCallFound == false) + { + delete pCallList; + pCallList = null; + return; + } + delete pCallList; + pCallList = null; + //Identify the call to be ended and remove from list on API success + CallInfo callToBeEnded; + pCallList = endConfCall.GetCallerList(); + callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + pCallList->GetAt(index, callToBeEnded); + if ((unsigned int)callToBeEnded.GetCallHandle()->ToLong() == callSplitNotification.id) + { + //Identified the call to be ended and remove from conference list + //Add this to the active call list + endConfCall.RemoveCallFromCallerList(index); + break; + } + } + unsigned int confCallHandle = (unsigned int)endConfCall.GetCallHandle()->ToLong(); + //Set the hold flags correctly and make the changes to the active call list + if (endConfCall.GetCallerListCount() == 1) + { + //Set hold for the other single call + // and add to the list + CallInfo callFromList; + pCallList = endConfCall.GetCallerList(); + pCallList->GetAt(0, callFromList); + CallInfo* pHeldCall = new (std::nothrow) CallInfo(); + *pHeldCall = callFromList; + pHeldCall->SetConference(false); + pHeldCall->SetOnHold(true); + pTelManager->__pActiveCallList->Remove(confCallHandle); + pTelManager->__pActiveCallList->Add(pHeldCall->GetCallHandle()->ToLong(), *pHeldCall); + pHeldCall = null; + } + else + { + //Set hold flag for conference call + endConfCall.SetOnHold(true); + CallInfo callFromList; + pCallList = endConfCall.GetCallerList(); + pCallList->GetAt(0, callFromList); + + CallInfo* pConfCallInfo = new (std::nothrow) CallInfo(); + *pConfCallInfo = endConfCall; + if (confCallHandle == callSplitNotification.id) + { + //Call Handle is same as conf call handle. + //Change conf call handle + pTelManager->__pActiveCallList->Remove(confCallHandle); + int tmpCallHandle = callFromList.GetCallHandle()->ToLong(); + pConfCallInfo->SetCallHandle(tmpCallHandle); + pTelManager->__pActiveCallList->Add(callFromList.GetCallHandle()->ToLong(), *pConfCallInfo); + } + else + { + pTelManager->__pActiveCallList->Remove(confCallHandle); + pTelManager->__pActiveCallList->Add(confCallHandle, *pConfCallInfo); + } + } + //Add the new active call to active call list + CallInfo* pActiveCall = new (std::nothrow) CallInfo(); + *pActiveCall = callToBeEnded; + pActiveCall->SetConference(false); + pActiveCall->SetOnHold(false); + pTelManager->__pActiveCallList->Remove(pActiveCall->GetCallHandle()->ToLong()); + pTelManager->__pActiveCallList->Add(pActiveCall->GetCallHandle()->ToLong(), *pActiveCall); + pActiveCall = null; + //using the callConnected to switch to Multiple active screen + pCallList = pTelManager->__pActiveCallList->GetValuesN(); + pTelManager->__pEventListener->HandleCallConnected(*pCallList); + pCallList = null; + } + else + { + pTelManager->__pEventListener->HandleTelephonyError(ERROR_SPLIT_FROM_CONFERENCE_FAILED); + } +} + +void +TelephonyManager::HandleIdleCallBack(void* pData, TelephonyManager* pTelManager) +{ + TelCallStatusIdleNoti_t idleNotification; + memcpy(&idleNotification, pData, sizeof(TelCallStatusIdleNoti_t)); + //handle end call event, show next screen + unsigned int endCallHandle = idleNotification.id; + + //fetch ended call details + CallInfo endCallInfo; + result r = pTelManager->__pActiveCallList->GetValue(endCallHandle, endCallInfo); + + if (r == E_SUCCESS) + { + // if (endCallInfo.IsConferenceCall() == true && endCallInfo.GetCallerListCount() > 0 ) + // { + // pTelManager->__pSoundManager->SetSoundMode(SOUND_MODE_VOICE); + // return; + // } + + //remove the call handle from active call list + pTelManager->__pActiveCallList->Remove(endCallHandle); + + //check if the ended call was the last call + bool isLastCall = (pTelManager->__pActiveCallList->GetCount() == 0); + + ArrayListT* pCallList = null; + if (isLastCall) + { + pCallList = new (std::nothrow) ArrayListT(); + pCallList->Construct(1); + + //save end call details + //TODO: map error cause "idleNotification.cause" to error string. + String endCause(L"Call Ended Successfully"); + endCallInfo.SetEndCallCause(endCause); + + // long callDuration = abs(endInfo.CallEndTime - endInfo.CallStartTime); + // endCallInfo.SetEndCallDuration(callDuration); + //save to list + pCallList->Add(endCallInfo); + } + else + { + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } + + if (pTelManager->__isIncomingCallPresent == true) + { + pTelManager->__pSoundManager->StopAlert(); + pTelManager->__isIncomingCallPresent = false; + } + // call should be active now. end the active call now + if (endCallInfo.IsConferenceCall() == false) + { + //Add call ended to call log database + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(&endCallInfo); + if(pTelManager->__pIncomingCall != null && ((unsigned int)pTelManager->__pIncomingCall->GetCallHandle()->ToLong() == endCallHandle)) + { + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = null; + } + } + else + { + int confCallCount = endCallInfo.GetCallerListCount(); + IListT* pCallList = endCallInfo.GetCallerList(); + for (int index = 0; index < confCallCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + //Add call ended to call log database + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(&callInfo); + } + //Once conference calls are added delete the incoming call info + if(pTelManager->__pIncomingCall != null ) + { + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = null; + } + } + if(pTelManager->__pActiveCallList->GetCount() == 0) + { + pTelManager->__pSoundManager->StopSession(); + } + //notify listener that call is connected. + pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); + delete pCallList; + pCallList = null; + } + else + { + //check if the ended call was the dialed call + bool isLastCall = (pTelManager->__pActiveCallList->GetCount() == 0); + ArrayListT* pCallList = null; + if (((pTelManager->__pDialedCall != null) && (((unsigned int)pTelManager->__pDialedCall->GetCallHandle()->ToLong()) == idleNotification.id))) + { + //Call Ended is the dialed call + endCallInfo = *(pTelManager->__pDialedCall); + delete pTelManager->__pDialedCall; + pTelManager->__pDialedCall = null; + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(&endCallInfo); + } + else + { + //Could be incoming call. So notify if incoming call is present + if (isLastCall) + { + pCallList = new (std::nothrow) ArrayListT(); + } + else + { + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } + if(pTelManager->__pIncomingCall != null && ((unsigned int)pTelManager->__pIncomingCall->GetCallHandle()->ToLong() == endCallHandle)) + { + if((pTelManager->__pSettingsManager->IsCallToBeRejected(pTelManager->__pIncomingCall->GetContactNumber()) == false) + && (pTelManager->__pSettingsManager->GetUnknownRejectStatus() == false)) + { + //Missed Call + pTelManager->__pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_MISSED); + pTelManager->__pCalllogMgr->AddCallogInfoToDatabase(pTelManager->__pIncomingCall); + } + + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = null; + } + if (pTelManager->__isIncomingCallPresent == true) + { + pTelManager->__pSoundManager->StopAlert(); + pTelManager->__isIncomingCallPresent = false; + if(pTelManager->__pActiveCallList->GetCount() == 0) + { + pTelManager->__pSoundManager->StopSession(); + } + pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); + } + delete pCallList; + pCallList = null; + pTelManager->__pSoundManager->SetSoundMode(SOUND_MODE_VOICE); + return; + } + + if (isLastCall) + { + pCallList = new (std::nothrow) ArrayListT(); + pCallList->Construct(1); + + //save end call details + //TODO: map error cause "idleNotification.cause" to error string. + String endCause(L"Call Ended Successfully"); + endCallInfo.SetEndCallCause(endCause); + + // long callDuration = abs(endInfo.CallEndTime - endInfo.CallStartTime); + // endCallInfo.SetEndCallDuration(callDuration); + //save to list + pCallList->Add(endCallInfo); + } + else + { + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } + if(pTelManager->__pActiveCallList->GetCount() == 0) + { + //notify listener that call is disconnected. + pTelManager->__pSoundManager->StopSession(); + } + pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); + delete pCallList; + pCallList = null; + } + pTelManager->__pSoundManager->SetSoundMode(SOUND_MODE_VOICE); +} + +void +TelephonyManager::HandleDialingCallBack(void* pData, TelephonyManager* pTelManager) +{ + unsigned int tempHandle = 0; + TelCallStatusDialingNoti_t dialingNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + dialingNotification.id = tempHandle; + if (pTelManager->__pDialedCall) + { + pTelManager->__pDialedCall->SetCallHandle(dialingNotification.id); + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pDialedCall->SetCallNotificationTime(startTime); + pTelManager->__pDialedCall->SetCalllogType(CALL_LOG_TYPE_VOICE_OUTGOING); + } + else + { + delete pTelManager->__pDialedCall; + pTelManager->__pDialedCall = new (std::nothrow) CallInfo(); + pTelManager->__pDialedCall->SetCallHandle(dialingNotification.id); + TelCallStatus_t callStatus; + int res = tel_get_call_status(pTelManager->__pTapiHandle, dialingNotification.id, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + String contactNumber(callStatus.pNumber); + pTelManager->__pDialedCall->SetContactNumber(contactNumber); + result r = pTelManager->FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pTelManager->__pDialedCall->SetContactInfo(*(pTelManager->__pCachedContact)); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pDialedCall->SetCallNotificationTime(startTime); + pTelManager->__pDialedCall->SetCalllogType(CALL_LOG_TYPE_VOICE_OUTGOING); + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pTelManager->__pDialedCall->SetEmergency(true); + } + else + { + pTelManager->__pDialedCall->SetEmergency(false); + } + } + } +} + +void +TelephonyManager::HandleActiveCallBack(void* pData, TelephonyManager* pTelManager) +{ + unsigned int tempHandle = 0; + TelCallStatusActiveNoti_t activeNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + activeNotification.id = tempHandle; + IListT* pCallList = pTelManager->__pActiveCallList->GetValuesN(); + + //Check if the activated call is already present in already activated calls. + bool toHandleEvent = true; + for (int callIndex = 0; (callIndex < pCallList->GetCount() && toHandleEvent == true); callIndex++ ) + { + CallInfo tempCallInfo; + pCallList->GetAt(callIndex, tempCallInfo); + unsigned int tempCallHandle = tempCallInfo.GetCallHandle()->ToLong(); + //Check if active callback came for "HandleJoinCallbackResponse" + //or for "UnHold Conf Call or normal call". + if(tempCallInfo.IsConferenceCall() == true) + { + if (tempCallHandle == activeNotification.id) + { + toHandleEvent = false; + } + else + { + //check individual participants of conf call + IListT* pConfCallList = tempCallInfo.GetCallerList(); + int confCallCount = pConfCallList->GetCount(); + for (int callIndex = 0; (callIndex < confCallCount && toHandleEvent == true); callIndex++) + { + CallInfo confCallerInfo; + pConfCallList->GetAt(callIndex, confCallerInfo); + unsigned int confCallerHandle = confCallerInfo.GetCallHandle()->ToLong(); + if (confCallerHandle == activeNotification.id) + { + toHandleEvent = false; + } + } + } + } + else if(tempCallHandle == activeNotification.id) + { + //If normal call is UnHold + toHandleEvent = false; + } + } + //If duplicate call handle, then to ignore the duplicate event. + if(toHandleEvent == false) + { + delete pCallList; + pCallList = null; + return; + } + + IListT* pKeyList = pTelManager->__pActiveCallList->GetKeysN(); + if( pKeyList->Contains(activeNotification.id) == false) + { + //handle call connected - save info + if (pTelManager->__pDialedCall != null) + { + pTelManager->__pDialedCall->SetCallHandle(activeNotification.id); + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pDialedCall->SetCallConnectTime(startTime); + + if (pTelManager->__pIncomingCall != null && activeNotification.id == (unsigned int)pTelManager->__pIncomingCall->GetCallHandle()->ToLong()) + { + pTelManager->__pDialedCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = null; + } + //transfer ownership to Active calls list + pTelManager->__pActiveCallList->Add(activeNotification.id, *(pTelManager->__pDialedCall)); + } + else + { + //Construct a new CallInfo object for call + //This case will normally come here with incoming call + pTelManager->__pDialedCall = new (std::nothrow) CallInfo(); + //__pDialedCall->SetRequestId(requestId); + pTelManager->__pDialedCall->SetCallHandle(activeNotification.id); + TelCallStatus_t callStatus; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + int res = tel_get_call_status(pTelManager->__pTapiHandle, activeNotification.id, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + String contactNumber(callStatus.pNumber); + pTelManager->__pDialedCall->SetContactNumber(contactNumber); + result r = pTelManager->FetchContactInfoForNumber(contactNumber); + if (!IsFailed(r)) + { + pTelManager->__pDialedCall->SetContactInfo(*(pTelManager->__pCachedContact)); + } + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pTelManager->__pDialedCall->SetEmergency(true); + } + else + { + pTelManager->__pDialedCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pDialedCall->SetCallConnectTime(startTime); + if (pTelManager->__pIncomingCall != null && (activeNotification.id == (unsigned int)pTelManager->__pIncomingCall->GetCallHandle()->ToLong())) + { + pTelManager->__pDialedCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + pTelManager->__pDialedCall->SetCallNotificationTime(pTelManager->__pIncomingCall->GetCallNotificationTime()); + } + //transfer ownership to Active calls list + pTelManager->__pActiveCallList->Add(activeNotification.id, *(pTelManager->__pDialedCall)); + } + } + } + delete pKeyList; + pKeyList = null; + pTelManager->__pDialedCall = null; + + //notify listener that call is connected. + pCallList = pTelManager->__pActiveCallList->GetValuesN(); + pTelManager->__pSoundManager->SetSoundMode(SOUND_MODE_VOICE); + pTelManager->__pEventListener->HandleCallConnected(*pCallList); + if (pTelManager->__isIncomingCallPresent == true) + { + pTelManager->__pSoundManager->StopAlert(); + pTelManager->__isIncomingCallPresent = false; + } + delete pCallList; + pCallList = null; +} + +void +TelephonyManager::HandleIncomingCallBack(void* pData, TelephonyManager* pTelManager) +{ + unsigned int tempHandle = 0; + TelCallStatus_t callStatus; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + int res = tel_get_call_status(pTelManager->__pTapiHandle, tempHandle, &callStatus); + if (res == TAPI_CAUSE_SUCCESS) + { + //This case will normally come here with incoming call + delete pTelManager->__pIncomingCall; + pTelManager->__pIncomingCall = new (std::nothrow) CallInfo(); + pTelManager->__pIncomingCall->SetCallHandle(tempHandle); + String contactNumber(callStatus.pNumber); + pTelManager->__pIncomingCall->SetContactNumber(contactNumber); + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + pTelManager->__pIncomingCall->SetEmergency(true); + } + else + { + pTelManager->__pIncomingCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pIncomingCall->SetCallNotificationTime(startTime); + pTelManager->__pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + //Check whether to reject incoming call or show incoming call screen to user. + bool isRejected = pTelManager->CheckIncomingCallToBeRejected(pTelManager->__pIncomingCall); + if(isRejected == false) + { + //show incoming call notification + CallInfo* pIncomingCall = new (std::nothrow) CallInfo(); + *pIncomingCall = *(pTelManager->__pIncomingCall); + pTelManager->__pEventListener->HandleIncomingCall(*pIncomingCall); + delete pIncomingCall; + } + } +} + +bool +TelephonyManager::CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo) +{ + int callHandle = pIncomingCallInfo->GetCallHandle()->ToLong(); + String contactNumber(L""); + contactNumber.Append(pIncomingCallInfo->GetContactNumber()); + //Fetch contact details from address book. + Contact* pContactDetails = GetContactN(contactNumber); + //Check if "reject unknown calls" is set and contact number is not present in AddressBook + //or if contact number is blacklisted + __isIncomingCallPresent = true; + if (((__pSettingsManager->GetUnknownRejectStatus() == true) && (pContactDetails == null)) + || (__pSettingsManager->IsCallToBeRejected(contactNumber) == true)) + { + AnswerCall(callHandle,false); + //save call rejected info + CallInfo* pRejectedCall = new (std::nothrow) CallInfo(); + *pRejectedCall = *pIncomingCallInfo; + pRejectedCall->SetCalllogType(CALL_LOG_TYPE_VOICE_BLOCKED); + __pCalllogMgr->AddCallogInfoToDatabase(pRejectedCall); + delete pRejectedCall; + delete pContactDetails; + return true; + } + else + { + //update contact person info + if (pContactDetails != null) + { + pIncomingCallInfo->SetContactInfo(*pContactDetails); + delete pContactDetails; + } + return false; + } +} + +void +TelephonyManager::HandleCallback(TapiHandle* pHandle, const char* pNotiId, void* pData, void* pUserData) +{ + unsigned int tempHandle = 0; + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (pTelManager->__pSoundManager == null) + { + AppLog("Creating Sound Manager"); + pTelManager->__pSoundManager = new (std::nothrow) SoundManager(); + } + + + if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_IDLE) == 0) + { + HandleIdleCallBack(pData, pTelManager); + } + else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE) == 0) + { + pTelManager->__pSoundManager->StartSession(); + HandleActiveCallBack(pData, pTelManager); + } + else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_DIALING) == 0) + { + HandleDialingCallBack(pData, pTelManager); + } + /*else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_INCOMING) == 0) + { + HandleIncomingCallBack(pData, pTelManager); + }*/ + else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_HELD) == 0) + { + //TelCallStatusHeldNoti_t heldNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_WAITING) == 0) + { + //TelCallInfoWaitingNoti_t waitingInfoNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_HELD) == 0) + { + //TelCallInfoHeldNoti_t heldInfoNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_ALERT) == 0) + { + //TelCallStatusAlertNoti_t alertNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_VOICE_CALL_STATUS_WAITING) == 0) + { + //TelCallStatusWaitingNoti_t waitingNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_CALL_CONNECTED_LINE) == 0) + { + //TelCallConnectedNumberInfo_t connectedNumberInfo; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_ACTIVE) == 0) + { + //TelCallInfoActiveNoti_t activeInfoNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_JOINED) == 0) + { + //TelCallInfoJoinedNoti_t joinedInfoNotification; + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else if (strcmp(pNotiId, TAPI_NOTI_CALL_INFO_RELEASED_ON_HOLD) == 0) + { + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } + else + { + memcpy(&tempHandle, pData, sizeof(TS_UINT)); + } +} + +CallInfo* +TelephonyManager::GetConferenceCallInfoN(void) +{ + CallInfo* pConfCallInfo = null; + + IListT* pCallList = __pActiveCallList->GetValuesN(); + int callCount = pCallList->GetCount(); + for (int index = 0; index < callCount; index++) + { + CallInfo callInfo; + pCallList->GetAt(index, callInfo); + if (callInfo.IsConferenceCall() == true) + { + pConfCallInfo = new (std::nothrow) CallInfo(); + *pConfCallInfo = callInfo; + //Found the Conference call to be ended. + break; + } + } + delete pCallList; + pCallList = null; + + return pConfCallInfo; +} + +IListT* +TelephonyManager::GetCallListN(void) +{ + ArrayListT* pCallList = null; + if (__pActiveCallList != null) + { + pCallList = static_cast*>(__pActiveCallList->GetValuesN()); + } + return pCallList; +} + +int +TelephonyManager::GetCurrentCallCount(void) +{ + if (__pActiveCallList != null) + { + return __pActiveCallList->GetCount(); + } + return 0; +} + +void +TelephonyManager::StartAlert(CallInfo& incomingCallInfo) +{ + __isIncomingCallPresent = true; + String contactRingTone(L""); + String contactNumber = incomingCallInfo.GetContactNumber(); + //check if not hidden call + if(contactNumber.IsEmpty() == false) + { + //fetch contact info from Db + Contact* foundContact = GetContactN(contactNumber); + if(foundContact != null) + { + //fetch custom ringtone for contact + result r = foundContact->GetValue(CONTACT_PROPERTY_ID_RINGTONE, contactRingTone); + AppLog("ringtone fetched - r = %d", r); + delete foundContact; + foundContact = null; + } + } + __pSoundManager->StartAlert(contactRingTone); +} + +void +TelephonyManager::StopAlert(void) +{ + __pSoundManager->StopAlert(); +} + +result +TelephonyManager::CheckValidTelePhoneNumber(const String& contactNumber) +{ + result r = E_SUCCESS; + if (contactNumber.GetLength() > TAPI_CALL_DIALDIGIT_LEN_MAX) + { + r = E_FAILURE; + } + //TODO: check if valid phonenumber else return error message + return r; +} + +result +TelephonyManager::CheckIfMOCallIsPossible() +{ + result r = E_SUCCESS; + + //Check modem power status + int modemStatus = 0; + int errorCode = tel_check_modem_power_status(__pTapiHandle, &modemStatus); + if (errorCode != TAPI_API_SUCCESS || modemStatus == TAPI_PHONE_POWER_STATUS_OFF + || modemStatus == TAPI_PHONE_POWER_STATUS_ERROR) + { + r = E_FAILURE; + } + else + { + TelSimCardStatus_t simStatus; + int simChangedStatus; + //fetch sim initialization status + int errorCode = tel_get_sim_init_info(__pTapiHandle, &simStatus, &simChangedStatus); + if (errorCode != TAPI_API_SUCCESS) + { + r = E_FAILURE; + } + else + { + switch (simStatus) + { + case TAPI_SIM_STATUS_SIM_INIT_COMPLETED: // Sim Initialization ok + r = E_SUCCESS; + break; + + case TAPI_SIM_STATUS_UNKNOWN: //initial state + case TAPI_SIM_STATUS_CARD_NOT_PRESENT: //Card not present + case TAPI_SIM_STATUS_CARD_REMOVED: //Card removed + case TAPI_SIM_STATUS_CARD_ERROR: // Bad card / On the fly, SIM gone bad + //TODO: might want to set different error code, to give proper message to user + r = E_FAILURE; + break; + default: + r = E_FAILURE; + break; + } + } + } + return r; +} + +bool +TelephonyManager::CheckIfMOCallIsEmergency(const String& contactNumber, bool isSimInitialized) +{ + //TODO: extract actual telephone number from contactNumber + //by deleting prefix,'P','W', etx. + + bool isEmergency = false; + //conversion "contactNumber" to char* + const wchar_t* pContact = contactNumber.GetPointer(); + int len = contactNumber.GetLength() + 1; + char* pNumber = new (std::nothrow) char[len]; + wcstombs(pNumber, pContact, len); + + if(isSimInitialized) + { + //used to get Ecc information for 2G and 3G. + TelSimEccList_t simEccList; + memset(&simEccList, 0x00, sizeof(TelSimEccList_t)); + //Check if given number matches the sim card's emergency numbers + int errorCode = tel_get_sim_ecc(__pTapiHandle, &simEccList); + if (errorCode == TAPI_API_SUCCESS && simEccList.ecc_count > 0) + { + for (int index = 0; index < simEccList.ecc_count; index++) + { + if ((strcmp(pNumber, simEccList.list[index].number) == 0)) + { + isEmergency = true; + } + } + } + } + else + { + //TODO: check if we need to also check SOS call numbers, if sim not present. + } + + delete[] pNumber; + pNumber = null; + return isEmergency; +} + +result +TelephonyManager::FetchContactInfoForNumber(const String& phoneNumberStr) +{ + result r = E_FAILURE; + + //delete previously cached data + if (__pCachedContact != null) + { + delete __pCachedContact; + __pCachedContact = null; + } + + //Searches contacts by phone number. + IList* pContactList = __pAddressBook->SearchContactsByPhoneNumberN(phoneNumberStr); + if (pContactList == null || IsFailed(GetLastResult())) + { + return r; + } + + //Fetch the contact's info to be displayed + IEnumerator* pContactEnum = pContactList->GetEnumeratorN(); + while ((E_SUCCESS == pContactEnum->MoveNext()) && (__pCachedContact == null)) + { + Contact* pContact = static_cast(pContactEnum->GetCurrent()); + + IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + if (pPhoneNumberList != null) + { + IEnumerator* pPhoneEnum = pPhoneNumberList->GetEnumeratorN(); + while (E_SUCCESS == pPhoneEnum->MoveNext()) + { + PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent(); + //Check if this is the correct contact + if (pPhoneNumber->GetPhoneNumber().Equals(phoneNumberStr)) + { + //save newly fetched contact info. + __pCachedContact = new (std::nothrow) Contact(*pContact); + r = E_SUCCESS; + break; + } + } + delete pPhoneEnum; + pPhoneNumberList->RemoveAll(true); + delete pPhoneNumberList; + } + } + delete pContactEnum; + pContactList->RemoveAll(true); + delete pContactList; + + return r; +} + +Contact* +TelephonyManager::GetContactN(const String& phoneNumber) +{ + result r = FetchContactInfoForNumber(phoneNumber); + if (!IsFailed(r)) + { + return new (std::nothrow) Contact(*__pCachedContact); + } + return null; +} + +CallInfo* +TelephonyManager::FetchIncomingCallHandleN(const String& callHandle, const String& contactNumber) +{ + if(__pIncomingCall != null) + { + delete __pIncomingCall; + __pIncomingCall = null; + } + + if(callHandle.IsEmpty() == false) + { + int incomingHandle; + Integer::Parse(callHandle,incomingHandle); + //This API call is synchronous + TelCallStatus_t callStatus; + int errCode = tel_get_call_status(__pTapiHandle, incomingHandle, &callStatus); + if (errCode != TAPI_API_SUCCESS) + { + AppLogDebug("tel_get_call_status_all failed"); + return null; + } + //construct incoming call info object + __pIncomingCall = new (std::nothrow) CallInfo(); + __pIncomingCall->SetCallHandle(incomingHandle); + + //contact number + String phoneNumber(contactNumber); + if(phoneNumber.IsEmpty() == true) + { + phoneNumber.Append(callStatus.pNumber); + } + __pIncomingCall->SetContactNumber(phoneNumber); + //set emergency state + if(callStatus.CallType == TAPI_CALL_TYPE_E911) + { + __pIncomingCall->SetEmergency(true); + } + else + { + __pIncomingCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + __pIncomingCall->SetCallNotificationTime(startTime); + __pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + } + else + { + //TODO: This 'else' block can be removed once AppControl request API is stabilized. + //This API call is synchronous and 'HandleIncomingCallStatusCallBack' is called for each active call. + int errCode = tel_get_call_status_all(__pTapiHandle, &HandleIncomingCallStatusCallBack, this); + if (errCode != TAPI_API_SUCCESS) + { + return null; + } + } + + //construct a new callinfo object to pass its ownership to caller. + if(__pIncomingCall != null) + { + CallInfo* pNewIncomingCall = new (std::nothrow) CallInfo(); + *pNewIncomingCall = *__pIncomingCall; + return pNewIncomingCall; + } + //return null, if no incoming call found + return null; +} + +void +TelephonyManager::HandleIncomingCallStatusCallBack(TelCallStatus_t* pCallStatus, void* pUserData) +{ + TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + if (pCallStatus != null && pCallStatus->bMoCall == false + && ((pCallStatus->CallState == TAPI_CALL_STATE_INCOMING) + || (pCallStatus->CallState == TAPI_CALL_STATE_WAITING))) + { + //construct incoming call details + pTelManager->__pIncomingCall = new (std::nothrow) CallInfo(); + pTelManager->__pIncomingCall->SetCallHandle(pCallStatus->CallHandle); + //contact number + String contactNumber(pCallStatus->pNumber); + pTelManager->__pIncomingCall->SetContactNumber(contactNumber); + //set emergency state + if(pCallStatus->CallType == TAPI_CALL_TYPE_E911) + { + pTelManager->__pIncomingCall->SetEmergency(true); + } + else + { + pTelManager->__pIncomingCall->SetEmergency(false); + } + //set start time, when call is connected + long long startTime = 0; + SystemTime::GetTicks(startTime); + pTelManager->__pIncomingCall->SetCallNotificationTime(startTime); + pTelManager->__pIncomingCall->SetCalllogType(CALL_LOG_TYPE_VOICE_INCOMING); + } +} diff --git a/src/PhnTypes.cpp b/src/PhnTypes.cpp new file mode 100644 index 0000000..18a7219 --- /dev/null +++ b/src/PhnTypes.cpp @@ -0,0 +1,317 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file PhnTypes.cpp + * @brief Common constants used in Phone application + */ +#include "PhnTypes.h" + +//bitmap +const wchar_t* IDB_BTN_OPTION_BG_ICON = L"C01-3_dialer_btn_option_bg.9.png"; +const wchar_t* IDB_BTN_OPTION_PRESS_BG_ICON = L"C01-3_dialer_btn_option_press.9.png"; +const wchar_t* IDB_BTN_MORE_ICON = L"more.png"; +const wchar_t* IDB_BTN_MORE_PRESS_ICON = L"more_press.png"; +const wchar_t* IDB_POPUP_BUBBLE_ICON = L"00_popup_bubble_tail_bottom.png"; +const wchar_t* IDB_DIALER_BTN_LINE_ICON = L"C01-3_dialer_btn_1line_bg.9.png"; +const wchar_t* IDB_DIALER_BTN_PRESS_ICON = L"C01-3_dialer_btn_press.9.png"; +const wchar_t* IDB_VOICEMAIL_BTN_ICON = L"C01-3_dialer_icon_01.png"; +const wchar_t* IDB_VOICEMAIL_BTN_PRESS_ICON = L"C01-3_dialer_icon_01_press.png"; +const wchar_t* IDB_DIALER_BTN_LINE2_ICON = L"C01-3_dialer_btn_2line_bg.9.png"; +const wchar_t* IDB_DIALER_BTN_LINE3_ICON = L"C01-3_dialer_btn_3line_bg.9.png"; +const wchar_t* IDB_DIALER_BTN_LINE4_ICON = L"C01-3_dialer_btn_4line_bg.9.png"; +const wchar_t* IDB_DIALER_BTN_LINE5_ICON = L"C01-3_dialer_btn_5line_bg.9.png"; +const wchar_t* IDB_DIALER_STAR_ICON = L"C01-3_dialer_icon_star.png"; +const wchar_t* IDB_DIALER_MUTE_ICON = L"00_volume_icon_Mute.png"; +const wchar_t* IDB_DIALER_VIDEOCALL_ICON = L"C01-3_icon_voicecall.png"; +const wchar_t* IDB_DIALER_CALL_ICON = L"C01-3_icon_call.png"; +const wchar_t* IDB_DIALER_CLEAR_ICON = L"C01-3_icon_clear.png"; +const wchar_t* IDB_DIALER_CALL_BG_ICON = L"C01-3_dialer_btn_call_bg.9.png"; +const wchar_t* IDB_HIDE_KEYPAD_ICON = L"C01-1_icon_Hide.png"; +const wchar_t* IDB_HIDE_KEYPAD_PRESS_ICON = L"C01-1_icon_Hide_press_wh.png"; +const wchar_t* IDB_HIDE_KEYPAD_DIM_ICON = L"C01-1_icon_Hide_dim.png"; +const wchar_t* IDB_CLOSE_KEYPAD_ICON = L"C01-1_icon_keypad.png"; +const wchar_t* IDB_CLOSE_KEYPAD_PRESS_ICON = L"C01-1_icon_keypad_press_wh.png"; +const wchar_t* IDB_CLOSE_KEYPAD_DIM_ICON = L"C01-1_icon_keypad_dim.png"; +const wchar_t* IDB_SPEAKER_ON_ICON = L"C01-1_icon_speaker_on.png"; +const wchar_t* IDB_SPEAKER_ON_PRESS_ICON = L"C01-1_icon_speaker_on_press.png"; +const wchar_t* IDB_SPEAKER_ON_DIM_ICON = L"C01-1_icon_speaker_on_dim.png"; +const wchar_t* IDB_SPEAKER_OFF_ICON = L"C01-1_icon_speaker.png"; +const wchar_t* IDB_SPEAKER_OFF_PRESS_ICON = L"C01-1_icon_speaker_press_wh.png"; +const wchar_t* IDB_SPEAKER_OFF_DIM_ICON = L"C01-1_icon_speaker_dim.png"; +const wchar_t* IDB_MUTE_ON_ICON = L"C01-1_icon_mute_on.png"; +const wchar_t* IDB_MUTE_ON_PRESS_ICON = L"C01-1_icon_mute_on_press.png"; +const wchar_t* IDB_MUTE_ON_DIM_ICON = L"C01-1_icon_mute_on_dim.png"; +const wchar_t* IDB_MUTE_OFF_ICON = L"C01-1_icon_mute.png"; +const wchar_t* IDB_MUTE_OFF_PRESS_ICON = L"C01-1_icon_mute_press_wh.png"; +const wchar_t* IDB_MUTE_OFF_DIM_ICON = L"C01-1_icon_mute_dim.png"; +const wchar_t* IDB_BACKGROUND_BITMAP = L"C01-1_call_bg.png"; +const wchar_t* IDB_VOICE_CALL_ICON = L"C01-1_icon_voice call.png"; +const wchar_t* IDB_VOICE_CALL_PRESS_ICON = L"C01-1_icon_voice call_press.png"; +const wchar_t* IDB_VOICE_CALL_DIM_ICON = L"C01-1_icon_voice call_dim.png"; +const wchar_t* IDB_VIDEO_CALL_ICON = L"C01-1_icon_video call.png"; +const wchar_t* IDB_VIDEO_CALL_PRESS_ICON = L"C01-1_icon_video call_press.png"; +const wchar_t* IDB_VIDEO_CALL_DIM_ICON = L"C01-1_icon_video call_dim.png"; +const wchar_t* IDB_MESSAGE_ICON = L"C01-1_icon_message.png"; +const wchar_t* IDB_MESSAGE_PRESS_ICON = L"C01-1_icon_message_press.png"; +const wchar_t* IDB_MESSAGE_DIM_ICON = L"C01-1_icon_message_dim.png"; +const wchar_t* IDB_END_CALL_ICON = L"C01-1_icon_end call.png"; +const wchar_t* IDB_END_CALL_PRESS_ICON = L"C01-1_icon_end call_press.png"; +const wchar_t* IDB_END_CALL_DIM_ICON = L"C01-1_icon_end call_dim.png"; +const wchar_t* IDB_ADD_CALL_ICON = L"C01-1_icon_add.png"; +const wchar_t* IDB_ADD_CALL_PRESS_ICON = L"C01-1_icon_add_press_wh.png"; +const wchar_t* IDB_ADD_CALL_DIM_ICON = L"C01-1_icon_add_dim.png"; +const wchar_t* IDB_JOIN_CALL_ICON = L"C01-1_icon_join.png"; +const wchar_t* IDB_JOIN_CALL_PRESS_ICON = L"C01-1_icon_join_press_wh.png"; +const wchar_t* IDB_JOIN_CALL_DIM_ICON = L"C01-1_icon_join_dim.png"; +const wchar_t* IDB_CONTACT_ICON = L"C01-1_icon_contacts.png"; +const wchar_t* IDB_CONTACT_PRESS_ICON = L"C01-1_icon_contacts_press_wh.png"; +const wchar_t* IDB_CONTACT_DIM_ICON = L"C01-1_icon_contacts_dim.png"; +const wchar_t* IDB_SWAP_ICON_NORMAL = L"C01-1_icon_swap.png"; +const wchar_t* IDB_SWAP_ICON_PRESS = L"C01-1_icon_swap_press.png"; +const wchar_t* IDB_UNHOLD_NORMAL_BUTTON_ICON = L"C01-1_icon_unhold_78x78.png"; +const wchar_t* IDB_UNHOLD_PRESS_BUTTON_ICON = L"C01-1_icon_unhold_78x78_press.png"; +const wchar_t* IDB_HOLD_NORMAL_BUTTON_ICON = L"C01-1_icon_hold_78x78.png"; +const wchar_t* IDB_HOLD_PRESS_BUTTON_ICON = L"C01-1_icon_hold_78x78_press.png"; +const wchar_t* IDB_POPUP_ARROW_ICON = L"C01-1_popup_arrow.png"; +const wchar_t* IDB_POPUP_BG_ICON = L"C01-1_popup_bg.png"; +const wchar_t* IDB_MORE_MANAGE_CONFERENCE_ICON = L"C01-1_icon_more_Manage conference call.png"; +const wchar_t* IDB_CONFERENCE_BG_ICON = L"C01-1_multil_default_caller ID_720x370.png"; +const wchar_t* IDB_CONFERENCE_BIG_BG_ICON = L"C01-1_multil_default_caller ID_720x720.png"; +const wchar_t* IDB_ACTIVE_CALL_DEFAULT_ICON = L"C01-1_end call_default_caller ID_720x720.png"; +const wchar_t* IDB_MULTIPLE_CALL_DEFAULT_ICON = L"C01-1_end call_default_caller ID_720x370.png"; +const wchar_t* IDB_KEYPAD_BUTTON_NORMAL = L"C01-1_keypad_btn_normal.png"; +const wchar_t* IDB_KEYPAD_BUTTON_PRESS = L"C01-1_keypad_btn_press.png"; +const wchar_t* IDB_KEYPAD_NUM1_ICON = L"C01-1_keypad_btn_icon.png"; +const wchar_t* IDB_CALLOG_LIST_BG = L"00_index list_bg.png"; +const wchar_t* IDB_LOG_RECEIVEDCALL_ICON = L"C01-4_icon_dialed.png"; +const wchar_t* IDB_LOG_DIALEDCALL_ICON = L"C01-4_icon_received.png"; +const wchar_t* IDB_LOG_MISSEDCALL_ICON = L"C01-4_icon_missed-call.png"; +const wchar_t* IDB_LOG_BLOCKEDCALL_ICON = L"C01-4_icon_Blocked(Auto-rejected).png"; +const wchar_t* IDB_LOG_DETAIL_CALL_ICON = L"C01-4_btn_icon_call.png"; +const wchar_t* IDB_LOG_DETAIL_MSG_ICON = L"C01-1_icon_Reject_with_Message.png"; +const wchar_t* IDB_LOG_NO_CONTENT = L"00_Nocontents_text.png"; + + +//String messages +const wchar_t* IDS_DIALER_MOBILE_STR = L"IDS_DIALER_MOBILE_STR"; +const wchar_t* IDS_DIALER_SPEEDDIAL_POPUP_MSG = L"IDS_DIALER_SPEEDDIAL_POPUP_MSG"; +const wchar_t* IDS_SPEEDDIAL_POP_YES_BTN_STRING = L"IDS_SPEEDDIAL_POP_YES_BTN_STRING"; +const wchar_t* IDS_SPEEDDIAL_POP_NO_BTN_STRING = L"IDS_SPEEDDIAL_POP_NO_BTN_STRING"; +const wchar_t* IDS_DIALER_MENU_ITEM_SEND_MSG = L"IDS_DIALER_MENU_ITEM_SEND_MSG"; +const wchar_t* IDS_DIALER_MENU_ITEM_ADD_CONTACT = L"IDS_DIALER_MENU_ITEM_ADD_CONTACT"; +const wchar_t* IDS_DIALER_MENU_ITEM_SPEED_DIAL = L"IDS_DIALER_MENU_ITEM_SPEED_DIAL"; +const wchar_t* IDS_DIALER_MENU_ITEM_ADD_PAUSE = L"IDS_DIALER_MENU_ITEM_ADD_PAUSE"; +const wchar_t* IDS_DIALER_MENU_ITEM_ADD_WAIT = L"IDS_DIALER_MENU_ITEM_ADD_WAIT"; +const wchar_t* IDS_DIALER_MENU_ITEM_EXIT = L"IDS_DIALER_MENU_ITEM_EXIT"; +const wchar_t* IDS_SPEED_DIAL_SEARCH_KEY = L"SPEED_DIAL"; +const wchar_t* IDS_KEYPAD_BTN_NAME = L"IDS_KEYPAD_BTN_NAME"; +const wchar_t* IDS_SPEAKER_BTN_NAME = L"IDS_SPEAKER_BTN_NAME"; +const wchar_t* IDS_MUTE_BTN_NAME = L"IDS_MUTE_BTN_NAME"; +const wchar_t* IDS_VOICE_CALL_BTN_NAME = L"IDS_VOICE_CALL_BTN_NAME"; +const wchar_t* IDS_VIDEO_CALL_BTN_NAME = L"IDS_VIDEO_CALL_BTN_NAME"; +const wchar_t* IDS_MSG_BTN_NAME = L"IDS_MSG_BTN_NAME"; +const wchar_t* IDS_ENDCALL_BTN_NAME = L"IDS_ENDCALL_BTN_NAME"; +const wchar_t* IDS_ADDCALL_BTN_NAME = L"IDS_ADDCALL_BTN_NAME"; +const wchar_t* IDS_JOINCALL_BTN_NAME = L"IDS_JOINCALL_BTN_NAME"; +const wchar_t* IDS_CONTACT_BTN_NAME = L"IDS_CONTACT_BTN_NAME"; +const wchar_t* IDS_HOLD_BTN_NAME = L"IDS_HOLD_BTN_NAME"; +const wchar_t* IDS_UNHOLD_BTN_NAME = L"IDS_UNHOLD_BTN_NAME"; +const wchar_t* IDS_PEOPLE_STR = L"IDS_PEOPLE_STR"; +const wchar_t* IDS_MGR_CONF_CALL_LIST_STR = L"IDS_MGR_CONF_CALL_LIST_STR"; +const wchar_t* IDS_LOG_CONTEXT_CALL = L"IDS_LOG_CONTEXT_CALL"; +const wchar_t* IDS_LOG_CONTEXT_MESSAGE = L"IDS_LOG_CONTEXT_MESSAGE"; +const wchar_t* IDS_LOG_CONTEXT_VIDEOCALL = L"IDS_LOG_CONTEXT_VIDEOCALL"; +const wchar_t* IDS_LOG_CONTEXT_DELETE = L"IDS_LOG_CONTEXT_DELETE"; +const wchar_t* IDS_AM_TIME = L"IDS_AM_TIME" ; +const wchar_t* IDS_PM_TIME = L"IDS_PM_TIME"; +const wchar_t* IDS_CALLLOG_NO_NUMBER = L"IDS_CALLLOG_NO_NUMBER"; +const wchar_t* IDS_CALLLOG_NO_NAME = L"IDS_CALLLOG_NO_NAME"; +const wchar_t* IDS_CALLLOG_RECEIVED = L"IDS_CALLLOG_RECEIVED"; +const wchar_t* IDS_CALLLOG_MISSED = L"IDS_CALLLOG_MISSED"; +const wchar_t* IDS_CALLLOG_OUTGOING = L"IDS_CALLLOG_OUTGOING"; +const wchar_t* IDS_CALLLOG_RECEIVED_MSG = L"IDS_CALLLOG_RECEIVED_MSG"; +const wchar_t* IDS_CALLLOG_SENT_MSG = L"IDS_CALLLOG_SENT_MSG"; +const wchar_t* IDS_CALLLOG_REJECTED = L"IDS_CALLLOG_REJECTED"; +const wchar_t* IDS_CALLLOG_DELETE_FOOTER = L"IDS_CALLLOG_DELETE_FOOTER"; +const wchar_t* IDS_CALLLOG_CANCEL_FOOTER = L"IDS_CALLLOG_CANCEL_FOOTER"; +const wchar_t* IDS_EMERGENCY_CALL = L"IDS_EMERGENCY_CALL"; +const wchar_t* IDS_SELECT_CALL_LOG = L"IDS_SELECT_CALL_LOG"; +const wchar_t* IDS_SELECTED_ITEMS_STRING = L"IDS_SELECTED_ITEMS_STRING"; +const wchar_t* IDS_SELECTED_ITEM_STRING = L"IDS_SELECTED_ITEM_STRING"; +const wchar_t* IDS_SELECT_NUMBER = L"IDS_SELECT_NUMBER"; +const wchar_t* IDS_NUMBER_SELECTED = L"IDS_NUMBER_SELECTED"; +const wchar_t* IDS_NUMBERS_SELECTED = L"IDS_NUMBERS_SELECTED"; +const wchar_t* IDS_SELECT_MESSAGE = L"IDS_SELECT_MESSAGE"; +const wchar_t* IDS_MESSAGE_SELECTED = L"IDS_MESSAGE_SELECTED"; +const wchar_t* IDS_MESSAGES_SELECTED = L"IDS_MESSAGES_SELECTED"; +const wchar_t* IDS_NO_LOGS = L"IDS_NO_LOGS"; + +//Panel +const wchar_t* PANEL_DIALER = L"PanelDialer"; +const wchar_t* PANEL_LOGS = L"PanelLogs"; + +//Corresponding Call form name +const wchar_t* IDL_FORM_OUTCALL = L"OutgoingCallForm"; +const wchar_t* IDL_FORM_OUT_EMERGENCYCALL = L"OutgoingEmergencyCallForm"; +const wchar_t* IDL_FORM_INCOMINGCALL = L"IncomingCallForm"; +const wchar_t* IDL_FORM_ACTIVECALL = L"ActiveCallForm"; +const wchar_t* IDL_FORM_ACTIVE_EMERGENCYCALL = L"ActiveEmergencyCallForm"; +const wchar_t* IDL_FORM_CONFCALL = L"ActiveConfCallForm"; +const wchar_t* IDL_FORM_CONFCALLLIST = L"ConfCallListForm "; +const wchar_t* IDL_FORM_ENDCALL = L"EndCallForm"; +const wchar_t* IDL_FORM_MULTIPLEACTIVECALL = L"MultipleActiveCallForm"; +//Corresponding Settings form name +const wchar_t* IDL_FORM_SETTINGS_PREFIX = L"SettingsForm"; +const wchar_t* IDL_FORM_MAIN_SETTING_MENU = L"SettingsFormMainMenu"; +const wchar_t* IDL_FORM_CALL_REJECTLIST_MENU = L"SettingsFormCallRejectList"; +const wchar_t* IDL_FORM_CALL_REJECTMSGS_MENU = L"SettingsFormCallRejectMsgs"; +const wchar_t* IDL_FORM_SPEED_DIAL = L"SettingsFormSpeedDial"; +const wchar_t* IDL_FORM_MORE_OPTIONS = L"SettingsFormMoreOptions"; +const wchar_t* IDL_FORM_CALL_STATUSTONES = L"SettingsFormCallStatusTones"; +const wchar_t* IDL_FORM_CALLTYPE_FORWARD = L"SettingsFormCallTypeForward"; +const wchar_t* IDL_FORM_CALL_FORWARD_OPTIONS = L"SettingsFormCallForwardMenu"; +const wchar_t* IDL_FORM_CALLTYPE_BARRING = L"SettingsFormCallTypeBarring"; +const wchar_t* IDL_FORM_CALL_BARRING_OPTIONS = L"SettingsFormCallBarringMenu"; +const wchar_t* IDL_FORM_CALL_WAITING_OPTIONS = L"SettingsFormCallWaitingMenu"; +const wchar_t* IDL_FORM_ADD_REJECT_NUMBER = L"SettingsFormAddRejectNumber"; +const wchar_t* IDL_FORM_AUTO_AREA_CODE = L"SettingsFormAutoAreaCode"; +const wchar_t* IDL_FORM_ADD_REJECT_MSG = L"SettingsFormAddRejectMsg"; +const wchar_t* IDL_FORM_EDIT_REJECT_MSG = L"SettingsFormEditRejectMsg"; +const wchar_t* IDL_FORM_FORWARD_TO_NUMBER = L"SettingsFormForwardToNumber"; +const wchar_t* IDL_FORM_NOREPLY_FORWARD_TO_NUMBER = L"SettingsFormNoReplyForwardToNumber"; +const wchar_t* IDL_FORM_SCENE_SET_BARRING_PWD = L"SettingsFormSetBarringPwd"; +const wchar_t* IDL_FORM_DEL_NUMBER = L"SettingsFormDeleteNumbers"; +const wchar_t* IDL_FORM_DEL_MESSAGE = L"SettingsFormDeleteMessages"; +//Dialer & Call Log Form names +const wchar_t* IDL_FORM_DIAL_APP = L"DialAppForm"; +const wchar_t* IDL_FORM_CALL_LOG_DETAIL = L"CallLogDetailForm"; +const wchar_t* IDL_CALL_PANEL = L"IDL_KEYS_PANEL"; +const wchar_t* IDL_END_CALL_PANEL = L"IDL_ENDCALLKEYS_PANEL"; +const wchar_t* IDL_OUTCALL_FORM = L"IDL_OUTCALL_FORM"; +const wchar_t* IDL_OUT_EMERGENCYCALL_FORM = L"IDL_OUT_EMERGENCYCALL_FORM"; +const wchar_t* IDL_CALL_FORM = L"IDL_CALL_FORM"; +const wchar_t* IDL_EMERGENCY_CALL_FORM = L"IDL_EMERGENCY_CALL_FORM"; +const wchar_t* IDL_MULTIPLE_CALL_FORM = L"IDL_MULTIPLE_CALL_FORM"; +const wchar_t* IDL_CONFCALL_FORM = L"IDL_CONFCALL_FORM"; +const wchar_t* IDL_DTMF_PANEL = L"IDL_DTMF_KEYPAD_PANEL"; +const wchar_t* IDL_DIALER_KEYPAD_PANEL = L"IDL_DIALER_KEYPAD_PANEL"; +const wchar_t* IDL_FORM_EMERGENCY_DIAL = L"IDL_FORM_EMERGENCY_DIAL"; + +//Constants - Call Scene name +const wchar_t* IDSCN_SCENE_OUTCALL = L"OutgoingCallScene"; +const wchar_t* IDSCN_SCENE_OUT_EMERGENCYCALL = L"OutgoingEmergencyCallScene"; +const wchar_t* IDSCN_SCENE_INCOMINGCALL = L"IncomingCallScene"; +const wchar_t* IDSCN_SCENE_ACTIVECALL = L"ActiveCallScene"; +const wchar_t* IDSCN_SCENE_ACTIVE_EMERGENCYCALL = L"ActiveEmergencyCallScene"; +const wchar_t* IDSCN_SCENE_CONFCALL = L"ActiveConfCallScene"; +const wchar_t* IDSCN_SCENE_CONFCALLLIST = L"ConfCallListScene"; +const wchar_t* IDSCN_SCENE_ENDCALL = L"EndCallScene"; +const wchar_t* IDSCN_SCENE_MULTIPLEACTIVECALL = L"MultipleActiveCallScene"; +//Constants - Settings Scene name +const wchar_t* IDSCN_SCENE_MAIN_SETTING_MENU = L"CallMainSettingScene"; +const wchar_t* IDSCN_SCENE_CALL_REJECTLIST_MENU = L"CallRejectListScene"; +const wchar_t* IDSCN_SCENE_CALL_REJECTMSGS_MENU = L"CallRejectMsgsScene"; +const wchar_t* IDSCN_SCENE_SPEED_DIAL = L"SpeedDialScene"; +const wchar_t* IDSCN_SCENE_MORE_OPTIONS = L"MoreOptionsScene"; +const wchar_t* IDSCN_SCENE_CALL_STATUSTONES = L"CallStatusTonesScene"; +const wchar_t* IDSCN_SCENE_CALLTYPE_FORWARD = L"CallTypeForwardScene"; +const wchar_t* IDSCN_SCENE_CALL_FORWARD_OPTIONS = L"CallForwardMenuScene"; +const wchar_t* IDSCN_SCENE_CALLTYPE_BARRING = L"CallTypeBarringScene"; +const wchar_t* IDSCN_SCENE_CALL_BARRING_OPTIONS = L"CallBarringMenuScene"; +const wchar_t* IDSCN_SCENE_CALL_WAITING_OPTIONS = L"CallWaitingMenuScene"; +const wchar_t* IDSCN_SCENE_ADD_REJECT_NUMBER = L"AddRejectNumberScene"; +const wchar_t* IDSCN_SCENE_AUTO_AREA_CODE = L"AutoAreaCodeScene"; +const wchar_t* IDSCN_SCENE_ADD_REJECT_MSG = L"AddRejectMsgScene"; +const wchar_t* IDSCN_SCENE_EDIT_REJECT_MSG = L"EditRejectMsgScene"; +const wchar_t* IDSCN_SCENE_FORWARD_TO_NUMBER = L"ForwardToNumberScene"; +const wchar_t* IDSCN_SCENE_NOREPLY_FORWARD_TO_NUMBER = L"NoReplyForwardToNumberScene"; +const wchar_t* IDSCN_SCENE_SET_BARRING_PWD = L"SetBarringPwdScene"; +const wchar_t* IDSCN_SCENE_DEL_NUMBER = L"DeleteNumbersScene"; +const wchar_t* IDSCN_SCENE_DEL_MESSAGE = L"DeleteMessagesScene"; +//Dialer & Call Log Scene names +const wchar_t* IDSCN_DIALER = L"SceneDialer"; +const wchar_t* IDSCN_CALL_LOG = L"SceneCallLog"; +const wchar_t* IDSCN_CALL_LOG_DETAILS = L"SceneCallLogDetails"; +const wchar_t* IDSCN_EMERGENCY_DIAL = L"SceneEmergencyDial"; + +const wchar_t* TYPE_VIDEO = L"type:video"; +const wchar_t* TYPE_VOICE = L"type:voice"; +const wchar_t* TYPE_SMS = L"type:SMS"; +const wchar_t* TEL = L"tel:"; +const wchar_t* TO = L"to:"; + +const wchar_t* OPERATION_ID_PICK = L"http://tizen.org/appcontrol/operation/pick"; +const wchar_t* OPERATION_ID_VIEW = L"http://tizen.org/appcontrol/operation/view"; +const wchar_t* OPERATION_ID_ADD = L"http://tizen.org/appcontrol/operation/add"; +const wchar_t* OPERATION_ID_EDIT = L"http://tizen.org/appcontrol/operation/edit"; +const wchar_t* OPERATION_ID_CONFIGURE = L"http://tizen.org/appcontrol/operation/configure"; +const wchar_t* OPERATION_ID_CAPTURE = L"http://tizen.org/appcontrol/operation/capture"; +const wchar_t* OPERATION_ID_CALL = L"http://tizen.org/appcontrol/operation/call"; +const wchar_t* OPERATION_ID_COMPOSE = L"http://tizen.org/appcontrol/operation/compose"; +const wchar_t* OPERATION_ID_DIAL = L"http://tizen.org/appcontrol/operation/dial"; + +const wchar_t* PROVIDER_ID_CAMERA = L"http://tizen.org/appcontrol/provider/camera"; +const wchar_t* PROVIDER_ID_GALLERY = L"http://tizen.org/appcontrol/provider/gallery"; +const wchar_t* PROVIDER_ID_CALL = L"http://tizen.org/appcontrol/provider/call"; +const wchar_t* PROVIDER_ID_MESSAGE = L"http://tizen.org/appcontrol/provider/message"; +const wchar_t* PROVIDER_ID_EMAIL = L"http://tizen.org/appcontrol/provider/email"; +const wchar_t* PROVIDER_ID_MEDIA = L"http://tizen.org/appcontrol/provider/media"; +const wchar_t* PROVIDER_ID_CONTACTS = L"f9uev8hsyo.Contacts"; + +const wchar_t* RETURN_TYPE_PHONE = L"phone"; +const wchar_t* RETURN_TYPE_EMAIL = L"Email"; +const wchar_t* RETURN_TYPE_CONTACT_ID = L"contactId"; + +//Constants used in AppControl requests +const wchar_t* DELIMITER = L":"; +const wchar_t* LAUNCHTYPE = L"launch-type"; +const wchar_t* PARAM_ORIGIN_MT = L"MT"; +const wchar_t* CALL_HANDLE = L"handle"; +const wchar_t* CONTACT_NUMBER = L"number"; +const wchar_t* PARAM_CALL_VALUE_VOICE = L"voice"; +const wchar_t* PARAM_CALL_TYPE = L"type"; +const wchar_t* PARAM_PHONE_NUMBER = L"tel"; +const wchar_t* INPUT_TYPE_PHONE = L"phone"; +const wchar_t* MESSAGE_TYPE = L"type"; +const wchar_t* MESSAGE_SMS_TYPE = L"SMS"; +const wchar_t* MESSAGE_TEXT = L"text"; +const wchar_t* MESSAGE_TO = L"to"; + +const wchar_t* SELECTION_MODE = L"selectionMode"; +const wchar_t* RETURN_TYPE = L"returnType"; +const wchar_t* SELECTION_MODE_SINGLE = L"single"; +const wchar_t* RETURN_KEY_VALUE = L"value"; + +//Dimensions for Small photo of caller/callee. +const int W_SMALL_PHOTO = 366; +const int H_SMALL_PHOTO = 366; +const int W_CONFERENCE_PHOTO = 720; +const int H_CONFERENCE_PHOTO = 370; +//Maximum number of calls +const int IDI_MAX_ACTIVE_CALLS = 2; +const int IDI_MAX_CONF_CALL_PARTICIPANTS = 5; +//Constants used for custom list item in message panel in Incoming call screen +const int IDA_FORMAT_SENDTEXT = 500; +//Constants +const wchar_t* IDI_KEY2_TXT = L"ABC"; +const wchar_t* IDI_KEY3_TXT = L"DEF"; +const wchar_t* IDI_KEY4_TXT = L"GHI"; +const wchar_t* IDI_KEY5_TXT = L"JKL"; +const wchar_t* IDI_KEY6_TXT = L"MNO"; +const wchar_t* IDI_KEY7_TXT = L"PQRS"; +const wchar_t* IDI_KEY8_TXT = L"TUV"; +const wchar_t* IDI_KEY9_TXT = L"WXYZ";