~renatofilho/buteo-syncfw/more-verbose

« back to all changes in this revision

Viewing changes to libsyncpluginmgr/SyncPluginBase.h

  • Committer: Sergey Gerasimenko
  • Date: 2010-06-29 12:51:21 UTC
  • Revision ID: git-v1:cd8dab07b102ac96752ece4f3cde5fc62697d717
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of buteo-syncfw package
 
3
 *
 
4
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
5
 *
 
6
 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public License
 
10
 * version 2.1 as published by the Free Software Foundation.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
20
 * 02110-1301 USA
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef SYNCPLUGINBASE_H
 
25
#define SYNCPLUGINBASE_H
 
26
 
 
27
#include "libsynccommon/SyncCommonDefs.h"
 
28
#include "libsyncprofile/SyncResults.h"
 
29
#include <QString>
 
30
#include <QMetaType>
 
31
#include <QObject>
 
32
 
 
33
 
 
34
 
 
35
namespace Buteo {
 
36
 
 
37
class PluginCbInterface;
 
38
 
 
39
/*! \brief Base class for client and server plugins.
 
40
 *
 
41
 */
 
42
class SyncPluginBase : public QObject
 
43
{
 
44
    Q_OBJECT;
 
45
 
 
46
public:
 
47
    /*! \brief Constructor
 
48
     *
 
49
     * @param aPluginName Name of this plugin
 
50
     * @param aProfileName Profile name
 
51
     * @param aCbInterface Pointer to the callback interface
 
52
     */
 
53
    SyncPluginBase( const QString &aPluginName,
 
54
                    const QString &aProfileName,
 
55
                    PluginCbInterface *aCbInterface );
 
56
 
 
57
    /*! \brief Returns the name of this plugin
 
58
     *
 
59
     * @return Name of the plugin
 
60
     */
 
61
    QString getPluginName() const;
 
62
 
 
63
    /*! \brief Returns profile name
 
64
     *
 
65
     * @return Profile
 
66
     */
 
67
    QString getProfileName() const;
 
68
 
 
69
    /*! \brief Initializes the plugin.
 
70
     *
 
71
     * It is recommended that the plugin should do not do any thread insecure
 
72
     * initializations inside constructor, instead it should be done inside
 
73
     * this method.
 
74
     *
 
75
     * @return True on success, otherwise false
 
76
     */
 
77
    virtual bool init() = 0;
 
78
 
 
79
    /*! \brief Uninitializes the plugin
 
80
     *
 
81
     * @return True on success, otherwise false
 
82
     */
 
83
    virtual bool uninit() = 0;
 
84
 
 
85
    /*! \brief Aborts synchronization
 
86
     *
 
87
     * Derived plug-in should implement this function and abort the sync
 
88
     * session that is in progress when this function is called. A final signal
 
89
     * (success or error) is still expected from the aborted session before
 
90
     * it terminates.
 
91
     */
 
92
    virtual void abortSync() { };
 
93
    
 
94
    /*! \brief Cleans up any sync related stuff (e.g sync anchors etc) when the 
 
95
     * profile is deleted
 
96
     *
 
97
     * Derived plug-in should implement this function and perform any cleanup
 
98
     * operations if required when the profile is deleted
 
99
     */
 
100
    virtual bool cleanUp() { return false; };
 
101
 
 
102
    /*! \brief Gets the results of the last completed sync session.
 
103
     *
 
104
     * This function should be called only after the sync session has finished,
 
105
     * after an error or success signal has been emitted.
 
106
     * The default implementation returns empty results, so derived plug-in
 
107
     * should implement this function.
 
108
     * @returns Sync results.
 
109
     */
 
110
    virtual SyncResults getSyncResults() const;
 
111
 
 
112
signals:
 
113
 
 
114
    /*! \brief Emitted when progress has been made in synchronization in
 
115
     * transferring items between local and remote database.
 
116
     *
 
117
     * @param aProfileName Name of the profile being synchronized
 
118
     * @param aDatabase Indicates if progress has been made to local or remote database
 
119
     * @param aType Type of progress made (item added, modified or deleted)
 
120
     * @param aMimeType Mime type of the processed item
 
121
     */
 
122
    void transferProgress( const QString &aProfileName, Sync::TransferDatabase aDatabase,
 
123
        Sync::TransferType aType, const QString &aMimeType);
 
124
 
 
125
    /*! \brief Emitted when error has occurred in synchronization and it
 
126
     *         cannot be continued.
 
127
     *
 
128
     * @param aProfileName Name of the profile being synchronized
 
129
     * @param aMessage Message data related to error event
 
130
     * @param aErrorCode Error code
 
131
     */
 
132
    void error( const QString &aProfileName, const QString &aMessage, int aErrorCode );
 
133
 
 
134
    /*! \brief Emitted when synchronization has been finished successfully.
 
135
     *
 
136
     * @param aProfileName Name of the profile being synchronized
 
137
     * @param aMessage Message data related to finish event
 
138
     */
 
139
    void success( const QString &aProfileName, const QString &aMessage );
 
140
 
 
141
    /*! \brief Emitted when a storage is requested and accquired.
 
142
     *
 
143
     * @param aMimeType Mime type of the processed item
 
144
     */
 
145
    void accquiredStorage( const QString &aMimeType );
 
146
    
 
147
public slots:
 
148
 
 
149
    /**
 
150
     * \brief Receives information about usb cable connection status
 
151
     * @param aCableStatus True if cable is connected, false if not
 
152
     */
 
153
    /*! \brief Slot that is invoked by sync framework when changes occur in
 
154
     *         connectivity domains
 
155
     *
 
156
     * @param aType Connectivity domain
 
157
     * @param aState True if connectivity domain is now available, otherwise false
 
158
     */
 
159
    virtual void connectivityStateChanged( Sync::ConnectivityType aType, bool aState ) = 0;
 
160
 
 
161
protected:
 
162
 
 
163
    PluginCbInterface*  iCbInterface;
 
164
 
 
165
private:
 
166
 
 
167
    QString iPluginName;
 
168
 
 
169
    QString iProfileName;
 
170
};
 
171
 
 
172
}
 
173
 
 
174
#endif // SYNCPLUGINBASE_H