~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiContainerView.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: symbian_ua_guiContainerView.cpp 3550 2011-05-05 05:33:27Z nanang $ */
2
 
/*
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 */
19
 
// [[[ begin generated region: do not modify [Generated System Includes]
20
 
#include <aknviewappui.h>
21
 
#include <eikmenub.h>
22
 
#include <avkon.hrh>
23
 
#include <barsread.h>
24
 
#include <stringloader.h>
25
 
#include <eiklabel.h>
26
 
#include <eikenv.h>
27
 
#include <gdi.h>
28
 
#include <eikedwin.h>
29
 
#include <akncontext.h>
30
 
#include <akntitle.h>
31
 
#include <eikbtgpc.h>
32
 
#include <aknnotewrappers.h>
33
 
#include <aknquerydialog.h>
34
 
#include <symbian_ua_gui.rsg>
35
 
// ]]] end generated region [Generated System Includes]
36
 
 
37
 
// [[[ begin generated region: do not modify [Generated User Includes]
38
 
#include "symbian_ua_gui.hrh"
39
 
#include "symbian_ua_guiContainerView.h"
40
 
#include "symbian_ua_guiContainer.hrh"
41
 
#include "symbian_ua_guiSettingItemList.hrh"
42
 
#include "symbian_ua_guiContainer.h"
43
 
// ]]] end generated region [Generated User Includes]
44
 
 
45
 
#include <utf.h>
46
 
#include "symbian_ua.h"
47
 
 
48
 
// [[[ begin generated region: do not modify [Generated Constants]
49
 
// ]]] end generated region [Generated Constants]
50
 
 
51
 
Csymbian_ua_guiContainerView *myinstance = NULL;
52
 
_LIT(KStCall, "Call");
53
 
_LIT(KStHangUp, "Hang Up");
54
 
 
55
 
void on_info(const wchar_t* buf)
56
 
{
57
 
        TPtrC aBuf((const TUint16*)buf);
58
 
 
59
 
        if (myinstance)
60
 
                myinstance->PutMessage(aBuf);
61
 
}
62
 
 
63
 
void on_incoming_call(const wchar_t* caller_disp, const wchar_t* caller_uri)
64
 
{
65
 
        TBuf<512> buf;
66
 
        TPtrC aDisp((const TUint16*)caller_disp);
67
 
        TPtrC aUri((const TUint16*)caller_uri);
68
 
        _LIT(KFormat, "Incoming call from %S, accept?");
69
 
 
70
 
        buf.Format(KFormat, &aDisp);
71
 
        if (Csymbian_ua_guiContainerView::RunQry_accept_callL(&buf) == EAknSoftkeyYes)
72
 
        {
73
 
                CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
74
 
                if (cba != NULL) {
75
 
                        TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp));
76
 
                        cba->DrawDeferred();
77
 
                }
78
 
                symbian_ua_answercall();
79
 
        } else {
80
 
                symbian_ua_endcall();
81
 
        }
82
 
}
83
 
 
84
 
void on_call_end(const wchar_t* reason)
85
 
{
86
 
        TPtrC aReason((const TUint16*)reason);
87
 
 
88
 
        CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
89
 
        if (cba != NULL) {
90
 
                TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall));
91
 
                cba->DrawDeferred();
92
 
        }
93
 
 
94
 
        Csymbian_ua_guiContainerView::RunNote_infoL(&aReason);
95
 
}
96
 
 
97
 
void on_reg_state(bool success)
98
 
{
99
 
        if (success)
100
 
                Csymbian_ua_guiContainerView::RunNote_infoL();
101
 
        else
102
 
                Csymbian_ua_guiContainerView::RunNote_warningL();
103
 
}
104
 
 
105
 
void on_unreg_state(bool success)
106
 
