00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef WALLPAPERBUSINESSLOGIC_H
00020 #define WALLPAPERBUSINESSLOGIC_H
00021
00022 #include <QList>
00023 #include <QObject>
00024 #include <QPointer>
00025 #include <QFileSystemWatcher>
00026 #include <meegocontrolexport.h>
00027
00028 class QString;
00029 class MGConfItem;
00030 class WallpaperDescriptor;
00031 class QStringList;
00032 class WallpaperITrans;
00033
00034 #include <QPointer>
00035 #include <QtConcurrentRun>
00036 #include <QFutureWatcher>
00037
00038 #include <wallpaperdescriptor.h>
00039
00040 #define WALLPAPER_DBUS_INTERFACE "com.nokia.wallpaper"
00041 #define WALLPAPER_DBUS_EDIT_SIGNAL "edit"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00069 class MC_EXPORT WallpaperBusinessLogic : public QObject
00070 {
00071 Q_OBJECT
00072
00073 public:
00074 WallpaperBusinessLogic (QObject *parent = 0);
00075 ~WallpaperBusinessLogic ();
00076
00077 QList<WallpaperDescriptor *> availableWallpapers () const;
00078
00079 void setEditedImage (WallpaperDescriptor *desc, bool ours = false);
00080 void startEdit (WallpaperDescriptor *desc = NULL);
00081
00082 WallpaperDescriptor *editedImage ();
00083
00084 void setBackground (
00085 WallpaperITrans *landscapeITrans,
00086 WallpaperITrans *portraitITrans,
00087 WallpaperDescriptor *desc = 0);
00088
00089 signals:
00090 void wallpaperChanged ();
00091 void imageEditRequested ();
00092 void fileListChanged ();
00093
00094 private slots:
00095 void editRequestArrived (
00096 QString portraitFileName,
00097 QString landscapeFileName);
00098
00099 void startEditThreadEnded ();
00100 void valueChanged ();
00101 void directoryChangedDelayed ();
00102 void directoryChanged (const QString &path);
00103 void fileChanged (const QString &path);
00104
00105 private:
00106 typedef enum {
00107 SaveDir,
00108 DownloadDir,
00109 MountDir,
00110 SystemDir
00111 } WallpaperDirectoryID;
00112
00113 QString dirPath (WallpaperDirectoryID dirID = SaveDir) const;
00114 void startWatchingFiles ();
00115 bool ensureHasDirectory ();
00116 void createBackupFiles ();
00117 void deleteBackupFiles ();
00118 void saveOriginal (
00119 WallpaperDescriptor *desc);
00120 bool writeFiles (
00121 WallpaperITrans *landscapeITrans,
00122 WallpaperITrans *portraitITrans,
00123 WallpaperDescriptor *desc);
00124
00125 void makeBackup (const QString &filePath);
00126 void makeImageFile (
00127 const QString &filePath,
00128 WallpaperDescriptor *desc,
00129 WallpaperITrans *transformations);
00130
00131 bool supportsLandscape () const;
00132 bool supportsPortrait () const;
00133
00134 private:
00135 MGConfItem *m_LandscapeGConfItem;
00136 MGConfItem *m_PortraitGConfItem;
00137 QPointer<WallpaperDescriptor> m_EditedImage;
00138 bool m_EditedImageOurs;
00139 bool m_OrientationLocked;
00140 M::Orientation m_LockedOrientation;
00141 QFutureWatcher <void> m_FutureWatcher;
00142 QPointer<QFileSystemWatcher> m_FileWatcher;
00143 #ifdef UNIT_TEST
00144 friend class Ut_WallpaperBusinessLogic;
00145 friend class Ft_WallpaperBusinessLogic;
00146 #endif
00147 };
00148
00149 #endif