|
1 /* |
|
2 * CDlStylusPopupMenu.cpp |
|
3 * |
|
4 * Created on: Dec 24, 2009 |
|
5 * Author: hari and billa |
|
6 */ |
|
7 |
|
8 #include "CDownloadsStylusPopupMenu.h" |
|
9 #include "CDownloadsListDlg.h" |
|
10 #include "DownloadMgrUiLib.rsg" |
|
11 #include "CDownloadsListArray.h" |
|
12 #include "DownloadMgrUilib.hrh" |
|
13 |
|
14 |
|
15 // ----------------------------------------------------------------------------- |
|
16 // BrowserStylusPopupMenu::ConstructL() |
|
17 // Symbian 2nd phase constructor can leave. |
|
18 // ----------------------------------------------------------------------------- |
|
19 // |
|
20 CDlStylusPopupMenu* CDlStylusPopupMenu::NewL() |
|
21 { |
|
22 CDlStylusPopupMenu* container = |
|
23 new (ELeave) CDlStylusPopupMenu; |
|
24 container->ConstructL(); |
|
25 return container; |
|
26 } |
|
27 |
|
28 void CDlStylusPopupMenu::ConstructL() |
|
29 { |
|
30 ilongtapRunning = EFalse; |
|
31 iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // BrowserStylusPopupMenu::HandlePointerEventL() |
|
36 // Called by framework to handle pointer touch events. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CDlStylusPopupMenu::HandlePointerEventL(const TPointerEvent& aPointerEvent, CDownloadsListDlg *view) |
|
40 { |
|
41 ilongtapRunning = EFalse; |
|
42 iLongTapDetector->SetLongTapDelay(KLONG_TAP_TIMER_DELAY); |
|
43 iLongTapDetector->PointerEventL(aPointerEvent); |
|
44 iLongTapDetector->EnableLongTapAnimation(ETrue); |
|
45 iDlView = view; |
|
46 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
47 } |
|
48 |
|
49 void CDlStylusPopupMenu::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ) |
|
50 { |
|
51 ilongtapRunning = ETrue; |
|
52 TBool isAiwcall = EFalse; |
|
53 if (iStylusPopupMenu) |
|
54 { |
|
55 delete iStylusPopupMenu; |
|
56 iStylusPopupMenu = NULL; |
|
57 iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , aPenEventScreenLocation); |
|
58 } |
|
59 else |
|
60 { |
|
61 iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , aPenEventScreenLocation); |
|
62 } |
|
63 |
|
64 iStylusPopupMenu->SetPosition(aPenEventScreenLocation, CAknStylusPopUpMenu::EPositionTypeLeftBottom); |
|
65 |
|
66 TResourceReader reader; |
|
67 iCoeEnv->CreateResourceReaderLC(reader,R_STYLUS_LONG_TAP_POPUP_DL_MENU); |
|
68 iStylusPopupMenu->ConstructFromResourceL(reader); |
|
69 TInt currentItemIndex = iDlView->CurrentItemIndex(); |
|
70 CDownloadsListArray* DownloadsListArray = iDlView->DownloadsListArray(); |
|
71 RHttpDownload& currDownload = DownloadsListArray->Download( currentItemIndex ); |
|
72 |
|
73 // Get the UI data for the current download |
|
74 TDownloadUiData& dlData = DownloadsListArray->DlUiData( iDlView->CurrentItemIndex() ); |
|
75 TInt32 state( dlData.iDownloadState ); |
|
76 HBufC8* contentType = HBufC8::NewLC(KMaxContentTypeLength); |
|
77 TPtr8 contentTypePtr = contentType->Des(); |
|
78 User::LeaveIfError |
|
79 ( currDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) ); |
|
80 TInt typeAudio = !contentType->Find(KAudio); |
|
81 CleanupStack::PopAndDestroy( contentType ); |
|
82 |
|
83 if (state == EHttpDlInprogress) |
|
84 { |
|
85 isAiwcall = ETrue; |
|
86 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
87 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
88 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdDelete,ETrue); |
|
89 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdFileManager,ETrue); |
|
90 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdResume,ETrue); |
|
91 } |
|
92 |
|
93 if ((state == EHttpDlCompleted) || (state ==EHttpDlMultipleMOCompleted)) |
|
94 { |
|
95 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdCancel,ETrue); |
|
96 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdResume,ETrue); |
|
97 } |
|
98 if (state == EHttpDlPaused || state == EHttpDlMultipleMOFailed) |
|
99 { |
|
100 isAiwcall = ETrue; |
|
101 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
102 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
103 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdDelete,ETrue); |
|
104 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdFileManager,ETrue); |
|
105 } |
|
106 |
|
107 if(typeAudio != 1 || (typeAudio == 1 && dlData.iNumMediaObjects > 1)) //Not an audio type or multiple audio type objects. |
|
108 { |
|
109 isAiwcall = ETrue; |
|
110 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
111 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
112 } |
|
113 |
|
114 CleanupStack::PopAndDestroy(); |
|
115 if (!isAiwcall) |
|
116 iDlView->AddAiwItemsL(); |
|
117 iStylusPopupMenu->ShowMenu(); |
|
118 } |
|
119 |
|
120 void CDlStylusPopupMenu::ProcessCommandL(TInt aCommand) |
|
121 { |
|
122 iDlView->ProcessCommandL(aCommand); |
|
123 } |
|
124 |
|
125 CDlStylusPopupMenu::~CDlStylusPopupMenu() |
|
126 { |
|
127 if(iLongTapDetector) |
|
128 { |
|
129 delete iLongTapDetector; |
|
130 iLongTapDetector = NULL; |
|
131 } |
|
132 if(iStylusPopupMenu) |
|
133 { |
|
134 delete iStylusPopupMenu; |
|
135 iStylusPopupMenu = NULL; |
|
136 } |
|
137 } |
|
138 |
|
139 void CDlStylusPopupMenu::cancelLongTapL() |
|
140 { |
|
141 iLongTapDetector->CancelAnimationL(); |
|
142 } |
|
143 |
|
144 TBool CDlStylusPopupMenu::islongtapRunning() |
|
145 { |
|
146 return ilongtapRunning; |
|
147 } |
|
148 |
|
149 void CDlStylusPopupMenu::reSetLongTapFlag() |
|
150 { |
|
151 ilongtapRunning = EFalse; |
|
152 } |
|
153 |