|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: Juha Kauppinen, Mika Hokkanen |
|
13 * |
|
14 * Description: Photo Browser |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "SendImageFile.h" |
|
19 |
|
20 #include <sendui.h> |
|
21 #include <eikenv.h> |
|
22 |
|
23 #ifdef SEND_FILE_DIALOGUE |
|
24 #include <BTObjectExchange.rsg> |
|
25 #endif |
|
26 |
|
27 #include <caknfileselectiondialog.h> |
|
28 #include <caknmemoryselectiondialog.h> |
|
29 |
|
30 #include <cmessagedata.h> |
|
31 |
|
32 |
|
33 CSendImageFile::CSendImageFile() { |
|
34 |
|
35 } |
|
36 |
|
37 CSendImageFile* CSendImageFile::NewL() { |
|
38 CSendImageFile* self = new ( ELeave ) CSendImageFile(); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 void CSendImageFile::ConstructL() { |
|
46 |
|
47 iSendUi = CSendUi::NewL(); |
|
48 |
|
49 } |
|
50 |
|
51 CSendImageFile::~CSendImageFile() { |
|
52 if(iSendUi) { |
|
53 delete iSendUi; |
|
54 } |
|
55 } |
|
56 |
|
57 #ifdef SEND_FILE_DIALOGUE |
|
58 TBool CSendImageFile::AskFileL(TFileName& aFileName) |
|
59 { |
|
60 |
|
61 // Select memory |
|
62 CAknMemorySelectionDialog* memSelectionDialog = |
|
63 CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, EFalse); |
|
64 CleanupStack::PushL(memSelectionDialog); |
|
65 CAknMemorySelectionDialog::TMemory mem(CAknMemorySelectionDialog::EPhoneMemory); |
|
66 |
|
67 TInt ret = memSelectionDialog->ExecuteL(mem); |
|
68 CleanupStack::PopAndDestroy(memSelectionDialog); |
|
69 if (!ret) |
|
70 { |
|
71 return EFalse; |
|
72 } |
|
73 //Select file from the chosen memory |
|
74 CAknFileSelectionDialog* fileSelectionDialog = NULL; |
|
75 if (mem == CAknMemorySelectionDialog::EMemoryCard) |
|
76 { |
|
77 fileSelectionDialog = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal,R_FILE_SELECTION_DIALOG_E ); |
|
78 } |
|
79 else |
|
80 { |
|
81 fileSelectionDialog= CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal,R_FILE_SELECTION_DIALOG_C ); |
|
82 } |
|
83 |
|
84 TBool result = fileSelectionDialog->ExecuteL(aFileName); |
|
85 delete fileSelectionDialog; |
|
86 return result; |
|
87 |
|
88 } |
|
89 |
|
90 void CSendImageFile::SendFileViaSendUiL() |
|
91 { |
|
92 |
|
93 TFileName path; |
|
94 |
|
95 AskFileL(path); |
|
96 SendFileViaSendUiL(path); |
|
97 |
|
98 } |
|
99 #endif |
|
100 |
|
101 void CSendImageFile::SendFileViaSendUiL(TFileName path) |
|
102 { |
|
103 |
|
104 TSendingCapabilities capabs( 0, 1024, TSendingCapabilities::ESupportsAttachments ); |
|
105 |
|
106 RFs fs; |
|
107 CleanupClosePushL(fs); |
|
108 User::LeaveIfError( fs.Connect() ); |
|
109 fs.ShareProtected(); |
|
110 |
|
111 RFile temp; |
|
112 User::LeaveIfError( temp.Open( fs, path, EFileShareReadersOnly | EFileRead ) ); |
|
113 CleanupClosePushL(temp); |
|
114 |
|
115 CMessageData* messageData = CMessageData::NewL(); |
|
116 CleanupStack::PushL(messageData); |
|
117 messageData->AppendAttachmentHandleL(temp); |
|
118 |
|
119 TRAPD(err, iSendUi->ShowQueryAndSendL(messageData, capabs) ); |
|
120 |
|
121 CleanupStack::PopAndDestroy(messageData); |
|
122 |
|
123 CleanupStack::PopAndDestroy(&temp); |
|
124 CleanupStack::PopAndDestroy(&fs); |
|
125 |
|
126 } |