|
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 TResourceReader readerFolder; |
|
33 TResourceReader readerItem; |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // BrowserStylusPopupMenu::HandlePointerEventL() |
|
38 // Called by framework to handle pointer touch events. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CDlStylusPopupMenu::HandlePointerEventL(const TPointerEvent& aPointerEvent, CDownloadsListDlg *view) |
|
42 { |
|
43 ilongtapRunning = EFalse; |
|
44 iLongTapDetector->SetLongTapDelay(KLONG_TAP_TIMER_DELAY); |
|
45 iLongTapDetector->PointerEventL(aPointerEvent); |
|
46 iLongTapDetector->EnableLongTapAnimation(ETrue); |
|
47 iDlView = view; |
|
48 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
49 } |
|
50 |
|
51 void CDlStylusPopupMenu::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ) |
|
52 { |
|
53 ilongtapRunning = ETrue; |
|
54 TBool isAiwcall = EFalse; |
|
55 if (iStylusPopupMenu) |
|
56 { |
|
57 delete iStylusPopupMenu; |
|
58 iStylusPopupMenu = NULL; |
|
59 iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , aPenEventScreenLocation); |
|
60 } |
|
61 else |
|
62 { |
|
63 iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , aPenEventScreenLocation); |
|
64 } |
|
65 |
|
66 iStylusPopupMenu->SetPosition(aPenEventScreenLocation, CAknStylusPopUpMenu::EPositionTypeLeftBottom); |
|
67 |
|
68 TResourceReader reader; |
|
69 iCoeEnv->CreateResourceReaderLC(reader,R_STYLUS_LONG_TAP_POPUP_DL_MENU); |
|
70 iStylusPopupMenu->ConstructFromResourceL(reader); |
|
71 TInt currentItemIndex = iDlView->CurrentItemIndex(); |
|
72 CDownloadsListArray* DownloadsListArray = iDlView->DownloadsListArray(); |
|
73 RHttpDownload& currDownload = DownloadsListArray->Download( currentItemIndex ); |
|
74 |
|
75 // Get the UI data for the current download |
|
76 TDownloadUiData& dlData = DownloadsListArray->DlUiData( iDlView->CurrentItemIndex() ); |
|
77 TInt32 state( dlData.iDownloadState ); |
|
78 HBufC8* contentType = HBufC8::NewLC(KMaxContentTypeLength); |
|
79 TPtr8 contentTypePtr = contentType->Des(); |
|
80 User::LeaveIfError |
|
81 ( currDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) ); |
|
82 TInt typeAudio = !contentType->Find(KAudio); |
|
83 CleanupStack::PopAndDestroy( contentType ); |
|
84 |
|
85 if (state == EHttpDlInprogress) |
|
86 { |
|
87 isAiwcall = ETrue; |
|
88 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
89 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
90 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdDelete,ETrue); |
|
91 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdFileManager,ETrue); |
|
92 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdResume,ETrue); |
|
93 } |
|
94 |
|
95 if ((state == EHttpDlCompleted) || (state ==EHttpDlMultipleMOCompleted)) |
|
96 { |
|
97 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdCancel,ETrue); |
|
98 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdResume,ETrue); |
|
99 } |
|
100 if (state == EHttpDlPaused) |
|
101 { |
|
102 isAiwcall = ETrue; |
|
103 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
104 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
105 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdDelete,ETrue); |
|
106 iStylusPopupMenu->SetItemDimmed(EDownloadsListCmdFileManager,ETrue); |
|
107 } |
|
108 |
|
109 if(typeAudio != 1) //Not an audio type |
|
110 { |
|
111 isAiwcall = ETrue; |
|
112 iStylusPopupMenu->SetItemDimmed(EAiwCmdContact,ETrue); |
|
113 iStylusPopupMenu->SetItemDimmed(EAiwCmdRingtone,ETrue); |
|
114 } |
|
115 |
|
116 CleanupStack::PopAndDestroy(); |
|
117 if (!isAiwcall) |
|
118 iDlView->AddAiwItemsL(); |
|
119 iStylusPopupMenu->ShowMenu(); |
|
120 } |
|
121 |
|
122 void CDlStylusPopupMenu::ProcessCommandL(TInt aCommand) |
|
123 { |
|
124 iDlView->ProcessCommandL(aCommand); |
|
125 } |
|
126 |
|
127 CDlStylusPopupMenu::~CDlStylusPopupMenu() |
|
128 { |
|
129 if(iLongTapDetector) |
|
130 { |
|
131 delete iLongTapDetector; |
|
132 iLongTapDetector = NULL; |
|
133 } |
|
134 if(iStylusPopupMenu) |
|
135 { |
|
136 delete iStylusPopupMenu; |
|
137 iStylusPopupMenu = NULL; |
|
138 } |
|
139 } |
|
140 |
|
141 void CDlStylusPopupMenu::cancelLongTapL() |
|
142 { |
|
143 iLongTapDetector->CancelAnimationL(); |
|
144 } |
|
145 |
|
146 TBool CDlStylusPopupMenu::islongtapRunning() |
|
147 { |
|
148 return ilongtapRunning; |
|
149 } |
|
150 |
|
151 void CDlStylusPopupMenu::reSetLongTapFlag() |
|
152 { |
|
153 ilongtapRunning = EFalse; |
|
154 } |
|
155 |