diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kdeaccounts-plugin | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeaccounts-plugin')
-rw-r--r-- | kdeaccounts-plugin/Makefile.am | 17 | ||||
-rw-r--r-- | kdeaccounts-plugin/README | 15 | ||||
-rw-r--r-- | kdeaccounts-plugin/kdeaccountsformat.cpp | 90 | ||||
-rw-r--r-- | kdeaccounts-plugin/kdeaccountsformat.h | 51 | ||||
-rw-r--r-- | kdeaccounts-plugin/kdeaccountsplugin.desktop | 44 |
5 files changed, 217 insertions, 0 deletions
diff --git a/kdeaccounts-plugin/Makefile.am b/kdeaccounts-plugin/Makefile.am new file mode 100644 index 00000000..7be8cea3 --- /dev/null +++ b/kdeaccounts-plugin/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) + +noinst_HEADERS = kdeaccountsformat.h +kde_module_LTLIBRARIES = kabcformat_kdeaccounts.la +kabcformat_kdeaccounts_la_SOURCES = kdeaccountsformat.cpp +kabcformat_kdeaccounts_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kabcformat_kdeaccounts_la_LIBADD = -lkabc + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kabcformat_kdeaccounts.pot + +linkdir = $(kde_datadir)/kabc/formats +link_DATA = kdeaccountsplugin.desktop +EXTRA_DIST = $(link_DATA) README diff --git a/kdeaccounts-plugin/README b/kdeaccounts-plugin/README new file mode 100644 index 00000000..1319ab18 --- /dev/null +++ b/kdeaccounts-plugin/README @@ -0,0 +1,15 @@ +This is a KDE Addressbook Plugin, that is able to parse the file containing +names and email addresses of all KDE CVS accounts and puts them into your +addressbook. Very handy being able to auto-complete all those KDE developers +in KMail :) + +After installing, fire up kcontrol, open the Addressbook configuration, +select Add -> "file", enter a descriptive name like "KDE CVS Accounts", +check the "Read-only" option and select "KDE CVS Accounts" from the +dropdown list. Finally, enter the full path to the "accounts" file +(in CVS, it's in the "kde-common" module). + +That should be all :) + +Carsten Pfeiffer <pfeiffer@kde.org> + diff --git a/kdeaccounts-plugin/kdeaccountsformat.cpp b/kdeaccounts-plugin/kdeaccountsformat.cpp new file mode 100644 index 00000000..d445e311 --- /dev/null +++ b/kdeaccounts-plugin/kdeaccountsformat.cpp @@ -0,0 +1,90 @@ +#include "kdeaccountsformat.h" + +#include <qcstring.h> +#include <qfile.h> + +#include <kabc/addressbook.h> +#include <kabc/addressee.h> +#include <kabc/resourcefile.h> + +extern "C" +{ + KDE_EXPORT KABC::FormatPlugin *format() + { + return new KDEAccountsFormat(); + } +} + +/** + * Loads addresses of the kde-common/accounts file-> The format is + * pfeiffer Carsten Pfeiffer pfeiffer@kde.org + */ + +bool KDEAccountsFormat::loadAll( KABC::AddressBook *book, + KABC::Resource *resource, + QFile *file ) +{ + if ( !book || !file ) // eh? + return false; + + QString uuid = "KDEAccountsEntry."; + int id = 0; + + QByteArray array = file->readAll(); + file->close(); + + QByteArray::ConstIterator it = array.begin(); + QByteArray::ConstIterator end = array.end(); + QByteArray::ConstIterator startLine; + QString line; + char eol = '\n'; + char delim = ' '; + + for ( ; it < end; it++ ) + { + startLine = it; + + for ( ; it && it < end && *it != eol; it++ ) + { } // find eol + + uint length = it - startLine; + line = QString::fromUtf8( startLine, length ).simplifyWhiteSpace(); + + QString nickName; + QString name; + QString email; + + int firstSpace = line.find( delim ); + if ( firstSpace > 0 ) + { + nickName = line.left( firstSpace ); + + int lastSpace = line.findRev( delim ); + if ( lastSpace > firstSpace ) + { + email = line.mid( lastSpace +1 ); + + int start = firstSpace + 1; + int length = lastSpace - start; + name = line.mid( start, length ); + + if ( !email.isEmpty() ) + { + KABC::Addressee address; + address.setNickName( nickName ); + address.setNameFromString( name ); + address.setOrganization("KDE Project"); + address.insertCategory("KDE Developer"); + address.insertEmail( email ); + address.setUid( uuid + QString::number( id++ )); + + address.setResource( resource ); + book->insertAddressee( address ); + } + } + } + } + + return true; +} + diff --git a/kdeaccounts-plugin/kdeaccountsformat.h b/kdeaccounts-plugin/kdeaccountsformat.h new file mode 100644 index 00000000..6eb07c7c --- /dev/null +++ b/kdeaccounts-plugin/kdeaccountsformat.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** $Id$ +** +** Created : 2001 +** +** Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> +** +****************************************************************************/ + +#ifndef KDEACCOUNTSPARSER_H +#define KDEACCOUNTSPARSER_H + +#include <kabc/formatplugin.h> + +namespace KABC { + class AddressBook; +} + +class KDEAccountsFormat : public KABC::FormatPlugin +{ +public: + KDEAccountsFormat() {} + ~KDEAccountsFormat() {} + + virtual bool loadAll( KABC::AddressBook *, + KABC::Resource *resource, QFile *file ); + + virtual bool load( KABC::Addressee&, QFile *) + { + qDebug("*** KDE Accounts format: load single entry not supported."); + return false; + } + virtual void save( const KABC::Addressee&, QFile *) + { + qDebug("*** KDE Accounts format: save not supported."); + } + virtual void saveAll( KABC::AddressBook *, KABC::Resource *, QFile *) + { + qDebug("*** KDE Accounts format: save not supported."); + } + virtual bool checkFormat( QFile *file ) const + { + if ( file->name().endsWith( "/accounts" ) ) + return true; // lame, but works for me :) + + return false; + } + +}; + +#endif // KDEACCOUNTSPARSER_H diff --git a/kdeaccounts-plugin/kdeaccountsplugin.desktop b/kdeaccounts-plugin/kdeaccountsplugin.desktop new file mode 100644 index 00000000..03abf9a2 --- /dev/null +++ b/kdeaccounts-plugin/kdeaccountsplugin.desktop @@ -0,0 +1,44 @@ +[Misc] +Name=KDE Repository Accounts +Name[bg]=Сметки в хранилището на KDE +Name[ca]=Comptes del repositori de KDE +Name[cs]=Účty z KDE repository +Name[da]=KDE lager-konti +Name[de]=KDE Repositorium-Zugänge +Name[el]=Λογαριασμοί χώρου αποθήκευσης του KDE +Name[es]=Cuentas del repositorio de KDE +Name[et]=KDE hoidla kontod +Name[eu]=KDE-ren biltegiaren kontuak +Name[fa]=حسابهای مخزن KDE +Name[fi]=KDE:n versionhallinnan käyttäjätunnukset +Name[fr]=Comptes du référentiel de KDE +Name[gl]=Contas no repositorio de KDE +Name[hu]=KDE SVN-azonosítók +Name[is]=KDE geymslu aðgangur +Name[it]=Account del deposito di KDE +Name[ja]=KDE リポジトリアカウント +Name[ka]=KDE რეპოზიტორიის ანგარიში +Name[kk]=KDE қоймасының тіркелгілері +Name[lt]=KDE saugyklos paskyros +Name[nb]=KDE-lagerkontoer +Name[nds]=KDE-Archivkontos +Name[ne]=केडीई भण्डार खाता +Name[nl]=KDE Repository gebruikersnamen +Name[nn]=KDE-lagerkontoar +Name[pa]=KDE ਰਿਪੋਜ਼ਟਰੀ ਖਾਤੇ +Name[pl]=Konta w repozytorium KDE +Name[pt]=Contas do Repositório do KDE +Name[pt_BR]=Contas do Repositório do KDE +Name[ru]=Учётные записи репозитория KDE +Name[sk]=Účty KDE archívu +Name[sl]=Računi za skladišče KDE +Name[sr]=Налози KDE складишта +Name[sr@Latn]=Nalozi KDE skladišta +Name[sv]=KDE-arkivkonton +Name[uk]=Рахунки сховища KDE +Name[zh_CN]=KDE 仓库账号 +Name[zh_TW]=KDE 主目錄帳號 + +[Plugin] +Type=text +X-KDE-Library=kabcformat_kdeaccounts |