{
107
 
        TPtrC st_success(_L("Unregistration Success!"));
108
 
        TPtrC st_failed(_L("Unregistration Failed!"));
109
 
 
110
 
        if (success)
111
 
                Csymbian_ua_guiContainerView::RunNote_infoL(&st_success);
112
 
        else
113
 
                Csymbian_ua_guiContainerView::RunNote_warningL(&st_failed);
114
 
}
115
 
 
116
 
void Csymbian_ua_guiContainerView::PutMessage(const TDesC &msg)
117
 
        {
118
 
        if (!iSymbian_ua_guiContainer)
119
 
                return;
120
 
 
121
 
        CEikEdwin *obj_info = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_info);
122
 
 
123
 
        obj_info->SetTextL(&msg);
124
 
        obj_info->DrawDeferred();
125
 
        }
126
 
 
127
 
/**
128
 
 * First phase of Symbian two-phase construction. Should not contain any
129
 
 * code that could leave.
130
 
 */
131
 
Csymbian_ua_guiContainerView::Csymbian_ua_guiContainerView()
132
 
        {
133
 
        // [[[ begin generated region: do not modify [Generated Contents]
134
 
        iSymbian_ua_guiContainer = NULL;
135
 
        // ]]] end generated region [Generated Contents]
136
 
 
137
 
        }
138
 
/**
139
 
 * The view's destructor removes the container from the control
140
 
 * stack and destroys it.
141
 
 */
142
 
Csymbian_ua_guiContainerView::~Csymbian_ua_guiContainerView()
143
 
        {
144
 
        // [[[ begin generated region: do not modify [Generated Contents]
145
 
        delete iSymbian_ua_guiContainer;
146
 
        iSymbian_ua_guiContainer = NULL;
147
 
        // ]]] end generated region [Generated Contents]
148
 
 
149
 
        symbian_ua_set_info_callback(NULL);
150
 
        myinstance = NULL;
151
 
        }
152
 
 
153
 
/**
154
 
 * Symbian two-phase constructor.
155
 
 * This creates an instance then calls the second-phase constructor
156
 
 * without leaving the instance on the cleanup stack.
157
 
 * @return new instance of Csymbian_ua_guiContainerView
158
 
 */
159
 
Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewL()
160
 
        {
161
 
        Csymbian_ua_guiContainerView* self = Csymbian_ua_guiContainerView::NewLC();
162
 
        CleanupStack::Pop( self );
163
 
        return self;
164
 
        }
165
 
 
166
 
/**
167
 
 * Symbian two-phase constructor.
168
 
 * This creates an instance, pushes it on the cleanup stack,
169
 
 * then calls the second-phase constructor.
170
 
 * @return new instance of Csymbian_ua_guiContainerView
171
 
 */
172
 
Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewLC()
173
 
        {
174
 
        Csymbian_ua_guiContainerView* self = new ( ELeave ) Csymbian_ua_guiContainerView();
175
 
        CleanupStack::PushL( self );
176
 
        self->ConstructL();
177
 
        return self;
178
 
        }
179
 
 
180
 
 
181
 
/**
182
 
 * Second-phase constructor for view.
183
 
 * Initialize contents from resource.
184
 
 */
185
 
void Csymbian_ua_guiContainerView::ConstructL()
186
 
        {
187
 
        // [[[ begin generated region: do not modify [Generated Code]
188
 
        BaseConstructL( R_SYMBIAN_UA_GUI_CONTAINER_SYMBIAN_UA_GUI_CONTAINER_VIEW );
189
 
        // ]]] end generated region [Generated Code]
190
 
 
191
 
        // add your own initialization code here
192
 
        symbian_ua_info_cb_t cb;
193
 
        Mem::FillZ(&cb, sizeof(cb));
194
 
 
195
 
        cb.on_info = &on_info;
196
 
        cb.on_incoming_call = &on_incoming_call;
197
 
        cb.on_reg_state = &on_reg_state;
198
 
        cb.on_unreg_state = &on_unreg_state;
199
 
        cb.on_call_end = &on_call_end;
200
 
 
201
 
        symbian_ua_set_info_callback(&cb);
202
 
        myinstance = this;
203
 
        }
