source: extensions/digikam_export/piwigoexport/piwigos.cpp @ 4770

Last change on this file since 4770 was 4770, checked in by fcoiffie, 11 years ago

Premiere version du plugin Digikam piwigoexport

  • Connexion
  • Liste des categories
  • Upload des photos
File size: 3.1 KB
Line 
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
41namespace KIPIPiwigoExportPlugin
42{
43
44Piwigo::Piwigo()
45{
46    load();
47}
48
49Piwigo::~Piwigo()
50{
51}
52
53QString Piwigo::name() const
54{
55    return mName;
56}
57
58QString Piwigo::url() const
59{
60    return mUrl;
61}
62
63QString Piwigo::username() const
64{
65    return mUsername;
66}
67
68QString Piwigo::password() const
69{
70    return mPassword;
71}
72
73unsigned int Piwigo::galleryId() const
74{
75    return mPiwigoId;
76}
77
78// -------------------------------------
79
80void Piwigo::setName(const QString& name)
81{
82    mName = name;
83}
84
85void Piwigo::setUrl(const QString& url)
86{
87    mUrl = url;
88}
89
90void Piwigo::setUsername(const QString& username)
91{
92    mUsername = username;
93}
94
95void Piwigo::setPassword(const QString& password)
96{
97    mPassword = password;
98}
99
100void Piwigo::setPiwigoId(unsigned int galleryId)
101{
102    mPiwigoId = galleryId;
103}
104
105void Piwigo::load()
106{
107    // FIXME: sure we need this?? (perhaps YES..)
108    static bool bln_loaded = false;
109    if (bln_loaded) return;
110    bln_loaded = true;
111
112    // read config
113    KConfig config("kipirc");
114    KConfigGroup group = config.group("Piwigo Settings");
115
116    kDebug() << "Reading data from kipirc file..";
117
118    mName     = group.readEntry("Name",     QString() );
119    mUrl      = group.readEntry("URL",      QString() );
120    mUsername = group.readEntry("Username", QString() );
121    mPassword = group.readEntry("Password", QString() );
122}
123
124void Piwigo::save()
125{
126    KConfig config("kipirc");
127    KConfigGroup group = config.group("Piwigo Settings");
128
129    kDebug() << "Saving data to kipirc file..";
130
131    group.writeEntry(QString("Name"),     name() );
132    group.writeEntry(QString("URL"),      url() );
133    group.writeEntry(QString("Username"), username() );
134    group.writeEntry(QString("Password"), password() );
135
136    kDebug() << "syncing..";
137    config.sync();
138}
139
140} // namespace KIPIPiwigoExportPlugin
Note: See TracBrowser for help on using the repository browser.