home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / stdaddressbook.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.0 KB  |  154 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KABC_STDADDRESSBOOK_H
  22. #define KABC_STDADDRESSBOOK_H
  23.  
  24. #include "addressbook.h"
  25.  
  26. namespace KABC {
  27.  
  28. /**
  29.   Standard KDE address book
  30.  
  31.   This class provides access to the standard KDE address book shared by all
  32.   applications.
  33.  
  34.   It's implemented as a singleton. Use self() to get the address book
  35.   object. On the first self() call the address book also gets loaded.
  36.  
  37.   Example:
  38.  
  39.   \code
  40.   KABC::AddressBook *ab = KABC::StdAddressBook::self();
  41.  
  42.   AddressBook::Ticket *ticket = ab->requestSaveTicket();
  43.  
  44.   if ( ticket ) {
  45.     KABC::AddressBook::Iterator it;
  46.     for ( it = ab->begin(); it != ab->end(); ++it ) {
  47.       kdDebug() << "UID=" << (*it).uid() << endl;
  48.  
  49.       // do some other stuff
  50.     }
  51.  
  52.     KABC::StdAddressBook::save( ticket );
  53.   }
  54.   \endcode
  55. */
  56. class KABC_EXPORT StdAddressBook : public AddressBook
  57. {
  58.   public:
  59.  
  60.     /**
  61.       Destructor.
  62.      */
  63.     ~StdAddressBook();
  64.  
  65.     /**
  66.       Returns the standard addressbook object. It also loads all resources of
  67.       the users standard address book synchronously.
  68.      */
  69.     static StdAddressBook *self();
  70.  
  71.     /**
  72.       This is the same as above, but with specified behaviour of resource loading.
  73.  
  74.       @param asynchronous When true, the resources are loaded asynchronous, that
  75.                           means you have the data foremost the addressBookChanged()
  76.                           signal has been emitted. So connect to this signal when
  77.                           using this method!
  78.      */
  79.     static StdAddressBook *self( bool asynchronous );
  80.  
  81.     /**
  82.       Saves the standard address book to disk.
  83.  
  84.       @deprecated Use AddressBook::save( Ticket* ) instead
  85.      */
  86.     static bool save() KDE_DEPRECATED;
  87.  
  88.     /**
  89.       @deprecated There is no need to call this function anymore.
  90.     */
  91.     static void handleCrash() KDE_DEPRECATED;
  92.  
  93.     /**
  94.       Returns the default file name for vcard-based addressbook
  95.      */
  96.     static QString fileName();
  97.  
  98.     /**
  99.       Returns the default directory name for vcard-based addressbook
  100.      */
  101.     static QString directoryName();
  102.  
  103.     /**
  104.       Sets the automatic save property of the address book.
  105.  
  106.       @param state If true, the address book is saved automatically
  107.                    at destruction time, otherwise you have to call
  108.                    AddressBook::save( Ticket* ).
  109.      */
  110.     static void setAutomaticSave( bool state );
  111.  
  112.     /**
  113.       Closes the address book. Depending on automaticSave() it will
  114.       save the address book first.
  115.     */
  116.     static void close();
  117.  
  118.     /**
  119.       Returns whether the address book is saved at destruction time.
  120.       See also setAutomaticSave().
  121.      */
  122.     static bool automaticSave();
  123.  
  124.     /**
  125.       Returns the contact, that is associated with the owner of the
  126.       address book. This contact should be used by other programs
  127.       to access user specific data.
  128.      */
  129.     Addressee whoAmI();
  130.  
  131.     /**
  132.       Sets the users contact. See whoAmI() for more information.
  133.  
  134.       @param addr The users contact.
  135.      */
  136.     void setWhoAmI( const Addressee &addr );
  137.  
  138.   protected:
  139.     StdAddressBook();
  140.     StdAddressBook( bool asynchronous );
  141.  
  142.     void init( bool asynchronous );
  143.     bool saveAll();
  144.  
  145.   private:
  146.     static StdAddressBook *mSelf;
  147.     static bool mAutomaticSave;
  148. };
  149.  
  150. }
  151.  
  152. #endif
  153.  
  154.