204
 
 
205
 
/**
206
 
 * @return The UID for this view
207
 
 */
208
 
TUid Csymbian_ua_guiContainerView::Id() const
209
 
        {
210
 
        return TUid::Uid( ESymbian_ua_guiContainerViewId );
211
 
        }
212
 
 
213
 
/**
214
 
 * Handle a command for this view (override)
215
 
 * @param aCommand command id to be handled
216
 
 */
217
 
void Csymbian_ua_guiContainerView::HandleCommandL( TInt aCommand )
218
 
        {
219
 
        // [[[ begin generated region: do not modify [Generated Code]
220
 
        TBool commandHandled = EFalse;
221
 
        switch ( aCommand )
222
 
                {       // code to dispatch to the AknView's menu and CBA commands is generated here
223
 
 
224
 
                case ESymbian_ua_guiContainerViewControlPaneRightId:
225
 
                        commandHandled = CallSoftKeyPressedL( aCommand );
226
 
                        break;
227
 
                case ESymbian_ua_guiContainerViewSettingMenuItemCommand:
228
 
                        commandHandled = HandleSettingMenuItemSelectedL( aCommand );
229
 
                        break;
230
 
                default:
231
 
                        break;
232
 
                }
233
 
 
234
 
 
235
 
        if ( !commandHandled )
236
 
                {
237
 
 
238
 
                if ( aCommand == ESymbian_ua_guiContainerViewControlPaneRightId )
239
 
                        {
240
 
                        AppUi()->HandleCommandL( EEikCmdExit );
241
 
                        }
242
 
 
243
 
                }
244
 
        // ]]] end generated region [Generated Code]
245
 
 
246
 
        }
247
 
 
248
 
/**
249
 
 *      Handles user actions during activation of the view,
250
 
 *      such as initializing the content.
251
 
 */
252
 
void Csymbian_ua_guiContainerView::DoActivateL(
253
 
                const TVwsViewId& /*aPrevViewId*/,
254
 
                TUid /*aCustomMessageId*/,
255
 
                const TDesC8& /*aCustomMessage*/ )
256
 
        {
257
 
        // [[[ begin generated region: do not modify [Generated Contents]
258
 
        SetupStatusPaneL();
259
 
 
260
 
        CEikButtonGroupContainer* cba = AppUi()->Cba();
261
 
        if ( cba != NULL )
262
 
                {
263
 
                cba->MakeVisible( EFalse );
264
 
                }
265
 
 
266
 
        if ( iSymbian_ua_guiContainer == NULL )
267
 
                {
268
 
                iSymbian_ua_guiContainer = CSymbian_ua_guiContainer::NewL( ClientRect(), NULL, this );
269
 
                iSymbian_ua_guiContainer->SetMopParent( this );
270
 
                AppUi()->AddToStackL( *this, iSymbian_ua_guiContainer );
271
 
                }
272
 
        // ]]] end generated region [Generated Contents]
273
 
 
274
 
        cba = CEikButtonGroupContainer::Current();
275
 
        if (cba != NULL) {
276
 
                if (symbian_ua_anycall())
277
 
                        cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp);
278
 
                else
279
 
                        cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall);
280
 
        }
281
 
 
282
 
        }
283
 
 
284
 
/**
285
 
 */
286
 
void Csymbian_ua_guiContainerView::DoDeactivate()
287
 
        {
288
 
        // [[[ begin generated region: do not modify [Generated Contents]
289
 
        CleanupStatusPane();
290
 
 
291
 
        CEikButtonGroupContainer* cba = AppUi()->Cba();
292
 
        if ( cba != NULL )
293
 
                {
294
 
                cba->MakeVisible( ETrue );
295
 
                cba->DrawDeferred();
296
 
                }
297
 
 
298
 
        if ( iSymbian_ua_guiContainer != NULL )
299
 
                {
300
 
                AppUi()->RemoveFromViewStack( *this, iSymbian_ua_guiContainer );
301
 
                delete iSymbian_ua_guiContainer;
302
 
                iSymbian_ua_guiContainer = NULL;
303
 
                }
304
 
        // ]]] end generated region [Generated Contents]
305
 
 
306
 
        }
