1 | /* ============================================================ |
---|
2 | * |
---|
3 | * This file is a part of kipi-plugins project |
---|
4 | * http://www.kipi-plugins.org |
---|
5 | * |
---|
6 | * Date : 2010-01-07 |
---|
7 | * Description : a plugin to export to a remote Piwigo server. |
---|
8 | * |
---|
9 | * Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com> |
---|
10 | * Copyright (C) 2006 by Colin Guthrie <kde@colin.guthr.ie> |
---|
11 | * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> |
---|
12 | * Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com> |
---|
13 | * Copyright (C) 2010 by Frederic Coiffier <frederic dot coiffier at free dot com> |
---|
14 | * |
---|
15 | * This program is free software; you can redistribute it |
---|
16 | * and/or modify it under the terms of the GNU General |
---|
17 | * Public License as published by the Free Software Foundation; |
---|
18 | * either version 2, or (at your option) any later version. |
---|
19 | * |
---|
20 | * This program is distributed in the hope that it will be useful, |
---|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | * GNU General Public License for more details. |
---|
24 | * |
---|
25 | * ============================================================ */ |
---|
26 | |
---|
27 | #include "piwigos.h" |
---|
28 | |
---|
29 | // Qt includes |
---|
30 | |
---|
31 | #include <QString> |
---|
32 | |
---|
33 | // KDE includes |
---|
34 | |
---|
35 | #include <kapplication.h> |
---|
36 | #include <kconfig.h> |
---|
37 | #include <kconfiggroup.h> |
---|
38 | #include <kdebug.h> |
---|
39 | #include <klocale.h> |
---|
40 | |
---|
41 | namespace KIPIPiwigoExportPlugin |
---|
42 | { |
---|
43 | |
---|
44 | Piwigo::Piwigo() |
---|
45 | { |
---|
46 | load(); |
---|
47 | } |
---|
48 | |
---|
49 | Piwigo::~Piwigo() |
---|
50 | { |
---|
51 | } |
---|
52 | |
---|
53 | QString Piwigo::name() const |
---|
54 | { |
---|
55 | return mName; |
---|
56 | } |
---|
57 | |
---|
58 | QString Piwigo::url() const |
---|
59 | { |
---|
60 | return mUrl; |
---|
61 | } |
---|
62 | |
---|
63 | QString Piwigo::username() const |
---|
64 | { |
---|
65 | return mUsername; |
---|
66 | } |
---|
67 | |
---|
68 | QString Piwigo::password() const |
---|
69 | { |
---|
70 | return mPassword; |
---|
71 | } |
---|
72 | |
---|
73 | // ------------------------------------- |
---|
74 | |
---|
75 | void Piwigo::setName(const QString& name) |
---|
76 | { |
---|
77 | mName = name; |
---|
78 | } |
---|
79 | |
---|
80 | void Piwigo::setUrl(const QString& url) |
---|
81 | { |
---|
82 | mUrl = url; |
---|
83 | } |
---|
84 | |
---|
85 | void Piwigo::setUsername(const QString& username) |
---|
86 | { |
---|
87 | mUsername = username; |
---|
88 | } |
---|
89 | |
---|
90 | void Piwigo::setPassword(const QString& password) |
---|
91 | { |
---|
92 | mPassword = password; |
---|
93 | } |
---|
94 | |
---|
95 | void Piwigo::load() |
---|
96 | { |
---|
97 | // FIXME: sure we need this?? (perhaps YES..) |
---|
98 | static bool bln_loaded = false; |
---|
99 | if (bln_loaded) return; |
---|
100 | bln_loaded = true; |
---|
101 | |
---|
102 | // read config |
---|
103 | KConfig config("kipirc"); |
---|
104 | KConfigGroup group = config.group("Piwigo Settings"); |
---|
105 | |
---|
106 | kDebug() << "Reading data from kipirc file.."; |
---|
107 | |
---|
108 | mName = group.readEntry("Name", QString() ); |
---|
109 | mUrl = group.readEntry("URL", QString() ); |
---|
110 | mUsername = group.readEntry("Username", QString() ); |
---|
111 | mPassword = group.readEntry("Password", QString() ); |
---|
112 | } |
---|
113 | |
---|
114 | void Piwigo::save() |
---|
115 | { |
---|
116 | KConfig config("kipirc"); |
---|
117 | KConfigGroup group = config.group("Piwigo Settings"); |
---|
118 | |
---|
119 | kDebug() << "Saving data to kipirc file.."; |
---|
120 | |
---|
121 | group.writeEntry(QString("Name"), name() ); |
---|
122 | group.writeEntry(QString("URL"), url() ); |
---|
123 | group.writeEntry(QString("Username"), username() ); |
---|
124 | group.writeEntry(QString("Password"), password() ); |
---|
125 | |
---|
126 | kDebug() << "syncing.."; |
---|
127 | config.sync(); |
---|
128 | } |
---|
129 | |
---|
130 | } // namespace KIPIPiwigoExportPlugin |
---|