• Main Page
  • Classes
  • Files
  • File List

/home/bifh8/cs2009q3-i386/work/meegotouch-controlpanelapplets-0.20.61/src/wallpaperapplet/wallpaperbusinesslogic.h

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (directui@nokia.com)
00006 **
00007 ** This file is part of meegotouch-controlpanelapplets.
00008 **
00009 ** If you have questions regarding the use of this file, please contact
00010 ** Nokia at directui@nokia.com.
00011 **
00012 ** This library is free software; you can redistribute it and/or
00013 ** modify it under the terms of the GNU Lesser General Public
00014 ** License version 2.1 as published by the Free Software Foundation
00015 ** and appearing in the file LICENSE.LGPL included in the packaging
00016 ** of this file.
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              Initiating the wallpaper editor screen from DBus
00045 
00046  In order to initiate the wallpaper editor from an external application two
00047  steps has to be performed.
00048 
00049  (1) First the controlpanel has to be started and the wallpaper applet must be
00050  activated through dbus. Please check the documentation of the
00051  libduicontrolpanel about this step.
00052 
00053  (2) Then the wallpaper applet can be contacted through DBus and the editor has
00054  to be initiated giving two image files as parameter. The first image file is
00055  the portrait, while the second is the landscape version of the wallpaper that
00056  should be editoed. The two images might be the same, in this case the very same
00057  image will be cropped differently for getting the portrait and the landscape
00058  variants. The following interface can be used for this step:
00059 
00060  dbus-send --session --type=signal / com.nokia.wallpaper.edit \
00061     string:/usr/share/themes/base/meegotouch/images/meegotouch-wallpaper-portrait.jpg \
00062     string:/usr/share/themes/base/meegotouch/images/meegotouch-wallpaper-landscape.jpg
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

Generated on Mon Jul 11 2011 12:00:31 for libMeegoControl by  doxygen 1.7.1