1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2004-02-25
* Description : a kipi plugin to e-mailing images
*
* Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef SENDIMAGES_H
#define SENDIMAGES_H
// TQt includes.
#include <tqobject.h>
#include <tqstring.h>
#include <tqthread.h>
#include <tqstringlist.h>
// KDE includes.
#include <kurl.h>
// LibKipi includes.
#include <libkipi/imagecollection.h>
#include <libkipi/interface.h>
class TQFile;
class TQTimer;
class TQCustomEvent;
class KProcess;
namespace KIPISendimagesPlugin
{
class SendImagesDialog;
class SendImages : public TQObject, public TQThread
{
Q_OBJECT
TQ_OBJECT
public:
///Constructor: saves system handoff parameters in member variables
SendImages(KIPI::Interface* interface, const TQString &tmpFolder,
const KIPI::ImageCollection& imagesCollection, TQObject *tqparent=0);
///Destructor
~SendImages();
///Prepares the image list. This includes resizing, copying, maintaining an image's exif,
///and dropping evil characters out of filenames ;-)
virtual void run();
///Invokes the User Dialog Window
void showDialog(void);
///Gets input from the user dialog and store it into member variables
void prepare(void);
///Shows up an error dialog and the problematic images
bool showErrors(void);
/// Creates a text file with the images comments.
void makeCommentsFile(void);
/** Invokes mail agent. Depending on which mail agent to be used, we have different
proceedings. Easy for every agent except of mozilla derivates */
bool invokeMailAgent(void);
///Cleans up the temp directory
void removeTmpFiles(void);
/** Returns a list of Filenames, whose sum filesize is smaller than the quota
The returned images are deleted from the m_filesSendList*/
KURL::List divideEmails(void);
private slots:
///If Mozilla wasn't started before, now it is and so we can begin with the transmission
void slotMozillaTimeout(void);
///If mozilla, or thunderbird or any derivate isn't already running,
///start it now, wait 5 seconds and start SlotMozillaTimeout()
void slotMozillaExited(KProcess* proc);
///Handles mozillas errors
void slotMozillaReadStderr(KProcess* proc, char *buffer, int buflen);
private:
///Returns the file-extension of the corresponding fileformat
TQString extension(const TQString& imageFileFormat);
///in sendimagesplugin dialog the user can select a compression of images
///this function returns the pixel-size of the selected entry
int getSize( int choice );
///Checks if directory is empty and invokes its deletion
bool DeleteDir(TQString dirname);
///Deletes a directory and all its contents - Please call it using "DeleteDir"
bool deldir(TQString dirname);
///Resizes the Images before Sending...
bool resizeImageProcess(const TQString &SourcePath, const TQString &DestPath,
const TQString &ImageFormat, const TQString &ImageName,
int SizeFactor, int ImageCompression, TQSize &newsize);
///This function should copy the images to tempfolder in order to avoid suspicious filenames
///It is used, when no resizing should take place
bool copyImageProcess(const TQString &oldFilePath, const TQString &DestPath,
const TQString &ImageName);
///Tests if an entry already exists in the filename list
bool entry_already_exists(KURL::List filenamelist,TQString entry);
///Makes a deep copy of a KURL-list: Real and slow copying instead of only pointer arithmetics
bool kurllistdeepcopy(KURL::List &Destination, KURL::List Source);
private:
bool m_invokedBefore;
/** Change image properties options in setup dialog.*/
bool m_changeProp;
/** Image size factor in the setup dialog.*/
int m_sizeFactor;
/** Image compression factor in the setup dialog.*/
int m_imageCompression;
/** Biggest permitted email.*/
unsigned long m_attachmentlimit;
TQObject *m_parent;
TQTimer *m_mozillaTimer;
TQString m_mozillaStdErr;
TQString m_tmp;
/** Image format option in the setup dialog.*/
TQString m_imageFormat;
TQString m_thunderbirdUrl;
KProcess *m_mailAgentProc;
KProcess *m_mailAgentProc2;
KProcess *m_mailAgentProc3;
/** List of images in the setup dialog.*/
KURL::List m_images;
/** URL of resized images.*/
KURL::List m_filesSendList;
KURL::List m_filesSendList_copy;
/** URL of original images that cannot be resized.*/
KURL::List m_imagesResizedWithError;
/** URL of original images than have been resized
and KURL of resized images (used for to create
the comments file).*/
KURL::List m_imagesPackage;
KIPI::ImageCollection m_collection;
KIPI::Interface *m_interface;
SendImagesDialog *m_sendImagesDialog;
};
} // NameSpace KIPISendimagesPlugin
#endif // SENDIMAGES_H
|