summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncprofile.cpp
blob: d6d8fa3bc8f9b04f59ebb772c83c329432102e14 (plain)
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
/*
    This file is part of KOrganizer.
    Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

// $Id$

#include <qcolor.h>

#include <kconfig.h>
#include <kstandarddirs.h>
#include <kglobal.h>
#include <kdebug.h>

#include "ksyncprofile.h"


KSyncProfile::KSyncProfile( const char * name): QObject (0, name ) 
{
    setDefault(); 
}
KSyncProfile::~KSyncProfile()
{

}


KSyncProfile* KSyncProfile::clone()
{
    KSyncProfile* myClone = new KSyncProfile();
    myClone->setPreSyncCommand( mPreSyncCommand );
    myClone->setPostSyncCommand( mPostSyncCommand );
    myClone->setLocalTempFile( mLocalTempFile);
    myClone->setRemoteFileName( mRemoteFileName );
    myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
    myClone->setAskForPreferences( mAskForPreferences);
    myClone->setWriteBackExisting(mWriteBackExisting );
    myClone->setWriteBackFile( mWriteBackFile);
    myClone->setIncludeInRingSync( mIncludeInRingSync );
    myClone->setSyncPrefs( mSyncPrefs);
    myClone->setIsLocalFileSync( mIsLocalFileSync );
    myClone->setName( "noName" );
    return myClone;
}


void KSyncProfile::setDefault()
{
    mName = "noName";
    mPreSyncCommand = i18n("command for downloading remote file to local device");
    mPostSyncCommand = i18n("command for uploading local temp file to remote device");
    mLocalTempFile = "/tmp/mycalendar.ics";
    mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
    mShowSummaryAfterSync = true;
    mAskForPreferences = true;
    mWriteBackExisting = false;
    mWriteBackFile = true;
    mIncludeInRingSync = false;
    mSyncPrefs = SYNC_PREF_ASK;
    mIsLocalFileSync = true;

}
void KSyncProfile::readConfig(KConfig *config )
{
    config->setGroup("SyncProfiles");
    QString prefix = "Profile_"+mName+"_";
    //mName = config->readEntry( prefix+ "Name", mName );
    mPreSyncCommand = config->readEntry( prefix+ "PreSyncCommand",mPreSyncCommand  );
    mPostSyncCommand = config->readEntry( prefix+ "PostSyncCommand", mPostSyncCommand );
    mIncludeInRingSync = config->readBoolEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync  );
    mLocalTempFile = config->readEntry( prefix+ "LocalTempFile", mLocalTempFile );
    mRemoteFileName = config->readEntry( prefix+ "RemoteFileName", mRemoteFileName );
    mShowSummaryAfterSync = config->readBoolEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync );
    mAskForPreferences = config->readBoolEntry( prefix+ "AskForPreferences",mAskForPreferences  );
    mWriteBackExisting = config->readBoolEntry( prefix+ "WriteBackExisting",mWriteBackExisting  );
    mSyncPrefs = config->readNumEntry( prefix+ "SyncPrefs", mSyncPrefs );
    mIsLocalFileSync= config->readBoolEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync );
}
void KSyncProfile::writeConfig( KConfig * config )
{
    config->setGroup("SyncProfiles");
    QString prefix = "Profile_"+mName+"_";
    // config->writeEntry( prefix+ "Name", mName );
    config->writeEntry( prefix+ "PreSyncCommand",mPreSyncCommand  );
    config->writeEntry( prefix+ "PostSyncCommand", mPostSyncCommand );
    config->writeEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync  );
    config->writeEntry( prefix+ "LocalTempFile", mLocalTempFile );
    config->writeEntry( prefix+ "RemoteFileName", mRemoteFileName );
    config->writeEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync );
    config->writeEntry( prefix+ "AskForPreferences",mAskForPreferences  );
    config->writeEntry( prefix+ "WriteBackExisting",mWriteBackExisting  );
    config->writeEntry( prefix+ "SyncPrefs", mSyncPrefs );
    config->writeEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync );
}

/*
class KPrefsItemInt : public KPrefsItem {
  public:
    KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
    virtual ~KPrefsItemInt() {}
    
    void setDefault();
    void readConfig(KConfig *);
    void writeConfig(KConfig *);

  private:
    int *mReference;
    int mDefault;
};
*/