Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | ======================================================================== |
| 3 | Name : PjsuaContainerView.cpp |
| 4 | Author : nanang |
| 5 | Copyright : Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) |
| 6 | Description : |
| 7 | ======================================================================== |
| 8 | */ |
| 9 | // [[[ begin generated region: do not modify [Generated System Includes] |
| 10 | #include <aknviewappui.h> |
| 11 | #include <eikmenub.h> |
| 12 | #include <avkon.hrh> |
| 13 | #include <barsread.h> |
| 14 | #include <eikimage.h> |
| 15 | #include <eikenv.h> |
| 16 | #include <stringloader.h> |
| 17 | #include <eiklabel.h> |
| 18 | #include <akncontext.h> |
| 19 | #include <akntitle.h> |
| 20 | #include <eikbtgpc.h> |
| 21 | #include <pjsua.rsg> |
| 22 | // ]]] end generated region [Generated System Includes] |
| 23 | |
| 24 | // [[[ begin generated region: do not modify [Generated User Includes] |
| 25 | |
| 26 | #include "pjsua.hrh" |
| 27 | #include "pjsuaContainerView.h" |
| 28 | #include "pjsuaContainer.h" |
| 29 | // ]]] end generated region [Generated User Includes] |
| 30 | |
| 31 | // [[[ begin generated region: do not modify [Generated Constants] |
| 32 | // ]]] end generated region [Generated Constants] |
| 33 | |
| 34 | /** |
| 35 | * First phase of Symbian two-phase construction. Should not contain any |
| 36 | * code that could leave. |
| 37 | */ |
| 38 | CpjsuaContainerView::CpjsuaContainerView() |
| 39 | { |
| 40 | // [[[ begin generated region: do not modify [Generated Contents] |
| 41 | iPjsuaContainer = NULL; |
| 42 | // ]]] end generated region [Generated Contents] |
| 43 | |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * The view's destructor removes the container from the control |
| 48 | * stack and destroys it. |
| 49 | */ |
| 50 | CpjsuaContainerView::~CpjsuaContainerView() |
| 51 | { |
| 52 | // [[[ begin generated region: do not modify [Generated Contents] |
| 53 | delete iPjsuaContainer; |
| 54 | iPjsuaContainer = NULL; |
| 55 | // ]]] end generated region [Generated Contents] |
| 56 | |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Symbian two-phase constructor. |
| 61 | * This creates an instance then calls the second-phase constructor |
| 62 | * without leaving the instance on the cleanup stack. |
| 63 | * @return new instance of CpjsuaContainerView |
| 64 | */ |
| 65 | CpjsuaContainerView* CpjsuaContainerView::NewL() |
| 66 | { |
| 67 | CpjsuaContainerView* self = CpjsuaContainerView::NewLC(); |
| 68 | CleanupStack::Pop( self ); |
| 69 | return self; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Symbian two-phase constructor. |
| 74 | * This creates an instance, pushes it on the cleanup stack, |
| 75 | * then calls the second-phase constructor. |
| 76 | * @return new instance of CpjsuaContainerView |
| 77 | */ |
| 78 | CpjsuaContainerView* CpjsuaContainerView::NewLC() |
| 79 | { |
| 80 | CpjsuaContainerView* self = new ( ELeave ) CpjsuaContainerView(); |
| 81 | CleanupStack::PushL( self ); |
| 82 | self->ConstructL(); |
| 83 | return self; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | /** |
| 88 | * Second-phase constructor for view. |
| 89 | * Initialize contents from resource. |
| 90 | */ |
| 91 | void CpjsuaContainerView::ConstructL() |
| 92 | { |
| 93 | // [[[ begin generated region: do not modify [Generated Code] |
| 94 | BaseConstructL( R_PJSUA_CONTAINER_PJSUA_CONTAINER_VIEW ); |
| 95 | |
| 96 | // ]]] end generated region [Generated Code] |
| 97 | |
| 98 | // add your own initialization code here |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @return The UID for this view |
| 103 | */ |
| 104 | TUid CpjsuaContainerView::Id() const |
| 105 | { |
| 106 | return TUid::Uid( EPjsuaContainerViewId ); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Handle a command for this view (override) |
| 111 | * @param aCommand command id to be handled |
| 112 | */ |
| 113 | void CpjsuaContainerView::HandleCommandL( TInt aCommand ) |
| 114 | { |
| 115 | // [[[ begin generated region: do not modify [Generated Code] |
| 116 | TBool commandHandled = EFalse; |
| 117 | switch ( aCommand ) |
| 118 | { // code to dispatch to the AknView's menu and CBA commands is generated here |
| 119 | default: |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | if ( !commandHandled ) |
| 125 | { |
| 126 | |
| 127 | if ( aCommand == EAknSoftkeyBack ) |
| 128 | { |
| 129 | AppUi()->HandleCommandL( EEikCmdExit ); |
| 130 | } |
| 131 | |
| 132 | } |
| 133 | // ]]] end generated region [Generated Code] |
| 134 | |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Handles user actions during activation of the view, |
| 139 | * such as initializing the content. |
| 140 | */ |
| 141 | void CpjsuaContainerView::DoActivateL( |
| 142 | const TVwsViewId& /*aPrevViewId*/, |
| 143 | TUid /*aCustomMessageId*/, |
| 144 | const TDesC8& /*aCustomMessage*/ ) |
| 145 | { |
| 146 | // [[[ begin generated region: do not modify [Generated Contents] |
| 147 | SetupStatusPaneL(); |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | if ( iPjsuaContainer == NULL ) |
| 153 | { |
| 154 | iPjsuaContainer = CreateContainerL(); |
| 155 | iPjsuaContainer->SetMopParent( this ); |
| 156 | AppUi()->AddToStackL( *this, iPjsuaContainer ); |
| 157 | } |
| 158 | // ]]] end generated region [Generated Contents] |
| 159 | |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | */ |
| 164 | void CpjsuaContainerView::DoDeactivate() |
| 165 | { |
| 166 | // [[[ begin generated region: do not modify [Generated Contents] |
| 167 | CleanupStatusPane(); |
| 168 | |
| 169 | if ( iPjsuaContainer != NULL ) |
| 170 | { |
| 171 | AppUi()->RemoveFromViewStack( *this, iPjsuaContainer ); |
| 172 | delete iPjsuaContainer; |
| 173 | iPjsuaContainer = NULL; |
| 174 | } |
| 175 | // ]]] end generated region [Generated Contents] |
| 176 | |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Handle status pane size change for this view (override) |
| 181 | */ |
| 182 | void CpjsuaContainerView::HandleStatusPaneSizeChange() |
| 183 | { |
| 184 | CAknView::HandleStatusPaneSizeChange(); |
| 185 | |
| 186 | // this may fail, but we're not able to propagate exceptions here |
| 187 | TVwsViewId view; |
| 188 | AppUi()->GetActiveViewId( view ); |
| 189 | if ( view.iViewUid == Id() ) |
| 190 | { |
| 191 | TInt result; |
| 192 | TRAP( result, SetupStatusPaneL() ); |
| 193 | } |
| 194 | |
| 195 | // Hide menu |
| 196 | Cba()->MakeVisible(EFalse); |
| 197 | |
| 198 | //PutMessage("HandleStatusPaneSizeChange()"); |
| 199 | |
| 200 | // [[[ begin generated region: do not modify [Generated Code] |
| 201 | // ]]] end generated region [Generated Code] |
| 202 | |
| 203 | } |
| 204 | |
| 205 | // [[[ begin generated function: do not modify |
| 206 | void CpjsuaContainerView::SetupStatusPaneL() |
| 207 | { |
| 208 | // reset the context pane |
| 209 | TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); |
| 210 | CEikStatusPaneBase::TPaneCapabilities subPaneContext = |
| 211 | StatusPane()->PaneCapabilities( contextPaneUid ); |
| 212 | if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) |
| 213 | { |
| 214 | CAknContextPane* context = static_cast< CAknContextPane* > ( |
| 215 | StatusPane()->ControlL( contextPaneUid ) ); |
| 216 | context->SetPictureToDefaultL(); |
| 217 | } |
| 218 | |
| 219 | // setup the title pane |
| 220 | TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); |
| 221 | CEikStatusPaneBase::TPaneCapabilities subPaneTitle = |
| 222 | StatusPane()->PaneCapabilities( titlePaneUid ); |
| 223 | if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) |
| 224 | { |
| 225 | CAknTitlePane* title = static_cast< CAknTitlePane* >( |
| 226 | StatusPane()->ControlL( titlePaneUid ) ); |
| 227 | TResourceReader reader; |
| 228 | iEikonEnv->CreateResourceReaderLC( reader, R_PJSUA_CONTAINER_TITLE_RESOURCE ); |
| 229 | title->SetFromResourceL( reader ); |
| 230 | CleanupStack::PopAndDestroy(); // reader internal state |
| 231 | } |
| 232 | |
| 233 | } |
| 234 | |
| 235 | // ]]] end generated function |
| 236 | |
| 237 | // [[[ begin generated function: do not modify |
| 238 | void CpjsuaContainerView::CleanupStatusPane() |
| 239 | { |
| 240 | } |
| 241 | |
| 242 | // ]]] end generated function |
| 243 | |
| 244 | /** |
| 245 | * Creates the top-level container for the view. You may modify this method's |
| 246 | * contents and the CPjsuaContainer::NewL() signature as needed to initialize the |
| 247 | * container, but the signature for this method is fixed. |
| 248 | * @return new initialized instance of CPjsuaContainer |
| 249 | */ |
| 250 | CPjsuaContainer* CpjsuaContainerView::CreateContainerL() |
| 251 | { |
| 252 | return CPjsuaContainer::NewL( ClientRect(), NULL, this ); |
| 253 | } |
| 254 | |
| 255 | void CpjsuaContainerView::PutMessage( const char *msg ) |
| 256 | { |
| 257 | if (!iPjsuaContainer) |
| 258 | return; |
| 259 | |
| 260 | TRAPD(result, iPjsuaContainer->PutMessageL(msg)); |
| 261 | } |