307
 
 
308
 
// [[[ begin generated function: do not modify
309
 
void Csymbian_ua_guiContainerView::SetupStatusPaneL()
310
 
        {
311
 
        // reset the context pane
312
 
        TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
313
 
        CEikStatusPaneBase::TPaneCapabilities subPaneContext =
314
 
                StatusPane()->PaneCapabilities( contextPaneUid );
315
 
        if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
316
 
                {
317
 
                CAknContextPane* context = static_cast< CAknContextPane* > (
318
 
                        StatusPane()->ControlL( contextPaneUid ) );
319
 
                context->SetPictureToDefaultL();
320
 
                }
321
 
 
322
 
        // setup the title pane
323
 
        TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
324
 
        CEikStatusPaneBase::TPaneCapabilities subPaneTitle =
325
 
                StatusPane()->PaneCapabilities( titlePaneUid );
326
 
        if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
327
 
                {
328
 
                CAknTitlePane* title = static_cast< CAknTitlePane* >(
329
 
                        StatusPane()->ControlL( titlePaneUid ) );
330
 
                TResourceReader reader;
331
 
                iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_TITLE_RESOURCE );
332
 
                title->SetFromResourceL( reader );
333
 
                CleanupStack::PopAndDestroy(); // reader internal state
334
 
                }
335
 
 
336
 
        }
337
 
// ]]] end generated function
338
 
 
339
 
// [[[ begin generated function: do not modify
340
 
void Csymbian_ua_guiContainerView::CleanupStatusPane()
341
 
        {
342
 
        }
343
 
// ]]] end generated function
344
 
 
345
 
/**
346
 
 * Handle status pane size change for this view (override)
347
 
 */
348
 
void Csymbian_ua_guiContainerView::HandleStatusPaneSizeChange()
349
 
        {
350
 
        CAknView::HandleStatusPaneSizeChange();
351
 
 
352
 
        // this may fail, but we're not able to propagate exceptions here
353
 
        TInt result;
354
 
        TRAP( result, SetupStatusPaneL() );
355
 
        }
356
 
 
357
 
/**
358
 
 * Handle the rightSoftKeyPressed event.
359
 
 * @return ETrue if the command was handled, EFalse if not
360
 
 */
361
 
TBool Csymbian_ua_guiContainerView::CallSoftKeyPressedL( TInt aCommand )
362
 
        {
363
 
        CEikEdwin *obj_url = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_url);
364
 
        CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
365
 
 
366
 
        if (symbian_ua_anycall()) {
367
 
                symbian_ua_endcall();
368
 
                return ETrue;
369
 
        }
370
 
 
371
 
        PutMessage(_L("Making call..."));
372
 
        if ( cba != NULL ) {
373
 
                cba->SetCommandL(aCommand, KStHangUp);
374
 
                cba->DrawDeferred();
375
 
        }
376
 
 
377
 
 
378
 
        TUint8 url[256];
379
 
        TPtr8 aUrl(url, 256);
380
 
 
381
 
        HBufC *buf = obj_url->GetTextInHBufL();
382
 
        CnvUtfConverter::ConvertFromUnicodeToUtf8(aUrl, *buf);
383
 
        delete buf;
384
 
 
385
 
        if (symbian_ua_makecall((char *)aUrl.PtrZ()) != 0) {
386
 
                PutMessage(_L("Making call failed!"));
387
 
                if ( cba != NULL ) {
388
 
                        cba->SetCommandL(aCommand, KStCall);
389
 
                        cba->DrawDeferred();
390
 
                }
391
 
        }
392
 
 
393
 
        return ETrue;
394
 
        }
395
 
 
396
 
/**
397
 
 * Handle the selected event.
398
 
 * @param aCommand the command id invoked
399
 
 * @return ETrue if the command was handled, EFalse if not
400
 
 */
401
 
TBool Csymbian_ua_guiContainerView::HandleSettingMenuItemSelectedL( TInt aCommand )
402
 
        {
403
 
        AppUi()->ActivateLocalViewL(TUid::Uid(ESymbian_ua_guiSettingItemListViewId));
404
 
        return ETrue;
405
 
        }
406
 
 
407
 
// [[[ begin generated function: do not modify
408
 
/**
409
 
 * Show the popup note for note_error
410
 
 * @param aOverrideText optional override text
411
 
 */
412
 
void Csymbian_ua_guiContainerView::RunNote_errorL( const TDesC* aOverrideText )
413
 
        {
414
 
        CAknErrorNote* note = new ( ELeave ) CAknErrorNote();
415
 
        if ( aOverrideText == NULL )
416
 
                {
417
 
                HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_ERROR );
418
 
                note->ExecuteLD( *noteText );
419
 
                CleanupStack::PopAndDestroy( noteText );
420
 
                }
421
 
        else
422
 
                {
423
 
                note->ExecuteLD( *aOverrideText );
424
 
                }
425
 
        }
426
 
// ]]] end generated function
427
 
 
428
 
// [[[ begin generated function: do not modify
429
 
/**
430
 
 * Show the popup note for note_info
431
 
 * @param aOverrideText optional override text
432
 
 */
433
 
void Csymbian_ua_guiContainerView::RunNote_infoL( const TDesC* aOverrideText )
434
 
        {
435
 
        CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
436
 
        if ( aOverrideText == NULL )
437
 
                {
438
 
                HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_INFO );
439
 
                note->ExecuteLD( *noteText );
440
 
                CleanupStack::PopAndDestroy( noteText );
441
 
                }
442
 
        else
443
 
                {
444
 
                note->ExecuteLD( *aOverrideText );
445
 
                }
446
 
        }
447
 
// ]]] end generated function
448
 
 
449
 
// [[[ begin generated function: do not modify
450
 
/**
451
 
 * Show the popup note for note_warning
452
 
 * @param aOverrideText optional override text
453
 
 */
454
 
void Csymbian_ua_guiContainerView::RunNote_warningL( const TDesC* aOverrideText )
455
 
        {
456
 
        CAknWarningNote* note = new ( ELeave ) CAknWarningNote();
457
 
        if ( aOverrideText == NULL )
458
 
                {
459
 
                HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_WARNING );
460
 
                note->ExecuteLD( *noteText );
461
 
                CleanupStack::PopAndDestroy( noteText );
462
 
                }
463
 
        else
464
 
                {
465
 
                note->ExecuteLD( *aOverrideText );
466
 
                }
467
 
        }
468
 
// ]]] end generated function
469
 
 
470
 
// [[[ begin generated function: do not modify
471
 
/**
472
 
 * Show the popup dialog for qry_accept_call
473
 
 * @param aOverrideText optional override text
474
 
 * @return EAknSoftkeyYes (left soft key id) or 0
475
 
 */
476
 
TInt Csymbian_ua_guiContainerView::RunQry_accept_callL( const TDesC* aOverrideText )
477
 
        {
478
 
 
479
 
        CAknQueryDialog* queryDialog = CAknQueryDialog::NewL();
480
 
 
481
 
        if ( aOverrideText != NULL )
482
 
                {
483
 
                queryDialog->SetPromptL( *aOverrideText );
484
 
                }
485
 
        return queryDialog->ExecuteLD( R_SYMBIAN_UA_GUI_CONTAINER_QRY_ACCEPT_CALL );
486
 
        }
487
 
// ]]] end generated function