diff options
author | Darrell Anderson <[email protected]> | 2013-03-02 15:57:34 -0600 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2013-03-02 15:57:34 -0600 |
commit | 7c0b0c9dc9fcbe9c198925bdc7ee18ac6be49f4f (patch) | |
tree | c76702a7f6310fbe9d437e347535422e836e94e9 /tdeabc | |
parent | a2a38be7600e2a2c2b49c66902d912ca036a2c0f (diff) | |
parent | 27bbee9a5f9dcda53d8eb23863ee670ad1360e41 (diff) | |
download | tdelibs-7c0b0c9dc9fcbe9c198925bdc7ee18ac6be49f4f.tar.gz tdelibs-7c0b0c9dc9fcbe9c198925bdc7ee18ac6be49f4f.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdelibs
Diffstat (limited to 'tdeabc')
316 files changed, 50542 insertions, 0 deletions
diff --git a/tdeabc/CMakeLists.txt b/tdeabc/CMakeLists.txt new file mode 100644 index 000000000..0cd900c08 --- /dev/null +++ b/tdeabc/CMakeLists.txt @@ -0,0 +1,123 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( vcard ) +add_subdirectory( vcardparser ) +add_subdirectory( formats ) +add_subdirectory( plugins ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/vcard/include + ${CMAKE_CURRENT_SOURCE_DIR}/vcard/include/generated + ${CMAKE_CURRENT_SOURCE_DIR}/vcardparser + + # external includes + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/kab +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + address.h addressbook.h addresseedialog.h + agent.h distributionlist.h distributionlistdialog.h + distributionlisteditor.h errorhandler.h field.h + format.h formatfactory.h formatplugin.h geo.h key.h + phonenumber.h picture.h plugin.h resource.h secrecy.h + resourceselectdialog.h sound.h stdaddressbook.h + timezone.h vcardconverter.h vcardformat.h lock.h + vcardformatplugin.h ldifconverter.h addresslineedit.h + ldapclient.h addresseelist.h locknull.h ldif.h + ldapurl.h ldapconfigwidget.h sortmode.h + ${CMAKE_CURRENT_BINARY_DIR}/addressee.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### other data ################################ + +install( FILES tdeab2tdeabc.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) +install( FILES tdeabc_manager.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources ) +install( FILES countrytransl.map DESTINATION ${DATA_INSTALL_DIR}/tdeabc ) + + +##### generated files ########################### +# FIXME this hack make compatibility with out-of-source mode + +file( COPY + scripts/makeaddressee scripts/addressee.src.cpp + scripts/addressee.src.h scripts/entrylist scripts/field.src.cpp + DESTINATION scripts ) + +add_custom_command( + OUTPUT addressee.cpp addressee.h field.cpp + COMMAND perl + ARGS makeaddressee + DEPENDS scripts/addressee.src.cpp scripts/addressee.src.h scripts/entrylist scripts/field.src.cpp + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts +) + + +##### tdeabc ###################################### + +set( target tdeabc ) + +set( ${target}_SRCS + address.cpp addressbook.cpp addressee.cpp addresseedialog.cpp + agent.cpp distributionlist.cpp distributionlistdialog.cpp + distributionlisteditor.cpp errorhandler.cpp field.cpp + formatfactory.cpp geo.cpp key.cpp phonenumber.cpp + picture.cpp plugin.cpp resource.cpp resourceselectdialog.cpp + secrecy.cpp sound.cpp stdaddressbook.cpp timezone.cpp + vcard21parser.cpp vcardconverter.cpp vcardformat.cpp + vcardformatimpl.cpp vcardformatplugin.cpp ldifconverter.cpp + addresslineedit.cpp ldapclient.cpp addresseelist.cpp + vcardtool.cpp addresseehelper.cpp lock.cpp locknull.cpp + ldif.cpp ldapurl.cpp ldapconfigwidget.cpp sortmode.cpp + addresseehelper.skel +) + +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION 1.2.0 + LINK vcards-static vcard-shared tdeio-shared tderesources-shared + DEPENDENCIES addressee.h dcopidl + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### tdeab2tdeabc ################################## + +set( target tdeab2tdeabc ) + +set( ${target}_SRCS + tdeab2tdeabc.cpp +) + +tde_add_executable( ${target} + SOURCES ${${target}_SRCS} + LINK kab-static tdeabc-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/tdeabc/HACKING b/tdeabc/HACKING new file mode 100644 index 000000000..429ae0865 --- /dev/null +++ b/tdeabc/HACKING @@ -0,0 +1,100 @@ +Coding Style +============ + +See http://korganizer.kde.org/hacking.html for an HTML version. + +Formatting +---------- + +- No Tabs. +- Indent with 2 spaces. +- A line must not have more than 80 chars. +- Put Spaces between brackets and arguments of functions. +- For if, else, while and similar statements put the brackets on the same line + as the statement. +- Function and class definitions have their brackets on separate lines. + +Example: + +void MyClass::myFunction() +{ + if ( blah == fasel ) { + blubbVariable = arglValue; + } else { + blubbVariable = oerxValue; + } +} + + +Header Formatting +----------------- + +- General formatting rules apply. +- Access modifiers are indented. +- Put curly brackets of class definition on its own line. +- Double inclusion protection defines are all upper case letters and are + composed of the namespace (if available), the classname and a H suffix + separated by underscores. +- Inside a namespace there is no indentation. + +Example: + +#ifndef XKJ_MYCLASS_H +#define XKJ_MYCLASS_H + +namespace XKJ { + +class MyClass +{ + public: + MyClass(); + + private: + int mMyInt; +}; + +} + +#endif + + +API docs +-------- + +- Each public function must have a Doxygen compatible comment in the header +- Use C-style comments without additional asterisks +- Indent correctly. +- Comments should be grammatically correct, e.g. sentences start with uppercase + letters and end with a full stop. +- Be concise. + +Example: + + /** + This function makes tea. + + @param cups number of cups. + @result tea + */ + Tea makeTea( int cups ); + + +Class and File Names +-------------------- + +- Put classes in files, which have the same name as the class, but only + lower-case letters. +- Designer-generated files should have a name classname_base.ui and shoul + contain a class called ClassnameBase. +- Classes inheriting from designer-generated classes have the same name as the + generated class, but without the Base suffix. + +Class and Variable Names +------------------------ + +- For class, variable, function names seperate multiple words by upper-casing + the words precedeed by other words. +- Class names start with an upper-case letter. +- Function names start with a lower-case letter. +- Variable names start with a lower-case letter. +- Member variables of a class start with "m" followed by an upper-case letter. diff --git a/tdeabc/HOWTO b/tdeabc/HOWTO new file mode 100644 index 000000000..5187f2580 --- /dev/null +++ b/tdeabc/HOWTO @@ -0,0 +1,372 @@ +The KDE Address Book Framework +=============================== + +The KDE address book framework tries to provide an easy to use and powerful +mechanism to handle contacts in all KDE applications. + +If you want to make use of it, this small introduction to programming +with libkabc may be helpful. + + +General Concepts +================= + +In libkabc the storage and management of contacts is devided in 2 layers. + +****************** +Management Layer * +****************** + + .-------------------. + | TDEABC::AddressBook | + .--------------------------------. + | TDEABC::Addressee | => Iterators + | TDEABC::Addressee | + | TDEABC::Addressee | => Search functions + | ... | + `--------------------------------' + | + - - - - - - - - - - - | - - - - - - - - - - - - - + | +*************** | +Storage Layer * | +*************** | ....................... + | . . - Network + .---------------. | . .---------------. . + | ResourceFile |----+-----| ResourceLDAP | . + `---------------' | . `---------------' . + .---------------. | . .---------------. . + | ResourceDir |----+-----| ResourceNet | . + `---------------' . `---------------' . + . . + ....................... + + +The Management Layer +--------------------- +The Management Layer consists of the two classes TDEABC::AddressBook and +TDEABC::Addressee. TDEABC::AddressBook is a container for TDEABC::Addressee objects +and provides 2 kinds of access methods. +1) Iterators + With iterators you can iterate over each of the contacts of the + address book and perform an action on it + +2) Search functions + With search functions you can search for contacts with special attributes + such as "all contacts with the name 'Harald'" + +The class TDEABC::Addressee represents a single contact and contains all data +a vCard could store (as specified in RFC 2426). + +The Storage Layer +------------------ +The Storage Layer consists of the class TDEABC::Resource and its derived classes. +These classes are used by TDEABC::AddressBook to load and store the contacts to +the single backends. +At the moment libkabc provides 4 types of resources: +1) ResourceFile + - stores all contacts in a single file + +2) ResourceDir + - stores each contact in its own file with the unique identifier of the + contact as a filename, will all of the files together in one directory + +3) ResourceLDAP + - stores all of the contacts on a LDAP server + +4) ResourceNet + - stores all contacts in a single file, which can be accessable via HTTP, + FTP, Fish, WebDAV, POP3, IMAP or whatever the KIO frame work supports + +In general the developer does not have to take how to save the single contacts. +He just has to plug one of the above mentioned resources into TDEABC::AddressBook +and perform a save action. + +Examples +========= +Like a picture, C/C++ code is worth a 1000 words I'd like to give you a +lot of examples now, how to use libkabc for several tasks: + + +Using TDEABC::StdAddressBook and Iterators +----------------------------------------- +Normally you have to plugin the resources manually into the addressbook object +and call the load() function before you can access the contacts, but there is +a special class TDEABC::StdAddressBook, which loads all resources of the standard +address book of the user automatically. You can use it the following way: + + + #include <tdeabc/stdaddressbook.h> + + 1: TDEABC::AddressBook *ab = TDEABC::StdAddressBook::self(); + 2: TDEABC::AddressBook::Iterator it; + 3: for ( it = ab->begin(); it != ab->end(); ++it ) { + 4: TDEABC::Addressee addr = (*it); + 5: + 6: kdDebug() << "Name = " << addr.formattedName() << endl; + 7: } + +The above example prints out the names of all the contacts in the user's address +book. In line 1 you retrieve a pointer to the user's standard address book +(provided by TDEABC::StdAddressBook via a singleton design pattern). +In line 2 an iterator is defined, which is used in line 3 to iterate over the +whole address book. The assignment in line 4 is intended only to show more +clearly how iterators function. +You could also use (*it).formattedName() directly. In line 6 the formatted name +of the current contact is printed out to stderr. +As you can see that's all magic, and it's quite easy ;) + + +Using TDEABC::AddressBook manually +--------------------------------- +In some cases you don't want to load the user's standard address book, but, +for example, just a single vCard. For this purpose you have to use the +class TDEABC::AddressBook and handle the resource stuff manually. +The following code will create a file resource and save a contact into it: + + + #include <tdeabc/addressbook.h> + #include <tdeabc/resourcefile.h> + + 1: TDEABC::AddressBook ab; + 2: + 3: // create a file resource + 4: TDEABC::Resource *res = new TDEABC::ResourceFile( "/home/user/myvcard.vcf", "vcard" ); + 5: + 6: if ( !ab.addResource( res ) ) { + 7: kdDebug() << "Unable to open resource" << endl; + 8: return 1; + 9: } +10: +11: if ( !ab.load() ) { +12: kdDebug() << "Unable to load address book!" << endl; +13: return 2; +14: } +15: +16: TDEABC::Addressee addr; +17: addr.setNameFromString( "Otto Harald Meyer" ); +18: addr.setBirthday( QDate( 1982, 07, 19 ) ); +19: addr.setNickName( "otto" ); +20: addr.setMailer( "kmail" ); +21: +22: // TZ +23: TDEABC::TimeZone tz( 60 ); // takes time shift in minutes as argument +24: addr.setTimeZone( tz ); +25: +26: // GEO +27: TDEABC::Geo geo( 52.5, 13.36 ); // takes latitude and longitude as argument +28: addr.setGeo( geo ); +29: +30: addr.setTitle( "dude, the" ); +31: addr.setRole( "developer" ); +32: addr.setOrganization( "KDE e.V." ); +33: addr.setNote( "Yet another senseless note..." ); +34: addr.setUrl( KURL( "http://kaddressbook.org" ) ); +35: +36: // CLASS +37: TDEABC::Secrecy secrecy( TDEABC::Secrecy::Confidential ); +38: addr.setSecrecy( secrecy ); +39: +40: // PHOTO or LOGO +41: TDEABC::Picture photo; +42: QImage img; +43: if ( img.load( "face.png", "PNG" ) ) { +44: photo.setData( img ); +45: photo.setType( "image/png" ); +46: addr.setPhoto( photo ); +47: } +48: +49: addr.insertEmail( "[email protected]", true ); // preferred email +50: addr.insertEmail( "[email protected]", false ); +51: +52: // TEL +53: TDEABC::PhoneNumber phoneHome( "0351 5466738", TDEABC::PhoneNumber::Home ); +54: TDEABC::PhoneNumber phoneWork( "0351 2335411", TDEABC::PhoneNumber::Work ); +55: addr.insertPhoneNumber( phoneHome ); +56: addr.insertPhoneNumber( phoneWork ); +57: +58: // ADR +59: TDEABC::Address homeAddr( TDEABC::Address::Home ); +60: homeAddr.setStreet( "Milliwaystreet 42" ); +61: homeAddr.setLocality( "London" ); +62: homeAddr.setRegion( "Saxony" ); +63: homeAddr.setPostalCode( "43435" ); +64: homeAddr.setCountry( "Germany" ); +65: addr.insertAddress( homeAddr ); +66: +67: addr.insertCategory( "LUG-Dresden-Members" ); +68: +69: addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", "21.04.2009" ); +70: +71: ab.insertAddressee( addr ); // will be assigned to the standard resource +72: // automatically +73: +74: TDEABC::Ticket *ticket = ab.requestSaveTicket( res ); +75: if ( !ticket ) { +76: kdError() << "Resource is locked by other application!" << endl; +77: } else { +78: if ( !ab.save( ticket ) ) { +79: kdError() << "Saving failed!" << endl; +80: ab.releaseSaveTicket( ticket ); +81: } +82: +83: } +84: +85: return 0; + +In line 1 the TDEABC::AddressBook is created. In line 4 you creat the +TDEABC::ResourceFile (which will handle the loading/saving). +The resource takes 2 arguments, the first is the file name and the +second one the file format. At the moment libkabc supports two file formats: +1) vCard, as specified in RFC 2426 +2) Binary, which increases performance during loading and saving + +In line 6 we try to plug the resource into the addressbook. The addressbook +class tries to open the resource immediately and returns whether opening was +successful. We add here only one resource, but you can add as many resources +as you want. + +In line 11 we try to load all contacts from the backends into the address book. +As before, it returns whether opening was successful. + +In line 16 a TDEABC::Addressee is created, which we will fill now with data, +before inserting it into the TDEABC::AddressBook. +The setNameFromString() function in the following line takes a string as +argument and tries to parse it into the single name components such as: given +name, family name, additional names, honoric prefix and honoric suffix. +You can set these values manually as well by calling + addr.setGivenName( "Otto" ); +and + addr.setFamilyName( "Meyer" ); +etc. etc. + +In line 23 we use the class TDEABC::TimeZone to store the timezone. This class +takes the time shift in minutes. + +In line 27 the TDEABC::Geo class is used for storing the geographical +information. The arguments are the latitude and longitude as float values. + +TDEABC::Secrecy in line 37 represents the CLASS entity of a vCard and can take +TDEABC::Secrecy::Public, TDEABC::Secrecy::Private or TDEABC::Secrecy::Confidential +as argument. + +In line 41 we make use of TDEABC::Picture class to store the photo of the +contact. This class can contain either an URL or the raw image data in form +of a QImage, in this example we use the latter. + +In line 43 we try to load the image "face.png" from the local directory and +assign this QImage to the TDEABC::Picture class via the setData() function. +Additionally we set the type of the picture to "image/png". + +From 49 - 50 we insert 2 email addresses with the first one as preferred +(second argument is true). + +In 53 and the following 3 lines we add two telephone numbers. For this purpose +libkabc provides the TDEABC::PhoneNumber class, which takes the phone number in +string representation as first argument and the type as second. The types can +be combined, so 'TDEABC::PhoneNumber::Home | TDEABC::PhoneNumber::Fax' would be +the Home Fax. + +In line 59 we create a TDEABC::Address object and set the single parts in the +following lines. + +In line 67 we assign the contact to a special category. + +A contact can also contain custom entries, which are not specified in the API, +so you can add custom values with insertCustom() as shown in line 69. +The first argument of this function should be the name of the application, so +2 applications which use the same custom entry accidentally, do not overwrite +the data for each other. The second argument contains the name of the +custom entry and the third argument the value in string representation. + +In line 71 we finally insert the TDEABC::Addressee object into the +TDEABC::AddressBook. Since we have only one resource loaded, the contact is +automatically assigned to this resource. If you have several writeable +resources loaded, you should ask the user which resource the contact shall +belong to and assign the selected resource to the contact with + TDEABC::Addressee.setResource( TDEABC::Resource *resource ); +before inserting it into the address book. + +To prevent multiple access to one resource and possible resulting data loss +we have to lock the resource before saving our changes. +For this purpose TDEABC::AddressBook provides the function + requestSaveTicket( TDEABC::Resource* ) +which takes a pointer to the resource which shall be saved as argument and +returns a so called 'Save Ticket' if locking succeeded or a null pointer +if the resource is already locked by another application. + +So when we retrieved a valid ticket in line 74, we try to save our changes in +line 78. +The TDEABC::AddressBook::save() function takes the save ticket as argument and +returns whether saving succeeded. It also releases the save ticket when successful. + +Important! +If the save() call fails, you have to release the save ticket manually, as is +done in line 80, otherwise possible locks, created by the resources, won't be +removed. + +You can see also, that manual use is quite easy for the TDEABC::AddressBook class +and for the ResourceFile. For more information about the API of TDEABC::Addressee +please take a look at the official API documentation or the header files. + + +Distribution Lists +------------------- +libkabc provides so called distribution lists to group contacts. These lists +just store the uid of contacts, so they can be used for every kind of contact +grouping. There are 2 classes which handle the whole distribution list tasks, +TDEABC::DistributionListManager and TDEABC::DistributionList. The first one keeps +track of all available distribution lists and the latter one is the +representation of one list. + + + #include <tdeabc/distributionlist.h> + #include <tdeabc/stdaddressbook.h> + + 1: TDEABC::DistributionListManager manager( TDEABC::StdAddressBook::self() ); + 2: + 3: // load the lists + 4: manager.load(); + 5: + 6: QStringList listNames = manager.listNames(); + 7: QStringList::Iterator it; + 8: for ( it = listNames.begin(); it != listNames.end(); ++it ) { + 9: TDEABC::DistributionList *list = manager.list( *it ); +10: kdDebug() << list->name() << endl; +11: +12: QStringList emails = list->emails(); +13: QStringList::Iterator eit; +14: for ( eit = emails.begin(); eit != emails.end(); ++eit ) +15: kdDebug() << QString( "\t%1" ).arg( (*eit).latin1() ) << endl; +16: } + +In the first line a TDEABC::DistributionListManager is created. The manager takes +a pointer to a TDEABC::AddressBook, because he has to resolve the stored uids to +currently available email addresses. +In line 4 the manager loads all distribution lists from the central config file +$HOME/.trinity/share/apps/tdeabc/distlists. +The next line queries the names of all available distribution lists, which are +used in line 9 to retrieve a pointer to the specific list. +Now that you have a TDEABC::DistributionList object, you can performe the +following actions on it: + - set / get the name + - insert an entry + - remove an entry + - get a list of all email addresses + - get a list of all entries (which includes the uids) + +In line 12 we query all email addresses of every resource and print them out. + +<tdeabc/distributionlist.h> contains also the declaration for the class +TDEABC::DistributionListWatcher. This class exists only once per application and +its only job is to emit a signal as soon as the distribution list file has +changed. So to make your application aware of changes use the following code: + + + #include <tdeabc/distributionlist.h> + + 1: connect( TDEABC::DistributionListWatcher::self(), SIGNAL( changed() ), + 2: this, SLOT( slotDistributionListChanged() ) ); + +You see, as usual, easy ;) + diff --git a/tdeabc/Makefile.am b/tdeabc/Makefile.am new file mode 100644 index 000000000..a1f1d1b74 --- /dev/null +++ b/tdeabc/Makefile.am @@ -0,0 +1,72 @@ +SUBDIRS = vcard vcardparser . formats plugins scripts tests + +# Make sure $(all_includes) remains last! +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc -I$(top_srcdir)/kab \ + -I$(srcdir)/vcard/include -I$(srcdir)/vcardparser/ \ + -I$(srcdir)/vcard/include/generated \ + -I$(srcdir)/vcardparser $(all_includes) + +field.cpp: addressee.h addressee.cpp +addressee.cpp: addressee.h +addressee.cpp addressee.h field.cpp: \ + $(srcdir)/scripts/makeaddressee \ + $(srcdir)/scripts/addressee.src.cpp \ + $(srcdir)/scripts/addressee.src.h \ + $(srcdir)/scripts/entrylist \ + $(srcdir)/scripts/field.src.cpp + mysrcdir=`cd $(srcdir)/scripts && pwd` ;\ + cd scripts && $(PERL) $$mysrcdir/makeaddressee + +CLEANFILES = addressee.h addressee.cpp field.cpp + +lib_LTLIBRARIES = libtdeabc.la +libtdeabc_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 3:0:2 -no-undefined +libtdeabc_la_LIBADD = vcard/libvcard.la vcardparser/libvcards.la $(LIB_KIO) \ + $(top_builddir)/tderesources/libtderesources.la $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_TDEUI) $(LIB_TDECORE) +libtdeabc_la_COMPILE_FIRST = addressee.h + +libtdeabc_la_SOURCES = \ + address.cpp addressbook.cpp addressee.cpp addresseedialog.cpp agent.cpp \ + distributionlist.cpp distributionlistdialog.cpp distributionlisteditor.cpp \ + errorhandler.cpp field.cpp formatfactory.cpp geo.cpp key.cpp \ + phonenumber.cpp picture.cpp plugin.cpp resource.cpp \ + resourceselectdialog.cpp secrecy.cpp sound.cpp stdaddressbook.cpp \ + timezone.cpp vcard21parser.cpp vcardconverter.cpp vcardformat.cpp \ + vcardformatimpl.cpp vcardformatplugin.cpp ldifconverter.cpp addresslineedit.cpp \ + ldapclient.cpp addresseelist.cpp vcardtool.cpp addresseehelper.cpp \ + addresseehelper.skel lock.cpp locknull.cpp ldif.cpp ldapurl.cpp ldapconfigwidget.cpp \ + sortmode.cpp + + +tdeabcincludedir = $(includedir)/tdeabc +tdeabcinclude_HEADERS = address.h addressbook.h addressee.h addresseedialog.h \ + agent.h distributionlist.h distributionlistdialog.h distributionlisteditor.h \ + errorhandler.h field.h format.h formatfactory.h formatplugin.h geo.h key.h \ + phonenumber.h picture.h plugin.h resource.h \ + resourceselectdialog.h secrecy.h sound.h stdaddressbook.h timezone.h \ + vcardconverter.h vcardformat.h vcardformatplugin.h ldifconverter.h \ + addresslineedit.h ldapclient.h addresseelist.h lock.h locknull.h ldif.h \ + ldapurl.h ldapconfigwidget.h sortmode.h + +METASOURCES = AUTO + +bin_PROGRAMS = tdeab2tdeabc + +tdeab2tdeabc_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +tdeab2tdeabc_LDADD = libtdeabc.la ../kab/libkab.la +tdeab2tdeabc_SOURCES = tdeab2tdeabc.cpp + +autostart_DATA = tdeab2tdeabc.desktop +autostartdir = $(datadir)/autostart + +manager_DATA = tdeabc_manager.desktop +managerdir = $(kde_servicesdir)/tderesources + +DOXYGEN_REFERENCES = tdecore tdeui + +map_DATA = countrytransl.map +mapdir = $(kde_datadir)/tdeabc + +EXTRA_DIST = $(map_DATA) + +include ../admin/Doxyfile.am diff --git a/tdeabc/README b/tdeabc/README new file mode 100644 index 000000000..46d21b9b6 --- /dev/null +++ b/tdeabc/README @@ -0,0 +1,28 @@ +LIBKABC - new address book API for KDE + +PURPOSE: + +libkabc provides an API for address book data. This can be used by all KDE +application using data of this type, e.g. KAddressBook, KMail, KOrganizer, +KPilot etc. It is meant as replacement for libkab (in tdebase/kab). + +FEATURES: + +- Value based interface, addressbook entry data is implicitly shared. +- Address book entries are identified by a unique id. +- vCard backend (RFC 2425 / RFC 2426). +- Locking mechanism to support concurrent access to the address book by + multiple processes. +- Notification on change of addressbook by other process. +- Dialog for selecting address book entries, supports mouse and keyboard + selection, supports automatic name completion. +- GUI client for viewing, modifying address book data. This is aimed at + developers not end users. +- Tool for converting data, written with libkab, to libkabc format. +- Multiple backends (resources) for storing entries e.g. LDAP + +AUTHOR: Cornelius Schumacher <[email protected]> + +LICENCE: LPGL + +DATE: 13 Oct 2001 diff --git a/tdeabc/README.AddressFormat b/tdeabc/README.AddressFormat new file mode 100644 index 000000000..8079e4914 --- /dev/null +++ b/tdeabc/README.AddressFormat @@ -0,0 +1,66 @@ +Address formats can be a tricky thing. libkabc tries very hard to perfectly fit +the needs of ~95% of users and to be at least sufficient for the other 5%. + +The formatting of an address depends on the destination country as well as on +the origin country of a letter. Basically, the part indicating the destination +country follows the rules of the country of origin, all the rest follows the +rules of the destination country. So we need to store for every country a) the +country positioning and b) the address formatting. + +Address formats should usually be stored in a country's entry.desktop. There we +store the country position in field "AddressCountryPosition" and the address +format in a field "AddressFormat". Note that for most countries one field +"AddressFormat" is sufficient for personal as well as company addresses +(because personal addresses look just like business addresses without company); +however, in some countries (eg. Hungary) business addresses differ in their +structure. In this case you have the possibility of adding another field +"BusinessAddressFormat" which will be preferred for formatting of business +addresses; if libkabc can't find such a field, it will fall back to +"AddressFormat". (Please use BusinessAddressFormat ONLY if you really need to) + +The format consists mainly of tags that will be replaced by address fields. +The list of tags may grow in the future, the format *might* change in the near +future, but I hope not. + +Any comments very very welcome to [email protected] or to [email protected]. + +-Jost. + +Fields AddressFormat and BusinessAddressFormat +------------------------------------------------ +%n = real name +%N = REAL NAME +%cm = company +%CM = COMPANY +%s = street +%S = STREET +%z = zip code +%l = location +%L = LOCATION +%r = region +%R = REGION +%p = post office box +%, = conditional comma+whitespace, + will be left out if the value left or right of it is purged +%w = conditional whitespace, + will be left out if the value left or right of it is purged +%0(...) = the text inside the brackets will be completely purged if not + at least one tag inside it evaluates to something. Example: when the + address doesn't have a postbox, the string %0(PO Box %p) will not + evaluate to "PO Box " but to an empty string. +\n = newline + +Field AddressCountryPosition +------------------------------------------------ +below = country name below rest of address +BELOW = country name below in capital letters +above = country name above rest of address +ABOVE = country name above in capital letters + +Some Tips +------------------------------------------------ +- You sometimes have three fields in a line which can all be empty. If you eg. +separate them all with conditional whitespace (same goes for cond. comma) like +in "%z%w%r%w%l" and only the middle value (here: region) is empty, there will +be no whitespace at all between the outer values (here: zipcode and location). +To avoid this, combine two of these values with purge brackets: %0(%z%w%r)%w%l. diff --git a/tdeabc/TODO b/tdeabc/TODO new file mode 100644 index 000000000..13f75b6bb --- /dev/null +++ b/tdeabc/TODO @@ -0,0 +1 @@ +Factor out TDELockFile. diff --git a/tdeabc/address.cpp b/tdeabc/address.cpp new file mode 100644 index 000000000..e5305f5a0 --- /dev/null +++ b/tdeabc/address.cpp @@ -0,0 +1,592 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "address.h" + +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> +#include <kstaticdeleter.h> + +#include <tqfile.h> + +using namespace TDEABC; + +TQMap<TQString, TQString> *Address::mISOMap = 0; +static KStaticDeleter< TQMap<TQString, TQString> > isoMapDeleter; + +Address::Address() : + mEmpty( true ), mType( 0 ) +{ + mId = TDEApplication::randomString( 10 ); +} + +Address::Address( int type ) : + mEmpty( true ), mType( type ) +{ + mId = TDEApplication::randomString( 10 ); +} + +bool Address::operator==( const Address &a ) const +{ + if ( mPostOfficeBox != a.mPostOfficeBox ) return false; + if ( mExtended != a.mExtended ) return false; + if ( mStreet != a.mStreet ) return false; + if ( mLocality != a.mLocality ) return false; + if ( mRegion != a.mRegion ) return false; + if ( mPostalCode != a.mPostalCode ) return false; + if ( mCountry != a.mCountry ) return false; + if ( mLabel != a.mLabel ) return false; + + return true; +} + +bool Address::operator!=( const Address &a ) const +{ + return !( a == *this ); +} + +bool Address::isEmpty() const +{ + if ( mPostOfficeBox.isEmpty() && + mExtended.isEmpty() && + mStreet.isEmpty() && + mLocality.isEmpty() && + mRegion.isEmpty() && + mPostalCode.isEmpty() && + mCountry.isEmpty() && + mLabel.isEmpty() ) { + return true; + } + return false; +} + +void Address::clear() +{ + *this = Address(); +} + +void Address::setId( const TQString &id ) +{ + mEmpty = false; + + mId = id; +} + +TQString Address::id() const +{ + return mId; +} + +void Address::setType( int type ) +{ + mEmpty = false; + + mType = type; +} + +int Address::type() const +{ + return mType; +} + +TQString Address::typeLabel() const +{ + TQString label; + bool first = true; + + const TypeList list = typeList(); + + TypeList::ConstIterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { + label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); + if ( first ) + first = false; + } + } + + return label; +} + +void Address::setPostOfficeBox( const TQString &s ) +{ + mEmpty = false; + + mPostOfficeBox = s; +} + +TQString Address::postOfficeBox() const +{ + return mPostOfficeBox; +} + +TQString Address::postOfficeBoxLabel() +{ + return i18n("Post Office Box"); +} + + +void Address::setExtended( const TQString &s ) +{ + mEmpty = false; + + mExtended = s; +} + +TQString Address::extended() const +{ + return mExtended; +} + +TQString Address::extendedLabel() +{ + return i18n("Extended Address Information"); +} + + +void Address::setStreet( const TQString &s ) +{ + mEmpty = false; + + mStreet = s; +} + +TQString Address::street() const +{ + return mStreet; +} + +TQString Address::streetLabel() +{ + return i18n("Street"); +} + + +void Address::setLocality( const TQString &s ) +{ + mEmpty = false; + + mLocality = s; +} + +TQString Address::locality() const +{ + return mLocality; +} + +TQString Address::localityLabel() +{ + return i18n("Locality"); +} + + +void Address::setRegion( const TQString &s ) +{ + mEmpty = false; + + mRegion = s; +} + +TQString Address::region() const +{ + return mRegion; +} + +TQString Address::regionLabel() +{ + return i18n("Region"); +} + + +void Address::setPostalCode( const TQString &s ) +{ + mEmpty = false; + + mPostalCode = s; +} + +TQString Address::postalCode() const +{ + return mPostalCode; +} + +TQString Address::postalCodeLabel() +{ + return i18n("Postal Code"); +} + + +void Address::setCountry( const TQString &s ) +{ + mEmpty = false; + + mCountry = s; +} + +TQString Address::country() const +{ + return mCountry; +} + +TQString Address::countryLabel() +{ + return i18n("Country"); +} + + +void Address::setLabel( const TQString &s ) +{ + mEmpty = false; + + mLabel = s; +} + +TQString Address::label() const +{ + return mLabel; +} + +TQString Address::labelLabel() +{ + return i18n("Delivery Label"); +} + +Address::TypeList Address::typeList() +{ + static TypeList list; + + if ( list.isEmpty() ) + list << Dom << Intl << Postal << Parcel << Home << Work << Pref; + + return list; +} + +TQString Address::typeLabel( int type ) +{ + if ( type & Pref ) + return i18n( "Preferred address", "Preferred" ); + + switch ( type ) { + case Dom: + return i18n("Domestic"); + break; + case Intl: + return i18n("International"); + break; + case Postal: + return i18n("Postal"); + break; + case Parcel: + return i18n("Parcel"); + break; + case Home: + return i18n("Home Address", "Home"); + break; + case Work: + return i18n("Work Address", "Work"); + break; + case Pref: + return i18n("Preferred Address"); + break; + default: + return i18n("Other"); + break; + } +} + +void Address::dump() const +{ + kdDebug(5700) << " Address {" << endl; + kdDebug(5700) << " Id: " << id() << endl; + kdDebug(5700) << " Extended: " << extended() << endl; + kdDebug(5700) << " Street: " << street() << endl; + kdDebug(5700) << " Postal Code: " << postalCode() << endl; + kdDebug(5700) << " Locality: " << locality() << endl; + kdDebug(5700) << " }" << endl; +} + + +TQString Address::formattedAddress( const TQString &realName, + const TQString &orgaName ) const +{ + TQString ciso; + TQString addrTemplate; + TQString ret; + + // FIXME: first check for iso-country-field and prefer that one + if ( !country().isEmpty() ) { + ciso = countryToISO( country() ); + } else { + // fall back to our own country + ciso = TDEGlobal::locale()->country(); + } + KSimpleConfig entry( locate( "locale", + TQString( "l10n/" ) + ciso + TQString( "/entry.desktop" ) ) ); + entry.setGroup( "KCM Locale" ); + + // decide whether this needs special business address formatting + if ( orgaName.isEmpty() ) { + addrTemplate = entry.readEntry( "AddressFormat" ); + } else { + addrTemplate = entry.readEntry( "BusinessAddressFormat" ); + if ( addrTemplate.isEmpty() ) + addrTemplate = entry.readEntry( "AddressFormat" ); + } + + // in the case there's no format found at all, default to what we've always + // used: + if ( addrTemplate.isEmpty() ) { + kdWarning(5700) << "address format database incomplete " + << "(no format for locale " << ciso + << " found). Using default address formatting." << endl; + addrTemplate = "%0(%n\\n)%0(%cm\\n)%0(%s\\n)%0(PO BOX %p\\n)%0(%l%w%r)%,%z"; + } + + // scan + parseAddressTemplateSection( addrTemplate, ret, realName, orgaName ); + + // now add the country line if needed (formatting this time according to + // the rules of our own system country ) + if ( !country().isEmpty() ) { + KSimpleConfig entry( locate( "locale", TQString( "l10n/" ) + + TDEGlobal::locale()->country() + TQString( "/entry.desktop" ) ) ); + entry.setGroup( "KCM Locale" ); + TQString cpos = entry.readEntry( "AddressCountryPosition" ); + if ( "BELOW" == cpos || cpos.isEmpty() ) { + ret = ret + "\n\n" + country().upper(); + } else if ( "below" == cpos ) { + ret = ret + "\n\n" + country(); + } else if ( "ABOVE" == cpos ) { + ret = country().upper() + "\n\n" + ret; + } else if ( "above" == cpos ) { + ret = country() + "\n\n" + ret; + } + } + + return ret; +} + +bool Address::parseAddressTemplateSection( const TQString &tsection, + TQString &result, const TQString &realName, const TQString &orgaName ) const +{ + // This method first parses and substitutes any bracketed sections and + // after that replaces any tags with their values. If a bracketed section + // or a tag evaluate to zero, they are not just removed but replaced + // with a placeholder. This is because in the last step conditionals are + // resolved which depend on information about zero-evaluations. + result = tsection; + int stpos = 0; + bool ret = false; + + // first check for brackets that have to be evaluated first + int fpos = result.find( KABC_FMTTAG_purgeempty, stpos ); + while ( -1 != fpos ) { + int bpos1 = fpos + KABC_FMTTAG_purgeempty.length(); + int bpos2; + // expect opening bracket and find next balanced closing bracket. If + // next char is no opening bracket, continue parsing (no valid tag) + if ( '(' == result[bpos1] ) { + bpos2 = findBalancedBracket( result, bpos1 ); + if ( -1 != bpos2 ) { + // we have balanced brackets, recursively parse: + TQString rplstr; + bool purge = !parseAddressTemplateSection( result.mid( bpos1+1, + bpos2-bpos1-1 ), rplstr, + realName, orgaName ); + if ( purge ) { + // purge -> remove all + // replace with !_P_!, so conditional tags work later + result.replace( fpos, bpos2 - fpos + 1, "!_P_!" ); + // leave stpos as it is + } else { + // no purge -> replace with recursively parsed string + result.replace( fpos, bpos2 - fpos + 1, rplstr ); + ret = true; + stpos = fpos + rplstr.length(); + } + } else { + // unbalanced brackets: keep on parsing (should not happen + // and will result in bad formatting) + stpos = bpos1; + } + } + fpos = result.find( KABC_FMTTAG_purgeempty, stpos ); + } + + // after sorting out all purge tags, we just search'n'replace the rest, + // keeping track of whether at least one tag evaluates to something. + // The following macro needs TQString for R_FIELD + // It substitutes !_P_! for empty fields so conditional tags work later +#define REPLTAG(R_TAG,R_FIELD) \ + if ( result.find(R_TAG, false) != -1 ) { \ + TQString rpl = R_FIELD.isEmpty() ? TQString("!_P_!") : R_FIELD; \ + result.replace( R_TAG, rpl ); \ + if ( !R_FIELD.isEmpty() ) { \ + ret = true; \ + } \ + } + REPLTAG( KABC_FMTTAG_realname, realName ); + REPLTAG( KABC_FMTTAG_REALNAME, realName.upper() ); + REPLTAG( KABC_FMTTAG_company, orgaName ); + REPLTAG( KABC_FMTTAG_COMPANY, orgaName.upper() ); + REPLTAG( KABC_FMTTAG_pobox, postOfficeBox() ); + REPLTAG( KABC_FMTTAG_street, street() ); + REPLTAG( KABC_FMTTAG_STREET, street().upper() ); + REPLTAG( KABC_FMTTAG_zipcode, postalCode() ); + REPLTAG( KABC_FMTTAG_location, locality() ); + REPLTAG( KABC_FMTTAG_LOCATION, locality().upper() ); + REPLTAG( KABC_FMTTAG_region, region() ); + REPLTAG( KABC_FMTTAG_REGION, region().upper() ); + result.replace( KABC_FMTTAG_newline, "\n" ); +#undef REPLTAG + + // conditional comma + fpos = result.find( KABC_FMTTAG_condcomma, 0 ); + while ( -1 != fpos ) { + TQString str1 = result.mid( fpos - 5, 5 ); + TQString str2 = result.mid( fpos + 2, 5 ); + if ( str1 != "!_P_!" && str2 != "!_P_!" ) { + result.replace( fpos, 2, ", " ); + } else { + result.remove( fpos, 2 ); + } + fpos = result.find( KABC_FMTTAG_condcomma, fpos ); + } + // conditional whitespace + fpos = result.find( KABC_FMTTAG_condwhite, 0 ); + while ( -1 != fpos ) { + TQString str1 = result.mid( fpos - 5, 5 ); + TQString str2 = result.mid( fpos + 2, 5 ); + if ( str1 != "!_P_!" && str2 != "!_P_!" ) { + result.replace( fpos, 2, " " ); + } else { + result.remove( fpos, 2 ); + } + fpos = result.find( KABC_FMTTAG_condwhite, fpos ); + } + + // remove purged: + result.remove( "!_P_!" ); + + return ret; +} + +int Address::findBalancedBracket( const TQString &tsection, int pos ) const +{ + int balancecounter = 0; + for( unsigned int i = pos + 1; i < tsection.length(); i++ ) { + if ( ')' == tsection[i] && 0 == balancecounter ) { + // found end of brackets + return i; + } else + if ( '(' == tsection[i] ) { + // nested brackets + balancecounter++; + } + } + return -1; +} + +TQString Address::countryToISO( const TQString &cname ) +{ + // we search a map file for translations from country names to + // iso codes, storing caching things in a TQMap for faster future + // access. + if ( !mISOMap ) + isoMapDeleter.setObject( mISOMap, new TQMap<TQString, TQString>() ); + + TQMap<TQString, TQString>::ConstIterator it; + it = mISOMap->find( cname ); + if ( it != mISOMap->end() ) + return it.data(); + + TQString mapfile = TDEGlobal::dirs()->findResource( "data", + TQString::fromLatin1( "tdeabc/countrytransl.map" ) ); + + TQFile file( mapfile ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream s( &file ); + TQString strbuf = s.readLine(); + while( !strbuf.isEmpty() ) { + TQStringList countryInfo = TQStringList::split( '\t', strbuf, true ); + if ( countryInfo[ 0 ] == cname ) { + file.close(); + mISOMap->insert( cname, countryInfo[ 1 ] ); + return countryInfo[ 1 ]; + } + strbuf = s.readLine(); + } + file.close(); + } + + // fall back to system country + mISOMap->insert( cname, TDEGlobal::locale()->country() ); + return TDEGlobal::locale()->country(); +} + +TQString Address::ISOtoCountry( const TQString &ISOname ) +{ + // get country name from ISO country code (e.g. "no" -> i18n("Norway")) + if ( ISOname.simplifyWhiteSpace().isEmpty() ) + return TQString::null; + + TQString mapfile = TDEGlobal::dirs()->findResource( "data", + TQString::fromLatin1( "tdeabc/countrytransl.map" ) ); + + TQFile file( mapfile ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream s( &file ); + TQString searchStr = "\t" + ISOname.simplifyWhiteSpace().lower(); + TQString strbuf = s.readLine(); + int pos; + while ( !strbuf.isEmpty() ) { + if ( (pos = strbuf.find( searchStr )) != -1 ) { + file.close(); + return i18n( strbuf.left( pos ).utf8() ); + } + strbuf = s.readLine(); + } + file.close(); + } + + return ISOname; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Address &addr ) +{ + return s << addr.mId << addr.mType << addr.mPostOfficeBox << + addr.mExtended << addr.mStreet << addr.mLocality << + addr.mRegion << addr.mPostalCode << addr.mCountry << + addr.mLabel; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Address &addr ) +{ + s >> addr.mId >> addr.mType >> addr.mPostOfficeBox >> addr.mExtended >> + addr.mStreet >> addr.mLocality >> addr.mRegion >> + addr.mPostalCode >> addr.mCountry >> addr.mLabel; + + addr.mEmpty = false; + + return s; +} diff --git a/tdeabc/address.h b/tdeabc/address.h new file mode 100644 index 000000000..796be25a0 --- /dev/null +++ b/tdeabc/address.h @@ -0,0 +1,341 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESS_H +#define KABC_ADDRESS_H + +#include <tqmap.h> +#include <tqstring.h> +#include <tqvaluelist.h> + +#include <tdelibs_export.h> + +// template tags for address formatting localization +#define KABC_FMTTAG_realname TQString("%n") +#define KABC_FMTTAG_REALNAME TQString("%N") +#define KABC_FMTTAG_company TQString("%cm") +#define KABC_FMTTAG_COMPANY TQString("%CM") +#define KABC_FMTTAG_pobox TQString("%p") +#define KABC_FMTTAG_street TQString("%s") +#define KABC_FMTTAG_STREET TQString("%S") +#define KABC_FMTTAG_zipcode TQString("%z") +#define KABC_FMTTAG_location TQString("%l") +#define KABC_FMTTAG_LOCATION TQString("%L") +#define KABC_FMTTAG_region TQString("%r") +#define KABC_FMTTAG_REGION TQString("%R") +#define KABC_FMTTAG_newline TQString("\\n") +#define KABC_FMTTAG_condcomma TQString("%,") +#define KABC_FMTTAG_condwhite TQString("%w") +#define KABC_FMTTAG_purgeempty TQString("%0") + +namespace TDEABC { + +/** + @short Postal address information. + + This class represents information about a postal address. +*/ +class KABC_EXPORT Address +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Address & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Address & ); + + public: + /** + List of addresses. + */ + typedef TQValueList<Address> List; + typedef TQValueList<int> TypeList; + + /** + Address types: + + @li @p Dom - domestic + @li @p Intl - international + @li @p Postal - postal + @li @p Parcel - parcel + @li @p Home - home address + @li @p Work - address at work + @li @p Pref - preferred address + */ + enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, + Pref = 64 }; + + /** + Constructor that creates an empty Address, which is initialized + with a unique id (see id()). + */ + Address(); + + /** + This is like Address() just above, with the difference + that you can specify the type. + */ + Address( int ); + + bool operator==( const Address & ) const; + bool operator!=( const Address & ) const; + + /** + Returns true, if the address is empty. + */ + bool isEmpty() const; + + /** + Clears all entries of the address. + */ + void clear(); + + /** + Sets the unique id. + */ + void setId( const TQString & ); + + /* + Returns the unique id. + */ + TQString id() const; + + /** + Sets the type of address. See enum for definiton of types. + + @param type type, can be a bitwise or of multiple types. + */ + void setType( int type ); + + /** + Returns the type of address. Can be a bitwise or of multiple types. + */ + int type() const; + + /** + Returns a translated string of all types the address has. + */ + TQString typeLabel() const; + + /** + Sets the post office box. + */ + void setPostOfficeBox( const TQString & ); + + /** + Returns the post office box. + */ + TQString postOfficeBox() const; + + /** + Returns the translated label for post office box field. + */ + static TQString postOfficeBoxLabel(); + + /** + Sets the extended address information. + */ + void setExtended( const TQString & ); + + /** + Returns the extended address information. + */ + TQString extended() const; + + /** + Returns the translated label for extended field. + */ + static TQString extendedLabel(); + + /** + Sets the street (including number). + */ + void setStreet( const TQString & ); + + /** + Returns the street. + */ + TQString street() const; + + /** + Returns the translated label for street field. + */ + static TQString streetLabel(); + + /** + Sets the locality, e.g. city. + */ + void setLocality( const TQString & ); + + /** + Returns the locality. + */ + TQString locality() const; + + /** + Returns the translated label for locality field. + */ + static TQString localityLabel(); + + /** + Sets the region, e.g. state. + */ + void setRegion( const TQString & ); + + /** + Returns the region. + */ + TQString region() const; + + /** + Returns the translated label for region field. + */ + static TQString regionLabel(); + + /** + Sets the postal code. + */ + void setPostalCode( const TQString & ); + + /** + Returns the postal code. + */ + TQString postalCode() const; + + /** + Returns the translated label for postal code field. + */ + static TQString postalCodeLabel(); + + /** + Sets the country. + */ + void setCountry( const TQString & ); + + /** + Returns the country. + */ + TQString country() const; + + /** + Returns the translated label for country field. + */ + static TQString countryLabel(); + + /** + Sets the delivery label. This is the literal text to be used as label. + */ + void setLabel( const TQString & ); + + /** + Returns the delivery label. + */ + TQString label() const; + + /** + Returns the translated label for delivery label field. + */ + static TQString labelLabel(); + + /** + Returns the list of available types. + */ + static TypeList typeList(); + + /** + Returns the translated label for a special type. + */ + static TQString typeLabel( int type ); + + /** + Used for debug output. + */ + void dump() const; + + /** + Returns this address formatted according to the country-specific + address formatting rules. The formatting rules applied depend on + either the addresses {@link #country country} field, or (if the + latter is empty) on the system country setting. If companyName is + provided, an available business address format will be preferred. + + @param realName the formatted name of the contact + @param orgaName the name of the organization or company + @return the formatted address (containing newline characters) + */ + TQString formattedAddress( const TQString &realName=TQString::null + , const TQString &orgaName=TQString::null ) const; + + /** + Returns ISO code for a localized country name. Only localized country + names will be understood. This might be replaced by a TDELocale method in + the future. + @param cname name of the country + @return two digit ISO code + */ + static TQString countryToISO( const TQString &cname ); + + /** + Returns a localized country name for a ISO code. + This might be replaced by a TDELocale method in the future. + @param ISOname two digit ISO code + @return localized name of the country + @since 3.2 + */ + static TQString ISOtoCountry( const TQString &ISOname ); + + private: + /** + Parses a snippet of an address template + @param tsection the template string to be parsed + @param result TQString reference in which the result will be stored + @return true if at least one tag evaluated positively, else false + */ + bool parseAddressTemplateSection( const TQString &tsection + , TQString &result + , const TQString &realName + , const TQString &orgaName ) const; + + /** + Finds the balanced closing bracket starting from the opening bracket at + pos in tsection. + @return position of closing bracket, -1 for unbalanced brackets + */ + int findBalancedBracket( const TQString &tsection, int pos ) const; + + bool mEmpty; + + TQString mId; + int mType; + + TQString mPostOfficeBox; + TQString mExtended; + TQString mStreet; + TQString mLocality; + TQString mRegion; + TQString mPostalCode; + TQString mCountry; + TQString mLabel; + + static TQMap<TQString, TQString> *mISOMap; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Address & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Address & ); + +} + +#endif diff --git a/tdeabc/addressbook.cpp b/tdeabc/addressbook.cpp new file mode 100644 index 000000000..3a8a71f2b --- /dev/null +++ b/tdeabc/addressbook.cpp @@ -0,0 +1,842 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqfile.h> +#include <tqregexp.h> +#include <tqtimer.h> + +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <kinstance.h> +#include <tdelocale.h> +#include <kstandarddirs.h> + +#include "errorhandler.h" +#include "resource.h" + +#include "addressbook.h" +#include "addressbook.moc" + +using namespace TDEABC; + +struct AddressBook::AddressBookData +{ + Field::List mAllFields; + ErrorHandler *mErrorHandler; + TDEConfig *mConfig; + KRES::Manager<Resource> *mManager; + TQPtrList<Resource> mPendingLoadResources; + TQPtrList<Resource> mPendingSaveResources; + Iterator end; +}; + +struct AddressBook::Iterator::IteratorData +{ + Resource::Iterator mIt; + TQValueList<Resource*> mResources; + int mCurrRes; +}; + +struct AddressBook::ConstIterator::ConstIteratorData +{ + Resource::ConstIterator mIt; + TQValueList<Resource*> mResources; + int mCurrRes; +}; + +AddressBook::Iterator::Iterator() + : d( new IteratorData ) +{ +} + +AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) + : d( new IteratorData ) +{ + d->mIt = i.d->mIt; + d->mResources = i.d->mResources; + d->mCurrRes = i.d->mCurrRes; +} + +AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) +{ + if ( this == &i ) + return *this; // guard against self assignment + + delete d; // delete the old data the Iterator was completely constructed before + d = new IteratorData; + d->mIt = i.d->mIt; + d->mResources = i.d->mResources; + d->mCurrRes = i.d->mCurrRes; + + return *this; +} + +AddressBook::Iterator::~Iterator() +{ + delete d; + d = 0; +} + +const Addressee &AddressBook::Iterator::operator*() const +{ + return *(d->mIt); +} + +Addressee &AddressBook::Iterator::operator*() +{ + return *(d->mIt); +} + +Addressee *AddressBook::Iterator::operator->() +{ + return &(*(d->mIt)); +} + +AddressBook::Iterator &AddressBook::Iterator::operator++() +{ + do { + bool jumped = false; + while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource + if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) { + return *this; + } + + d->mCurrRes++; // jump to next resource + + jumped = true; + d->mIt = (d->mResources[ d->mCurrRes ])->begin(); + } + + if ( !jumped ) + (d->mIt)++; + + } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ); + + return *this; +} + +AddressBook::Iterator &AddressBook::Iterator::operator++( int ) +{ + do { + bool jumped = false; + while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource + if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) { + return *this; + } + + d->mCurrRes++; // jump to next resource + + jumped = true; + d->mIt = (d->mResources[ d->mCurrRes ])->begin(); + } + + if ( !jumped ) + (d->mIt)++; + + } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ); + + return *this; +} + +AddressBook::Iterator &AddressBook::Iterator::operator--() +{ + (d->mIt)--; + + return *this; +} + +AddressBook::Iterator &AddressBook::Iterator::operator--( int ) +{ + (d->mIt)--; + + return *this; +} + +bool AddressBook::Iterator::operator==( const Iterator &it ) +{ + return ( d->mIt == it.d->mIt ); +} + +bool AddressBook::Iterator::operator!=( const Iterator &it ) +{ + return ( d->mIt != it.d->mIt ); +} + + +AddressBook::ConstIterator::ConstIterator() + : d( new ConstIteratorData ) +{ +} + +AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) + : d( new ConstIteratorData ) +{ + d->mIt = i.d->mIt; + d->mResources = i.d->mResources; + d->mCurrRes = i.d->mCurrRes; +} + +AddressBook::ConstIterator::ConstIterator( const AddressBook::Iterator &i ) +{ + d = new ConstIteratorData; + d->mIt = i.d->mIt; + d->mResources = i.d->mResources; + d->mCurrRes = i.d->mCurrRes; +} + +AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) +{ + if ( this == &i ) + return *this; // guard for self assignment + + delete d; // delete the old data because the Iterator was really constructed before + d = new ConstIteratorData; + d->mIt = i.d->mIt; + d->mResources = i.d->mResources; + d->mCurrRes = i.d->mCurrRes; + + return *this; +} + +AddressBook::ConstIterator::~ConstIterator() +{ + delete d; + d = 0; +} + +const Addressee &AddressBook::ConstIterator::operator*() const +{ + return *(d->mIt); +} + +const Addressee* AddressBook::ConstIterator::operator->() const +{ + return &(*(d->mIt)); +} + +AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() +{ + do { + bool jumped = false; + while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource + if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) { + return *this; + } + + d->mCurrRes++; // jump to next resource + + jumped = true; + d->mIt = (d->mResources[ d->mCurrRes ])->begin(); + } + + if ( !jumped ) + (d->mIt)++; + + } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ); + + return *this; +} + +AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) +{ + do { + bool jumped = false; + while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource + if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) { + return *this; + } + + d->mCurrRes++; // jump to next resource + + jumped = true; + d->mIt = (d->mResources[ d->mCurrRes ])->begin(); + } + + if ( !jumped ) + (d->mIt)++; + + } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ); + + return *this; +} + +AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() +{ + (d->mIt)--; + return *this; +} + +AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) +{ + (d->mIt)--; + return *this; +} + +bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) +{ + return ( d->mIt == it.d->mIt ); +} + +bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) +{ + return ( d->mIt != it.d->mIt ); +} + + +AddressBook::AddressBook() + : d( new AddressBookData ) +{ + d->mErrorHandler = 0; + d->mConfig = 0; + d->mManager = new KRES::Manager<Resource>( "contact" ); + d->end.d->mResources = TQValueList<Resource*>(); + d->end.d->mCurrRes = -1; +} + +AddressBook::AddressBook( const TQString &config ) + : d( new AddressBookData ) +{ + d->mErrorHandler = 0; + if ( config.isEmpty() ) + d->mConfig = 0; + else + d->mConfig = new TDEConfig( config ); + d->mManager = new KRES::Manager<Resource>( "contact" ); + d->mManager->readConfig( d->mConfig ); + d->end.d->mResources = TQValueList<Resource*>(); + d->end.d->mCurrRes = -1; +} + +AddressBook::~AddressBook() +{ + delete d->mManager; d->mManager = 0; + delete d->mConfig; d->mConfig = 0; + delete d->mErrorHandler; d->mErrorHandler = 0; + delete d; d = 0; +} + +bool AddressBook::load() +{ + kdDebug(5700) << "AddressBook::load()" << endl; + + clear(); + + KRES::Manager<Resource>::ActiveIterator it; + bool ok = true; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + if ( !(*it)->load() ) { + error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); + ok = false; + } + } + + return ok; +} + +bool AddressBook::asyncLoad() +{ + kdDebug(5700) << "AddressBook::asyncLoad()" << endl; + + clear(); + + KRES::Manager<Resource>::ActiveIterator it; + bool ok = true; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + d->mPendingLoadResources.append( *it ); + if ( !(*it)->asyncLoad() ) { + error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); + ok = false; + } + } + + return ok; +} + +bool AddressBook::save( Ticket *ticket ) +{ + kdDebug(5700) << "AddressBook::save()"<< endl; + + if ( ticket->resource() ) { + deleteRemovedAddressees(); + bool ok = ticket->resource()->save( ticket ); + if ( ok ) ticket->resource()->releaseSaveTicket( ticket ); + return ok; + } + + return false; +} + +bool AddressBook::asyncSave( Ticket *ticket ) +{ + kdDebug(5700) << "AddressBook::asyncSave()"<< endl; + + if ( ticket->resource() ) { + d->mPendingSaveResources.append( ticket->resource() ); + bool ok = ticket->resource()->asyncSave( ticket ); + if ( ok ) ticket->resource()->releaseSaveTicket( ticket ); + return ok; + } + + return false; +} + +AddressBook::Iterator AddressBook::begin() +{ + TQValueList<Resource*> list; + KRES::Manager<Resource>::ActiveIterator resIt; + for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt ) + list.append( *resIt ); + + if ( list.count() == 0 ) + return end(); + + Iterator it = Iterator(); + it.d->mResources = list; + it.d->mCurrRes = 0; + it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin(); + + while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) { + if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 ) + return end(); + + it.d->mCurrRes++; + + it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin(); + } + + return it; +} + +AddressBook::ConstIterator AddressBook::begin() const +{ + TQValueList<Resource*> list; + KRES::Manager<Resource>::ActiveIterator resIt; + for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt ) + list.append( *resIt ); + + if ( list.count() == 0 ) + return end(); + + Iterator it = Iterator(); + it.d->mResources = list; + it.d->mCurrRes = 0; + it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin(); + + while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) { + if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 ) + return end(); + + it.d->mCurrRes++; + + it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin(); + } + + return it; +} + +AddressBook::Iterator AddressBook::end() +{ + KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd(); + + if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) { // no resource available + d->end.d->mIt = Resource::Iterator(); + } else { + d->end.d->mIt = (*resIt)->end(); + } + + return d->end; +} + +AddressBook::ConstIterator AddressBook::end() const +{ + KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd(); + + if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) { // no resource available + d->end.d->mIt = Resource::Iterator(); + } else { + d->end.d->mIt = (*resIt)->end(); + } + + return d->end; +} + +void AddressBook::clear() +{ + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) + (*it)->clear(); +} + +Ticket *AddressBook::requestSaveTicket( Resource *resource ) +{ + kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; + + if ( !resource ) + resource = standardResource(); + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + if ( (*it) == resource ) { + if ( (*it)->readOnly() || !(*it)->isOpen() ) + return 0; + else + return (*it)->requestSaveTicket(); + } + } + + return 0; +} + +void AddressBook::releaseSaveTicket( Ticket *ticket ) +{ + if ( !ticket ) + return; + + if ( ticket->resource() ) { + ticket->resource()->releaseSaveTicket( ticket ); + } +} + +void AddressBook::insertAddressee( const Addressee &a ) +{ + Resource *resource = a.resource(); + if ( resource == 0 ) + resource = standardResource(); + + Resource::Iterator it; + Addressee fAddr = resource->findByUid( a.uid() ); + + Addressee addr( a ); + if ( !fAddr.isEmpty() ) { + if ( fAddr != a ) + addr.setRevision( TQDateTime::currentDateTime() ); + else { + if ( fAddr.resource() == 0 ) { + fAddr.setResource( resource ); + //NOTE: Should we have setChanged( true ) here? + resource->insertAddressee( fAddr ); + } + return; + } + } + + addr.setResource( resource ); + addr.setChanged( true ); + resource->insertAddressee( addr ); +} + +void AddressBook::removeAddressee( const Addressee &a ) +{ + if ( a.resource() ) + a.resource()->removeAddressee( a ); +} + +void AddressBook::removeAddressee( const Iterator &it ) +{ + if ( (*it).resource() ) + (*it).resource()->removeAddressee( *it ); +} + +AddressBook::Iterator AddressBook::find( const Addressee &a ) +{ + Iterator it; + for ( it = begin(); it != end(); ++it ) { + if ( a.uid() == (*it).uid() ) + return it; + } + + return end(); +} + +Addressee AddressBook::findByUid( const TQString &uid ) +{ + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + Addressee addr = (*it)->findByUid( uid ); + if ( !addr.isEmpty() ) + return addr; + } + + return Addressee(); +} + +Addressee::List AddressBook::allAddressees() +{ + Addressee::List list; + + ConstIterator it; + for ( it = begin(); it != end(); ++it ) + list.append( *it ); + + return list; +} + +Addressee::List AddressBook::findByName( const TQString &name ) +{ + Addressee::List results; + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) + results += (*it)->findByName( name ); + + return results; +} + +Addressee::List AddressBook::findByEmail( const TQString &email ) +{ + Addressee::List results; + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) + results += (*it)->findByEmail( email ); + + return results; +} + +Addressee::List AddressBook::findByCategory( const TQString &category ) +{ + Addressee::List results; + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) + results += (*it)->findByCategory( category ); + + return results; +} + +void AddressBook::dump() const +{ + kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; + + ConstIterator it; + for( it = begin(); it != end(); ++it ) { + (*it).dump(); + } + + kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; +} + +TQString AddressBook::identifier() +{ + TQStringList identifier; + + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + if ( !(*it)->identifier().isEmpty() ) + identifier.append( (*it)->identifier() ); + } + + return identifier.join( ":" ); +} + +Field::List AddressBook::fields( int category ) +{ + if ( d->mAllFields.isEmpty() ) { + d->mAllFields = Field::allFields(); + } + + if ( category == Field::All ) return d->mAllFields; + + Field::List result; + Field::List::ConstIterator it; + for ( it = d->mAllFields.constBegin(); it != d->mAllFields.constEnd(); ++it ) { + if ( (*it)->category() & category ) + result.append( *it ); + } + + return result; +} + +bool AddressBook::addCustomField( const TQString &label, int category, + const TQString &key, const TQString &app ) +{ + if ( d->mAllFields.isEmpty() ) { + d->mAllFields = Field::allFields(); + } + + TQString a = app.isNull() ? TDEGlobal::instance()->instanceName() : app; + TQString k = key.isNull() ? label : key; + + Field *field = Field::createCustomField( label, category, k, a ); + + if ( !field ) return false; + + d->mAllFields.append( field ); + + return true; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const AddressBook &ab ) +{ + if (!ab.d) return s; + + return s;// << ab.d->mAddressees; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, AddressBook &ab ) +{ + if (!ab.d) return s; + +// s >> ab.d->mAddressees; + + return s; +} + +bool AddressBook::addResource( Resource *resource ) +{ + if ( !resource->open() ) { + kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; + return false; + } + + d->mManager->add( resource ); + resource->setAddressBook( this ); + + connect( resource, TQT_SIGNAL( loadingFinished( Resource* ) ), + this, TQT_SLOT( resourceLoadingFinished( Resource* ) ) ); + connect( resource, TQT_SIGNAL( savingFinished( Resource* ) ), + this, TQT_SLOT( resourceSavingFinished( Resource* ) ) ); + + connect( resource, TQT_SIGNAL( loadingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceLoadingError( Resource*, const TQString& ) ) ); + connect( resource, TQT_SIGNAL( savingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceSavingError( Resource*, const TQString& ) ) ); + + return true; +} + +bool AddressBook::removeResource( Resource *resource ) +{ + resource->close(); + + if ( resource == standardResource() ) + d->mManager->setStandardResource( 0 ); + + resource->setAddressBook( 0 ); + + disconnect( resource, TQT_SIGNAL( loadingFinished( Resource* ) ), + this, TQT_SLOT( resourceLoadingFinished( Resource* ) ) ); + disconnect( resource, TQT_SIGNAL( savingFinished( Resource* ) ), + this, TQT_SLOT( resourceSavingFinished( Resource* ) ) ); + + disconnect( resource, TQT_SIGNAL( loadingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceLoadingError( Resource*, const TQString& ) ) ); + disconnect( resource, TQT_SIGNAL( savingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceLoadingError( Resource*, const TQString& ) ) ); + + d->mManager->remove( resource ); + + return true; +} + +TQPtrList<Resource> AddressBook::resources() +{ + TQPtrList<Resource> list; + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { + if ( d->mManager->standardResource() == (*it) ) + list.prepend( *it ); + else + list.append( *it ); + } + + return list; +} + +void AddressBook::setErrorHandler( ErrorHandler *handler ) +{ + delete d->mErrorHandler; + d->mErrorHandler = handler; +} + +void AddressBook::error( const TQString& msg ) +{ + if ( !d->mErrorHandler ) // create default error handler + d->mErrorHandler = new ConsoleErrorHandler; + + if ( d->mErrorHandler ) + d->mErrorHandler->error( msg ); + else + kdError(5700) << "no error handler defined" << endl; +} + +void AddressBook::deleteRemovedAddressees() +{ + // no any longer needed +} + +void AddressBook::setStandardResource( Resource *resource ) +{ + d->mManager->setStandardResource( resource ); +} + +Resource *AddressBook::standardResource() +{ + return d->mManager->standardResource(); +} + +KRES::Manager<Resource> *AddressBook::resourceManager() +{ + return d->mManager; +} + +void AddressBook::cleanUp() +{ +} + +bool AddressBook::loadingHasFinished() const +{ + return d->mPendingLoadResources.isEmpty(); +} + +void AddressBook::resourceLoadingFinished( Resource *res ) +{ + d->mPendingLoadResources.remove( res ); + emit loadingFinished( res ); + + if ( d->mPendingLoadResources.count() == 0 ) + emit addressBookChanged( this ); +} + +void AddressBook::resourceSavingFinished( Resource *res ) +{ + d->mPendingSaveResources.remove( res ); + + emit savingFinished( res ); +} + +void AddressBook::resourceLoadingError( Resource *res, const TQString &errMsg ) +{ + error( errMsg ); + + d->mPendingLoadResources.remove( res ); + if ( d->mPendingLoadResources.count() == 0 ) + emit addressBookChanged( this ); +} + +void AddressBook::resourceSavingError( Resource *res, const TQString &errMsg ) +{ + error( errMsg ); + + d->mPendingSaveResources.remove( res ); +} diff --git a/tdeabc/addressbook.h b/tdeabc/addressbook.h new file mode 100644 index 000000000..09d18d6bb --- /dev/null +++ b/tdeabc/addressbook.h @@ -0,0 +1,431 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSBOOK_H +#define KABC_ADDRESSBOOK_H + +#include <tqobject.h> +#include <tqptrlist.h> + +#include <tderesources/manager.h> + +#include "addressee.h" +#include "field.h" + +namespace TDEABC { + +class ErrorHandler; +class Resource; +class Ticket; + +/** + @short Address Book + + This class provides access to a collection of address book entries. + */ +class KABC_EXPORT AddressBook : public TQObject +{ + Q_OBJECT + + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const AddressBook & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, AddressBook & ); + friend class StdAddressBook; + + public: + /** + @short Address Book Iterator + + This class provides an iterator for address book entries. + */ + class KABC_EXPORT Iterator + { + public: + Iterator(); + Iterator( const Iterator & ); + ~Iterator(); + + Iterator &operator=( const Iterator & ); + const Addressee &operator*() const; + Addressee &operator*(); + Addressee* operator->(); + Iterator &operator++(); + Iterator &operator++(int); + Iterator &operator--(); + Iterator &operator--(int); + bool operator==( const Iterator &it ); + bool operator!=( const Iterator &it ); + + struct IteratorData; + IteratorData *d; + }; + + /** + @short Address Book Const Iterator + + This class provides a const iterator for address book entries. + */ + class KABC_EXPORT ConstIterator + { + public: + ConstIterator(); + ConstIterator( const ConstIterator & ); + ConstIterator( const Iterator & ); + ~ConstIterator(); + + ConstIterator &operator=( const ConstIterator & ); + const Addressee &operator*() const; + const Addressee* operator->() const; + ConstIterator &operator++(); + ConstIterator &operator++(int); + ConstIterator &operator--(); + ConstIterator &operator--(int); + bool operator==( const ConstIterator &it ); + bool operator!=( const ConstIterator &it ); + + struct ConstIteratorData; + ConstIteratorData *d; + }; + + /** + Constructs an address book object. + You have to add the resources manually before calling load(). + */ + AddressBook(); + + /** + Constructs an address book object. + The resources are loaded automatically. + + @param config The config file which contains the resource settings. + */ + AddressBook( const TQString &config ); + + /** + Destructor. + */ + virtual ~AddressBook(); + + /** + Requests a ticket for saving the addressbook. Calling this function locks + the addressbook for all other processes. You need the returned ticket + object for calling the save() function. + + @param resource A pointer to the resource which shall be locked. If 0, + the default resource is locked. + @return 0 if the resource is already locked or a valid save ticket + otherwise. + @see save() + */ + Ticket *requestSaveTicket( Resource *resource = 0 ); + + /** + Releases the ticket requested previously with requestSaveTicket(). + Call this function, if you want to release a ticket without saving. + */ + void releaseSaveTicket( Ticket *ticket ); + + /** + Loads all addressees synchronously. + + @return Whether the loading was successfully. + */ + bool load(); + + /** + Loads all addressees asynchronously. This function returns immediately + and emits the addressBookChanged() signal as soon as the loading has + finished. + + @return Whether the synchronous part of loading was successfully. + */ + bool asyncLoad(); + + /** + Saves all addressees of one resource synchronously. If the save is + successfull the ticket is deleted. + + @param ticket The ticket returned by requestSaveTicket(). + @return Whether the saving was successfully. + */ + bool save( Ticket *ticket ); + + /** + Saves all addressees of one resource asynchronously. If the save is + successfull the ticket is deleted. + + @param ticket The ticket returned by requestSaveTicket(). + @return Whether the synchronous part of saving was successfully. + */ + bool asyncSave( Ticket *ticket ); + + /** + Returns an iterator pointing to the first addressee of address book. + This iterator equals end() if the address book is empty. + */ + ConstIterator begin() const; + + /** + This is an overloaded member function, provided for convenience. It + behaves essentially like the above function. + */ + Iterator begin(); + + /** + Returns an iterator pointing to the last addressee of address book. + This iterator equals begin() if the address book is empty. + */ + ConstIterator end() const; + + /** + This is an overloaded member function, provided for convenience. It + behaves essentially like the above function. + */ + Iterator end(); + + + /** + Removes all addressees from the address book. + */ + void clear(); + + /** + Insert an addressee into the address book. If an addressee with the same + unique id already exists, it is replaced by the new one, otherwise it is + appended. + + @param addr The addressee which shall be insert. + */ + void insertAddressee( const Addressee &addr ); + + /** + Removes an addressee from the address book. + + @param addr The addressee which shall be removed. + */ + void removeAddressee( const Addressee &addr ); + + /** + This is an overloaded member function, provided for convenience. It + behaves essentially like the above function. + + @param it An iterator pointing to the addressee which shall be removed. + */ + void removeAddressee( const Iterator &it ); + + /** + Returns an iterator pointing to the specified addressee. It will return + end() if no addressee matched. + + @param addr The addresee you are looking for. + */ + Iterator find( const Addressee &addr ); // KDE4: const + + /** + Searches an addressee with the specified unique identifier. + + @param uid The unique identifier you are looking for. + @return The addressee with the specified unique identifier or an + empty addressee. + */ + Addressee findByUid( const TQString &uid ); // KDE4: const + + /** + Returns a list of all addressees in the address book. + */ + Addressee::List allAddressees(); // KDE4: const + + /** + Searches all addressees which match the specified name. + + @param name The name you are looking for. + @return A list of all matching addressees. + */ + Addressee::List findByName( const TQString &name ); // KDE4: const + + /** + Searches all addressees which match the specified email address. + + @param email The email address you are looking for. + @return A list of all matching addressees. + */ + Addressee::List findByEmail( const TQString &email ); // KDE4: const + + /** + Searches all addressees which belongs to the specified category. + + @param category The category you are looking for. + @return A list of all matching addressees. + */ + Addressee::List findByCategory( const TQString &category ); // KDE4: const + + /** + Returns a string identifying this addressbook. The identifier is + created by concatenation of the resource identifiers. + */ + virtual TQString identifier(); // KDE4: const + + /** + Returns a list of all Fields known to the address book which are associated + with the given field category. + */ + Field::List fields( int category = Field::All ); // KDE4: const + + /** + Add custom field to address book. + + @param label User visible label of the field. + @param category Ored list of field categories. + @param key Identifier used as key for reading and writing the field. + @param app String used as application key for reading and writing + the field. + */ + bool addCustomField( const TQString &label, int category = Field::All, + const TQString &key = TQString::null, + const TQString &app = TQString::null ); + + /** + Adds a resource to the address book. + + @param resource The resource you want to add. + @return Whether opening the resource was successfully. + */ + bool addResource( Resource *resource ); + + /** + Removes a resource from the address book. + + @param resource The resource you want to remove. + @return Whether closing the resource was successfully. + */ + bool removeResource( Resource *resource ); + + /** + Returns a list of all resources. + */ + TQPtrList<Resource> resources(); // KDE4: const + + /** + Sets the @p ErrorHandler, that is used by error() to + provide GUI independent error messages. + + @param errorHandler The error handler you want to use. + */ + void setErrorHandler( ErrorHandler *errorHandler ); + + /** + Shows GUI independent error messages. + + @param msg The error message that shall be displayed. + */ + void error( const TQString &msg ); + + /** + @deprecated There is no need to call this function anymore. + */ + void cleanUp() KDE_DEPRECATED; + + /** + Used for debug output. This function prints out the list + of all addressees to kdDebug(5700). + */ + void dump() const; + + /** + */ + void emitAddressBookLocked() { emit addressBookLocked( this ); } + void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } + void emitAddressBookChanged() { emit addressBookChanged( this ); } + + /** + Returns true when the loading of the addressbook has finished, + otherwise false. + + @since 3.5 + */ + bool loadingHasFinished() const; + + signals: + /** + Emitted when one of the resources discovered a change in its backend + or the asynchronous loading of all resources has finished. + You should connect to this signal to update the presentation of + the contact data in your application. + + @param addressBook The address book which emitted this signal. + */ + void addressBookChanged( AddressBook *addressBook ); + + /** + Emitted when one of the resources has been locked for writing. + + @param addressBook The address book which emitted this signal. + */ + void addressBookLocked( AddressBook *addressBook ); + + /** + Emitted when one of the resources has been unlocked. + You should connect to this signal if you want to save your changes + to a resource which is currently locked, and want to get notified when + saving is possible again. + + @param addressBook The address book which emitted this signal. + */ + void addressBookUnlocked( AddressBook *addressBook ); + + /** + Emitted when the asynchronous loading of one resource has finished + after calling asyncLoad(). + + @param resource The resource which emitted this signal. + */ + void loadingFinished( Resource *resource ); + + /** + Emitted when the asynchronous saving of one resource has finished + after calling asyncSave(). + + @param resource The resource which emitted this signal. + */ + void savingFinished( Resource *resource ); + + protected slots: + void resourceLoadingFinished( Resource* ); + void resourceSavingFinished( Resource* ); + void resourceLoadingError( Resource*, const TQString& ); + void resourceSavingError( Resource*, const TQString& ); + + protected: + void deleteRemovedAddressees(); + void setStandardResource( Resource* ); + Resource *standardResource(); + KRES::Manager<Resource> *resourceManager(); + + private: + TQPtrList<Resource> mDummy; // Remove in KDE 4 + struct AddressBookData; + AddressBookData *d; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const AddressBook & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, AddressBook & ); + +} + +#endif diff --git a/tdeabc/addresseedialog.cpp b/tdeabc/addresseedialog.cpp new file mode 100644 index 000000000..028d178b0 --- /dev/null +++ b/tdeabc/addresseedialog.cpp @@ -0,0 +1,259 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqgroupbox.h> +#include <tqregexp.h> + +#include <tdelocale.h> +#include <kdebug.h> + +#include "stdaddressbook.h" + +#include "addresseedialog.h" +#include "addresseedialog.moc" + +using namespace TDEABC; + +AddresseeItem::AddresseeItem( TQListView *parent, const Addressee &addressee ) : + TQListViewItem( parent ), + mAddressee( addressee ) +{ + setText( Name, addressee.realName() ); + setText( Email, addressee.preferredEmail() ); +} + +TQString AddresseeItem::key( int column, bool ) const +{ + if (column == Email) { + TQString value = text(Email); + TQRegExp emailRe("<\\S*>"); + int match = emailRe.search(value); + if (match > -1) + value = value.mid(match + 1, emailRe.matchedLength() - 2); + + return value.lower(); + } + + return text(column).lower(); +} + +AddresseeDialog::AddresseeDialog( TQWidget *parent, bool multiple ) : + KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), + Ok|Cancel, Ok, parent ), mMultiple( multiple ) +{ + TQWidget *topWidget = plainPage(); + + TQBoxLayout *topLayout = new TQHBoxLayout( topWidget ); + TQBoxLayout *listLayout = new TQVBoxLayout; + topLayout->addLayout( listLayout ); + + mAddresseeList = new TDEListView( topWidget ); + mAddresseeList->addColumn( i18n("Name") ); + mAddresseeList->addColumn( i18n("Email") ); + mAddresseeList->setAllColumnsShowFocus( true ); + mAddresseeList->setFullWidth( true ); + listLayout->addWidget( mAddresseeList ); + connect( mAddresseeList, TQT_SIGNAL( doubleClicked( TQListViewItem * ) ), + TQT_SLOT( slotOk() ) ); + connect( mAddresseeList, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), + TQT_SLOT( updateEdit( TQListViewItem * ) ) ); + + mAddresseeEdit = new KLineEdit( topWidget ); + mAddresseeEdit->setCompletionMode( TDEGlobalSettings::CompletionAuto ); + connect( mAddresseeEdit->completionObject(), TQT_SIGNAL( match( const TQString & ) ), + TQT_SLOT( selectItem( const TQString & ) ) ); + mAddresseeEdit->setFocus(); + mAddresseeEdit->completionObject()->setIgnoreCase( true ); + listLayout->addWidget( mAddresseeEdit ); + + setInitialSize( TQSize( 450, 300 ) ); + + if ( mMultiple ) { + TQBoxLayout *selectedLayout = new TQVBoxLayout; + topLayout->addLayout( selectedLayout ); + topLayout->setSpacing( spacingHint() ); + + TQGroupBox *selectedGroup = new TQGroupBox( 1, Qt::Horizontal, i18n("Selected"), + topWidget ); + selectedLayout->addWidget( selectedGroup ); + + mSelectedList = new TDEListView( selectedGroup ); + mSelectedList->addColumn( i18n("Name") ); + mSelectedList->addColumn( i18n("Email") ); + mSelectedList->setAllColumnsShowFocus( true ); + mSelectedList->setFullWidth( true ); + connect( mSelectedList, TQT_SIGNAL( doubleClicked( TQListViewItem * ) ), + TQT_SLOT( removeSelected() ) ); + + TQPushButton *unselectButton = new TQPushButton( i18n("Unselect"), selectedGroup ); + connect ( unselectButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeSelected() ) ); + + connect( mAddresseeList, TQT_SIGNAL( clicked( TQListViewItem * ) ), + TQT_SLOT( addSelected( TQListViewItem * ) ) ); + + setInitialSize( TQSize( 650, 350 ) ); + } + + mAddressBook = StdAddressBook::self( true ); + connect( mAddressBook, TQT_SIGNAL( addressBookChanged( AddressBook* ) ), + TQT_SLOT( addressBookChanged() ) ); + connect( mAddressBook, TQT_SIGNAL( loadingFinished( Resource* ) ), + TQT_SLOT( addressBookChanged() ) ); + + loadAddressBook(); +} + +AddresseeDialog::~AddresseeDialog() +{ +} + +void AddresseeDialog::loadAddressBook() +{ + mAddresseeList->clear(); + mItemDict.clear(); + mAddresseeEdit->completionObject()->clear(); + + AddressBook::Iterator it; + for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); + addCompletionItem( (*it).realName(), item ); + addCompletionItem( (*it).preferredEmail(), item ); + } +} + +void AddresseeDialog::addCompletionItem( const TQString &str, TQListViewItem *item ) +{ + if ( str.isEmpty() ) return; + + mItemDict.insert( str, item ); + mAddresseeEdit->completionObject()->addItem( str ); +} + +void AddresseeDialog::selectItem( const TQString &str ) +{ + if ( str.isEmpty() ) return; + + TQListViewItem *item = mItemDict.find( str ); + if ( item ) { + mAddresseeList->blockSignals( true ); + mAddresseeList->setSelected( item, true ); + mAddresseeList->ensureItemVisible( item ); + mAddresseeList->blockSignals( false ); + } +} + +void AddresseeDialog::updateEdit( TQListViewItem *item ) +{ + mAddresseeEdit->setText( item->text( 0 ) ); + mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); +} + +void AddresseeDialog::addSelected( TQListViewItem *item ) +{ + AddresseeItem *addrItem = dynamic_cast<AddresseeItem *>( item ); + if ( !addrItem ) return; + + Addressee a = addrItem->addressee(); + + TQListViewItem *selectedItem = mSelectedDict.find( a.uid() ); + if ( !selectedItem ) { + selectedItem = new AddresseeItem( mSelectedList, a ); + mSelectedDict.insert( a.uid(), selectedItem ); + } +} + +void AddresseeDialog::removeSelected() +{ + TQListViewItem *item = mSelectedList->selectedItem(); + AddresseeItem *addrItem = dynamic_cast<AddresseeItem *>( item ); + if ( !addrItem ) return; + + mSelectedDict.remove( addrItem->addressee().uid() ); + delete addrItem; +} + +Addressee AddresseeDialog::addressee() +{ + AddresseeItem *aItem = 0; + + if ( mMultiple ) + aItem = dynamic_cast<AddresseeItem *>( mSelectedList->firstChild() ); + else + aItem = dynamic_cast<AddresseeItem *>( mAddresseeList->selectedItem() ); + + if (aItem) return aItem->addressee(); + return Addressee(); +} + +Addressee::List AddresseeDialog::addressees() +{ + Addressee::List al; + AddresseeItem *aItem = 0; + + if ( mMultiple ) { + TQListViewItem *item = mSelectedList->firstChild(); + while( item ) { + aItem = dynamic_cast<AddresseeItem *>( item ); + if ( aItem ) al.append( aItem->addressee() ); + item = item->nextSibling(); + } + } + else + { + aItem = dynamic_cast<AddresseeItem *>( mAddresseeList->selectedItem() ); + if (aItem) al.append( aItem->addressee() ); + } + + return al; +} + +Addressee AddresseeDialog::getAddressee( TQWidget *parent ) +{ + AddresseeDialog *dlg = new AddresseeDialog( parent ); + Addressee addressee; + int result = dlg->exec(); + + if ( result == TQDialog::Accepted ) { + addressee = dlg->addressee(); + } + + delete dlg; + return addressee; +} + +Addressee::List AddresseeDialog::getAddressees( TQWidget *parent ) +{ + AddresseeDialog *dlg = new AddresseeDialog( parent, true ); + Addressee::List addressees; + int result = dlg->exec(); + if ( result == TQDialog::Accepted ) { + addressees = dlg->addressees(); + } + + delete dlg; + return addressees; +} + +void AddresseeDialog::addressBookChanged() +{ + loadAddressBook(); +} diff --git a/tdeabc/addresseedialog.h b/tdeabc/addresseedialog.h new file mode 100644 index 000000000..718aa61da --- /dev/null +++ b/tdeabc/addresseedialog.h @@ -0,0 +1,161 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSEEDIALOG_H +#define KABC_ADDRESSEEDIALOG_H + +#include <tqdict.h> + +#include <kdialogbase.h> +#include <klineedit.h> +#include <tdelistview.h> + +#include "addressbook.h" + +namespace TDEABC { + +/** + @short Special ListViewItem, that is used by the AddresseeDialog. +*/ +class KABC_EXPORT AddresseeItem : public TQListViewItem +{ + public: + + /** + Type of column + @li @p Name - Name in Addressee + @li @p Email - Email in Addressee + */ + enum columns { Name = 0, Email = 1 }; + + /** + Constructor. + + @param parent The parent listview. + @param addressee The associated addressee. + */ + AddresseeItem( TQListView *parent, const Addressee &addressee ); + + /** + Returns the addressee. + */ + Addressee addressee() const { return mAddressee; } + + /** + Method used by TQListView to sort the items. + */ + virtual TQString key( int column, bool ascending ) const; + + private: + Addressee mAddressee; +}; + +/** + @short Dialog for selecting address book entries. + + This class provides a dialog for selecting entries from the standard KDE + address book. Use the getAddressee() function to open a modal dialog, + returning an address book entry. + + In the dialog you can select an entry from the list with the mouse or type in + the first letters of the name or email address you are searching for. The + entry matching best is automatically selected. Use double click, pressing + return or pressing the ok button to return the selected addressee to the + application. +*/ +class KABC_EXPORT AddresseeDialog : public KDialogBase +{ + Q_OBJECT + + public: + /** + Construct addressbook entry select dialog. + + @param parent parent widget + @param multiple if true, indicates a multiple selection. + */ + AddresseeDialog( TQWidget *parent=0, bool multiple=false ); + + /** + Destructor. + */ + virtual ~AddresseeDialog(); + + /** + Return the address chosen. + + If it is a multiple select, this will return only the first address chosen + */ + Addressee addressee(); + + /** + Return the list of addresses chosen + */ + Addressee::List addressees(); + + /** + Select a single address book entry. + + Open addressee select dialog and return the entry selected by the user. + If the user doesn't select an entry or presses cancel, the returned + addressee is empty. + */ + static Addressee getAddressee( TQWidget *parent ); + + /** + Select multiple address book entries. + + Open addressee select dialog and return the entries selected by the user. + If the user doesn't select an entry or presses cancel, the returned + addressee list is empty. + */ + static Addressee::List getAddressees( TQWidget *parent ); + + private slots: + void selectItem( const TQString & ); + void updateEdit( TQListViewItem *item ); + void addSelected( TQListViewItem *item ); + void removeSelected(); + + protected slots: + void addressBookChanged(); + + private: + void loadAddressBook(); + void addCompletionItem( const TQString &str, TQListViewItem *item ); + + bool mMultiple; + + TDEListView *mAddresseeList; + KLineEdit *mAddresseeEdit; + + TDEListView *mSelectedList; + + AddressBook *mAddressBook; + + TQDict<TQListViewItem> mItemDict; + TQDict<TQListViewItem> mSelectedDict; + + class AddresseeDialogPrivate; + AddresseeDialogPrivate *d; +}; + +} +#endif diff --git a/tdeabc/addresseehelper.cpp b/tdeabc/addresseehelper.cpp new file mode 100644 index 000000000..f752788dd --- /dev/null +++ b/tdeabc/addresseehelper.cpp @@ -0,0 +1,111 @@ +/* + This file is part of the KDE libraries + Copyright (C) 2003 Carsten Pfeiffer <[email protected]> + + 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, version 2. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqapplication.h> + +#include <tdeconfig.h> +#include <tdelocale.h> + +#include "addresseehelper.h" + +using namespace TDEABC; + +AddresseeHelper * AddresseeHelper::s_self; + +// static +AddresseeHelper *AddresseeHelper::self() +{ + if ( !s_self ) + s_self = new AddresseeHelper(); + + return s_self; +} + +AddresseeHelper::AddresseeHelper() + : TQObject( tqApp ), + DCOPObject( "TDEABC::AddresseeHelper" ) +{ + initSettings(); + + connectDCOPSignal( "kaddressbook", "TDEABC::AddressBookConfig", + "changed()", "initSettings()", false ); +} + +// static +void AddresseeHelper::addToSet( const TQStringList& list, + std::set<TQString>& container ) +{ + TQStringList::ConstIterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( !(*it).isEmpty() ) + container.insert( *it ); + } +} + +void AddresseeHelper::initSettings() +{ + mTitles.clear(); + mSuffixes.clear(); + mPrefixes.clear(); + + mTitles.insert( i18n( "Dr." ) ); + mTitles.insert( i18n( "Miss" ) ); + mTitles.insert( i18n( "Mr." ) ); + mTitles.insert( i18n( "Mrs." ) ); + mTitles.insert( i18n( "Ms." ) ); + mTitles.insert( i18n( "Prof." ) ); + + mSuffixes.insert( i18n( "I" ) ); + mSuffixes.insert( i18n( "II" ) ); + mSuffixes.insert( i18n( "III" ) ); + mSuffixes.insert( i18n( "Jr." ) ); + mSuffixes.insert( i18n( "Sr." ) ); + + mPrefixes.insert( "van" ); + mPrefixes.insert( "von" ); + mPrefixes.insert( "de" ); + + TDEConfig config( "kabcrc", true, false ); // readonly, no kdeglobals + config.setGroup( "General" ); + + addToSet( config.readListEntry( "Prefixes" ), mTitles ); + addToSet( config.readListEntry( "Inclusions" ), mPrefixes ); + addToSet( config.readListEntry( "Suffixes" ), mSuffixes ); + mTradeAsFamilyName = config.readBoolEntry( "TradeAsFamilyName", true ); +} + +bool AddresseeHelper::containsTitle( const TQString& title ) const +{ + return mTitles.find( title ) != mTitles.end(); +} + +bool AddresseeHelper::containsPrefix( const TQString& prefix ) const +{ + return mPrefixes.find( prefix ) != mPrefixes.end(); +} + +bool AddresseeHelper::containsSuffix( const TQString& suffix ) const +{ + return mSuffixes.find( suffix ) != mSuffixes.end(); +} + +bool AddresseeHelper::tradeAsFamilyName() const +{ + return mTradeAsFamilyName; +} diff --git a/tdeabc/addresseehelper.h b/tdeabc/addresseehelper.h new file mode 100644 index 000000000..30617b72b --- /dev/null +++ b/tdeabc/addresseehelper.h @@ -0,0 +1,66 @@ +/* + This file is part of the KDE libraries + Copyright (C) 2003 Carsten Pfeiffer <[email protected]> + + 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, version 2. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSEEHELPER_H +#define KABC_ADDRESSEEHELPER_H + +#include <tqobject.h> +#include <tqstringlist.h> + +#include <dcopobject.h> + +#include <set> + +/** + static data, shared by ALL addressee objects +*/ + +namespace TDEABC { + +class KABC_EXPORT AddresseeHelper : public TQObject, public DCOPObject +{ + K_DCOP + + public: + static AddresseeHelper *self(); + + bool containsTitle( const TQString& title ) const; + bool containsPrefix( const TQString& prefix ) const; + bool containsSuffix( const TQString& suffix ) const; + bool tradeAsFamilyName() const; + + k_dcop: + ASYNC initSettings(); + + private: + AddresseeHelper(); + + static void addToSet( const TQStringList& list, + std::set<TQString>& container ); + std::set<TQString> mTitles; + std::set<TQString> mPrefixes; + std::set<TQString> mSuffixes; + bool mTradeAsFamilyName; + + static AddresseeHelper *s_self; +}; + +} + +#endif diff --git a/tdeabc/addresseelist.cpp b/tdeabc/addresseelist.cpp new file mode 100644 index 000000000..4787c65aa --- /dev/null +++ b/tdeabc/addresseelist.cpp @@ -0,0 +1,256 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Jost Schenck <[email protected]> + 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> + +#include "addresseelist.h" + +#include "field.h" +#include "sortmode.h" + +using namespace TDEABC; + +// +// +// Traits +// +// + +bool SortingTraits::Uid::eq( const Addressee &a1, const Addressee &a2 ) +{ + // locale awareness doesn't make sense sorting ids + return ( TQString::compare( a1.uid(), a2.uid() ) == 0 ); +} + +bool SortingTraits::Uid::lt( const Addressee &a1, const Addressee &a2 ) +{ + // locale awareness doesn't make sense sorting ids + return ( TQString::compare( a1.uid(), a2.uid() ) < 0 ); +} + +bool SortingTraits::Name::eq( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.name(), a2.name() ) == 0 ); +} + +bool SortingTraits::Name::lt( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.name(), a2.name() ) < 0 ); +} + +bool SortingTraits::FormattedName::eq( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.formattedName(), a2.formattedName() ) == 0 ); +} + +bool SortingTraits::FormattedName::lt( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.formattedName(), a2.formattedName() ) < 0 ); +} + +bool SortingTraits::FamilyName::eq( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) == 0 + && TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) == 0 ); +} + +bool SortingTraits::FamilyName::lt( const Addressee &a1, const Addressee &a2 ) +{ + int family = TQString::localeAwareCompare( a1.familyName(), a2.familyName() ); + if ( 0 == family ) { + return ( TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) < 0 ); + } else { + return family < 0; + } +} + +bool SortingTraits::GivenName::eq( const Addressee &a1, const Addressee &a2 ) +{ + return ( TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) == 0 + && TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) == 0 ); +} + +bool SortingTraits::GivenName::lt( const Addressee &a1, const Addressee &a2 ) +{ + int given = TQString::localeAwareCompare( a1.givenName(), a2.givenName() ); + if ( 0 == given ) { + return ( TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) < 0 ); + } else { + return given < 0; + } +} + +// +// +// AddresseeList +// +// + +static Field *sActiveField=0; + +AddresseeList::AddresseeList() + : TQValueList<Addressee>() +{ + mReverseSorting = false; + mActiveSortingCriterion = FormattedName; +} + +AddresseeList::~AddresseeList() +{ +} + +AddresseeList::AddresseeList( const AddresseeList &l ) + : TQValueList<Addressee>( l ) +{ + mReverseSorting = l.reverseSorting(); + mActiveSortingCriterion = l.sortingCriterion(); +} + +AddresseeList::AddresseeList( const TQValueList<Addressee> &l ) + : TQValueList<Addressee>( l ) +{ + mReverseSorting = false; +} + +void AddresseeList::dump() const +{ + kdDebug(5700) << "AddresseeList {" << endl; + kdDebug(5700) << "reverse order: " << ( mReverseSorting ? "true" : "false" ) << endl; + + TQString crit; + if ( Uid == mActiveSortingCriterion ) { + crit = "Uid"; + } else if ( Name == mActiveSortingCriterion ) { + crit = "Name"; + } else if ( FormattedName == mActiveSortingCriterion ) { + crit = "FormattedName"; + } else if ( FamilyName == mActiveSortingCriterion ) { + crit = "FamilyName"; + } else if ( GivenName == mActiveSortingCriterion ) { + crit = "GivenName"; + } else { + crit = "unknown -- update dump method"; + } + + kdDebug(5700) << "sorting criterion: " << crit << endl; + + for ( const_iterator it = begin(); it != end(); ++it ) { + (*it).dump(); + } + + kdDebug(5700) << "}" << endl; +} + +void AddresseeList::sortBy( SortingCriterion c ) +{ + mActiveSortingCriterion = c; + if ( Uid == c ) { + sortByTrait<SortingTraits::Uid>(); + } else if ( Name == c ) { + sortByTrait<SortingTraits::Name>(); + } else if ( FormattedName == c ) { + sortByTrait<SortingTraits::FormattedName>(); + } else if ( FamilyName == c ) { + sortByTrait<SortingTraits::FamilyName>(); + } else if ( GivenName==c ) { + sortByTrait<SortingTraits::GivenName>(); + } else { + kdError(5700) << "AddresseeList sorting criterion passed for which a trait is not known. No sorting done." << endl; + } +} + +void AddresseeList::sort() +{ + sortBy( mActiveSortingCriterion ); +} + +template<class Trait> +void AddresseeList::sortByTrait() +{ + // FIXME: better sorting algorithm, bubblesort is not acceptable for larger lists. + // + // for i := 1 to n - 1 + // do for j := 1 to n - i + // do if A[j] > A[j+1] + // then temp := A[j] + // A[j] := A[j + 1] + // A[j + 1 ] := temp + + iterator i1 = begin(); + iterator endIt = end(); + --endIt; + if ( i1 == endIt ) // don't need sorting + return; + + iterator i2 = endIt; + while( i1 != endIt ) { + iterator j1 = begin(); + iterator j2 = j1; + ++j2; + while( j1 != i2 ) { + if ( !mReverseSorting && Trait::lt( *j2, *j1 ) + || mReverseSorting && Trait::lt( *j1, *j2 ) ) { + tqSwap( *j1, *j2 ); + } + ++j1; + ++j2; + } + ++i1; + --i2; + } +} + +void AddresseeList::sortByField( Field *field ) +{ + if ( !field ) { + kdWarning(5700) << "sortByField called with no active sort field" << endl; + return; + } + + sActiveField = field; + + if ( count() == 0 ) + return; + + TDEABC::FieldSortMode *mode = new TDEABC::FieldSortMode( sActiveField, !mReverseSorting ); + + TDEABC::Addressee::setSortMode( mode ); + qHeapSort( *this ); + TDEABC::Addressee::setSortMode( 0 ); + + delete mode; +} + +void AddresseeList::sortByMode( SortMode *mode ) +{ + if ( count() == 0 ) + return; + + TDEABC::Addressee::setSortMode( mode ); + qHeapSort( *this ); + TDEABC::Addressee::setSortMode( 0 ); +} + +Field* +AddresseeList::sortingField() const +{ + return sActiveField; +} diff --git a/tdeabc/addresseelist.h b/tdeabc/addresseelist.h new file mode 100644 index 000000000..bebe0a460 --- /dev/null +++ b/tdeabc/addresseelist.h @@ -0,0 +1,221 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Jost Schenck <[email protected]> + 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSEELIST_H +#define KABC_ADDRESSEELIST_H + +#include <tqvaluelist.h> + +#include "addressee.h" + +namespace TDEABC { + +class Field; +class SortField; +class SortMode; + +/** + * Each trait must implement one static function for equality, one for "less + * than". Class name should be the field name. A trait does not necessarily + * have to stick to just one field: a trait sorting by family name can e.g. + * sort addressees with equal family name by given name. + * + * If you want to implement reverse sorting, you do not have to write another + * trait, as AddresseeList takes care of that. + */ +namespace SortingTraits +{ + +class KABC_EXPORT Uid +{ + public: + static bool eq( const Addressee &, const Addressee & ); + static bool lt( const Addressee &, const Addressee & ); +}; + +class KABC_EXPORT Name +{ + public: + static bool eq( const Addressee &, const Addressee & ); + static bool lt( const Addressee &, const Addressee & ); +}; + +class KABC_EXPORT FormattedName +{ + public: + static bool eq( const Addressee &, const Addressee & ); + static bool lt( const Addressee &, const Addressee & ); +}; + +class KABC_EXPORT FamilyName // fallback to given name +{ + public: + static bool eq( const Addressee &, const Addressee & ); + static bool lt( const Addressee &, const Addressee & ); +}; + +class KABC_EXPORT GivenName // fallback to family name +{ + public: + static bool eq( const Addressee &, const Addressee & ); + static bool lt( const Addressee &, const Addressee & ); +}; + +} + +/** + * Addressee attribute used for sorting. + */ +typedef enum { Uid, Name, FormattedName, FamilyName, GivenName } SortingCriterion; + +/** + * @short a TQValueList of Addressee, with sorting functionality + * + * This class extends the functionality of TQValueList with + * sorting methods specific to the Addressee class. It can be used + * just like any other TQValueList but is no template class. + * + * An AddresseeList does not automatically keep sorted when addressees + * are added or removed or the sorting order is changed, as this would + * slow down larger operations by sorting after every step. So after + * such operations you have to call {@link #sort} or {@link #sortBy} to + * create a defined order again. + * + * Iterator usage is inherited by TQValueList and extensively documented + * there. Please remember that the state of an iterator is undefined + * after any sorting operation. + * + * For the enumeration Type SortingCriterion, which specifies the + * field by the collection will be sorted, the following values exist: + * Uid, Name, FormattedName, FamilyName, GivenName. + * + * @author Jost Schenck [email protected] + */ +class KABC_EXPORT AddresseeList : public TQValueList<Addressee> +{ + public: + AddresseeList(); + ~AddresseeList(); + AddresseeList( const AddresseeList & ); + AddresseeList( const TQValueList<Addressee> & ); + + /** + * Debug output. + */ + void dump() const; + + /** + * Determines the direction of sorting. On change, the list + * will <em>not</em> automatically be resorted. + * @param r <tt>true</tt> if sorting should be done reverse, <tt>false</tt> otherwise + */ + void setReverseSorting( bool r = true ) { mReverseSorting = r; } + + /** + * Returns the direction of sorting. + * @return <tt>true</tt> if sorting is done reverse, <tt>false</tt> otherwise + */ + bool reverseSorting() const { return mReverseSorting; } + + /** + * Sorts this list by a specific criterion. + * @param c the criterion by which should be sorted + */ + void sortBy( SortingCriterion c ); + + /** + * Sorts this list by a specific field. If no parameter is given, the + * last used Field object will be used. + * @param field pointer to the Field object to be sorted by + */ + void sortByField( Field *field = 0 ); + + /** + * Sorts this list by a specific sorting mode. + * @param mode pointer to the sorting mode object to be sorted by + * @since 3.4 + */ + void sortByMode( SortMode *mode = 0 ); + + /** + * Sorts this list by its active sorting criterion. This normally is the + * criterion of the last sortBy operation or <tt>FormattedName</tt> if up + * to now there has been no sortBy operation. + * + * Please note that the sorting trait of the last {@link #sortByTrait} + * method call is not remembered and thus the action can not be repeated + * by this method. + */ + void sort(); + + /** + * Templated sort function. You normally will not want to use this but + * {@link #sortBy} and {@link #sort} instead as the existing sorting + * criteria completely suffice for most cases. + * + * However, if you do want to use some special sorting criterion, you can + * write a trait class that will be provided to this templated method. + * This trait class has to have a class declaration like the following: + * \code + * class MySortingTrait { + * public: + * // eq returns true if a1 and a2 are equal + * static bool eq(TDEABC::Addressee a1, TDEABC::Addressee a2); + * // lt returns true is a1 is "less than" a2 + * static bool lt(TDEABC::Addressee a1, TDEABC::Addressee a2); + * }; + * \endcode + * You can then pass this class to the sortByTrait method like this: + * \code + * myAddresseelist.sortByTrait<MySortingTrait>(); + * \endcode + * Please note that the {@link #sort} method can not be used to repeat the + * sorting of the last <tt>sortByTrait</tt> action. + * + * Right now this method uses the bubble sort algorithm. This should be + * replaced for a better one when I have time. + */ + template<class Trait> void sortByTrait(); + + /** + * Returns the active sorting criterion, ie the sorting criterion that + * will be used by a {@link #sort} call. + */ + SortingCriterion sortingCriterion() const { return mActiveSortingCriterion; } + + /** + * Returns the active sorting field, ie a pointer to the Field object + * which was used for the last {@link #sortByField} operation. + * This function returns the last GLOBAL sorting field, not + * the class specific one. + * You're a lot better off by keeping track of this locally. + */ + Field* sortingField() const; + + private: + bool mReverseSorting; + SortingCriterion mActiveSortingCriterion; + //KDE 4.0 - add a d-pointer here! +}; + +} + +#endif diff --git a/tdeabc/addresslineedit.cpp b/tdeabc/addresslineedit.cpp new file mode 100644 index 000000000..8194f8ca3 --- /dev/null +++ b/tdeabc/addresslineedit.cpp @@ -0,0 +1,610 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Helge Deller <[email protected]> + 2002 Lubos Lunak <[email protected]> + 2001,2003 Carsten Pfeiffer <[email protected]> + 2001 Waldo Bastian <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +// $Id$ + +#include "addresslineedit.h" + +#include <tqapplication.h> +#include <tqobject.h> +#include <tqptrlist.h> +#include <tqregexp.h> +#include <tqevent.h> +#include <tqdragobject.h> + +#include <tdecompletionbox.h> +#include <tdeconfig.h> +#include <kcursor.h> +#include <kstandarddirs.h> +#include <kstaticdeleter.h> +#include <tdestdaccel.h> +#include <kurldrag.h> + +#include <tdeabc/stdaddressbook.h> +#include <tdeabc/distributionlist.h> +#include "ldapclient.h" + +#include <kdebug.h> + +//============================================================================= +// +// Class AddressLineEdit +// +//============================================================================= + + +using namespace TDEABC; + +TDECompletion * AddressLineEdit::s_completion = 0L; +bool AddressLineEdit::s_addressesDirty = false; +TQTimer* AddressLineEdit::s_LDAPTimer = 0L; +LdapSearch* AddressLineEdit::s_LDAPSearch = 0L; +TQString* AddressLineEdit::s_LDAPText = 0L; +AddressLineEdit* AddressLineEdit::s_LDAPLineEdit = 0L; +TDEConfig *AddressLineEdit::s_config = 0L; + +static KStaticDeleter<TDECompletion> completionDeleter; +static KStaticDeleter<TQTimer> ldapTimerDeleter; +static KStaticDeleter<LdapSearch> ldapSearchDeleter; +static KStaticDeleter<TQString> ldapTextDeleter; +static KStaticDeleter<TDEConfig> configDeleter; + +AddressLineEdit::AddressLineEdit(TQWidget* parent, + bool useCompletion, + const char *name) + : KLineEdit(parent,name) +{ + m_useCompletion = useCompletion; + m_completionInitialized = false; + m_smartPaste = false; + + init(); + + // Whenever a new AddressLineEdit is created (== a new composer is created), + // we set a dirty flag to reload the addresses upon the first completion. + // The address completions are shared between all AddressLineEdits. + // Is there a signal that tells us about addressbook updates? + if (m_useCompletion) + s_addressesDirty = true; +} + + +//----------------------------------------------------------------------------- +void AddressLineEdit::init() +{ + if ( !s_completion ) { + completionDeleter.setObject( s_completion, new TDECompletion() ); + s_completion->setOrder( TDECompletion::Sorted ); + s_completion->setIgnoreCase( true ); + } + + if( m_useCompletion ) { + if( !s_LDAPTimer ) { + ldapTimerDeleter.setObject( s_LDAPTimer, new TQTimer ); + ldapSearchDeleter.setObject( s_LDAPSearch, new LdapSearch ); + ldapTextDeleter.setObject( s_LDAPText, new TQString ); + } + connect( s_LDAPTimer, TQT_SIGNAL( timeout()), TQT_SLOT( slotStartLDAPLookup())); + connect( s_LDAPSearch, TQT_SIGNAL( searchData( const TQStringList& )), + TQT_SLOT( slotLDAPSearchData( const TQStringList& ))); + } + + if ( m_useCompletion && !m_completionInitialized ) + { + setCompletionObject( s_completion, false ); // we handle it ourself + connect( this, TQT_SIGNAL( completion(const TQString&)), + this, TQT_SLOT(slotCompletion() )); + + TDECompletionBox *box = completionBox(); + connect( box, TQT_SIGNAL( highlighted( const TQString& )), + this, TQT_SLOT( slotPopupCompletion( const TQString& ) )); + connect( box, TQT_SIGNAL( userCancelled( const TQString& )), + TQT_SLOT( userCancelled( const TQString& ))); + + m_completionInitialized = true; // don't connect muliple times. That's + // ugly, tho, better have completionBox() + // virtual in KDE 4 + // Why? This is only called once. Why should this be called more + // than once? And why was this protected? + } +} + +//----------------------------------------------------------------------------- +AddressLineEdit::~AddressLineEdit() +{ +} + +//----------------------------------------------------------------------------- + +TDEConfig* AddressLineEdit::config() +{ + if ( !s_config ) + configDeleter.setObject( s_config, new TDEConfig( "kabldaprc", false, false ) ); // Open read-write, no kdeglobals + + return s_config; +} + +void AddressLineEdit::setFont( const TQFont& font ) +{ + KLineEdit::setFont( font ); + if ( m_useCompletion ) + completionBox()->setFont( font ); +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::keyPressEvent(TQKeyEvent *e) +{ + bool accept = false; + + if (TDEStdAccel::shortcut(TDEStdAccel::SubstringCompletion).contains(KKey(e))) + { + doCompletion(true); + accept = true; + } + else if (TDEStdAccel::shortcut(TDEStdAccel::TextCompletion).contains(KKey(e))) + { + int len = text().length(); + + if (len == cursorPosition()) // at End? + { + doCompletion(true); + accept = true; + } + } + + if( !accept ) + KLineEdit::keyPressEvent( e ); + + if( e->isAccepted()) + { + if( m_useCompletion && s_LDAPTimer != NULL ) + { + if( *s_LDAPText != text()) + stopLDAPLookup(); + *s_LDAPText = text(); + s_LDAPLineEdit = this; + s_LDAPTimer->start( 500, true ); + } + } +} + +void AddressLineEdit::mouseReleaseEvent( TQMouseEvent * e ) +{ + if (m_useCompletion && (e->button() == Qt::MidButton)) + { + m_smartPaste = true; + KLineEdit::mouseReleaseEvent(e); + m_smartPaste = false; + return; + } + KLineEdit::mouseReleaseEvent(e); +} + +void AddressLineEdit::insert(const TQString &t) +{ + if (!m_smartPaste) + { + KLineEdit::insert(t); + return; + } + TQString newText = t.stripWhiteSpace(); + if (newText.isEmpty()) + return; + + // remove newlines in the to-be-pasted string as well as an eventual + // mailto: protocol + newText.replace( TQRegExp("\r?\n"), ", " ); + if ( newText.startsWith( "mailto:" ) ) + { + KURL u(newText); + newText = u.path(); + } + else if (newText.find(" at ") != -1) + { + // Anti-spam stuff + newText.replace( " at ", "@" ); + newText.replace( " dot ", "." ); + } + else if (newText.find("(at)") != -1) + { + newText.replace( TQRegExp("\\s*\\(at\\)\\s*"), "@" ); + } + + TQString contents = text(); + int start_sel = 0; + int end_sel = 0; + int pos = cursorPosition(); + if (getSelection(&start_sel, &end_sel)) + { + // Cut away the selection. + if (pos > end_sel) + pos -= (end_sel - start_sel); + else if (pos > start_sel) + pos = start_sel; + contents = contents.left(start_sel) + contents.right(end_sel+1); + } + + int eot = contents.length(); + while ((eot > 0) && contents[eot-1].isSpace()) eot--; + if (eot == 0) + { + contents = TQString::null; + } + else if (pos >= eot) + { + if (contents[eot-1] == ',') + eot--; + contents.truncate(eot); + contents += ", "; + pos = eot+2; + } + + contents = contents.left(pos)+newText+contents.mid(pos); + setText(contents); + setCursorPosition(pos+newText.length()); +} + +void AddressLineEdit::paste() +{ + if (m_useCompletion) + m_smartPaste = true; + KLineEdit::paste(); + m_smartPaste = false; +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::cursorAtEnd() +{ + setCursorPosition( text().length() ); +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::enableCompletion(bool enable) +{ + m_useCompletion = enable; +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::doCompletion(bool ctrlT) +{ + if ( !m_useCompletion ) + return; + + TQString prevAddr; + + TQString s(text()); + int n = s.findRev(','); + + if (n >= 0) + { + n++; // Go past the "," + + int len = s.length(); + + // Increment past any whitespace... + while( n < len && s[n].isSpace() ) + n++; + + prevAddr = s.left(n); + s = s.mid(n,255).stripWhiteSpace(); + } + + if ( s_addressesDirty ) + loadAddresses(); + + if ( ctrlT ) + { + TQStringList completions = s_completion->substringCompletion( s ); + if (completions.count() > 1) { + m_previousAddresses = prevAddr; + setCompletedItems( completions ); + } + else if (completions.count() == 1) + setText(prevAddr + completions.first()); + + cursorAtEnd(); + return; + } + + TDEGlobalSettings::Completion mode = completionMode(); + + switch ( mode ) + { + case TDEGlobalSettings::CompletionPopupAuto: + { + if (s.isEmpty()) + break; + } + case TDEGlobalSettings::CompletionPopup: + { + m_previousAddresses = prevAddr; + TQStringList items = s_completion->allMatches( s ); + items += s_completion->allMatches( "\"" + s ); + items += s_completion->substringCompletion( '<' + s ); + uint beforeDollarCompletionCount = items.count(); + + if( s.find( ' ' ) == -1 ) // one word, possibly given name + items += s_completion->allMatches( "$$" + s ); + + if ( !items.isEmpty() ) + { + if ( items.count() > beforeDollarCompletionCount ) + { + // remove the '$$whatever$' part + for( TQStringList::Iterator it = items.begin(); + it != items.end(); + ++it ) + { + int pos = (*it).find( '$', 2 ); + if( pos < 0 ) // ??? + continue; + (*it)=(*it).mid( pos + 1 ); + } + } + + items = removeMailDupes( items ); + + // We do not want KLineEdit::setCompletedItems to perform text + // completion (suggestion) since it does not know how to deal + // with providing proper completions for different items on the + // same line, e.g. comma-separated list of email addresses. + bool autoSuggest = (mode != TDEGlobalSettings::CompletionPopupAuto); + setCompletedItems( items, autoSuggest ); + + if (!autoSuggest) + { + int index = items.first().find( s ); + TQString newText = prevAddr + items.first().mid( index ); + //kdDebug() << "OLD TEXT: " << text() << endl; + //kdDebug() << "NEW TEXT: " << newText << endl; + setUserSelection(false); + setCompletedText(newText,true); + } + } + + break; + } + + case TDEGlobalSettings::CompletionShell: + { + TQString match = s_completion->makeCompletion( s ); + if ( !match.isNull() && match != s ) + { + setText( prevAddr + match ); + cursorAtEnd(); + } + break; + } + + case TDEGlobalSettings::CompletionMan: // Short-Auto in fact + case TDEGlobalSettings::CompletionAuto: + { + if (!s.isEmpty()) + { + TQString match = s_completion->makeCompletion( s ); + if ( !match.isNull() && match != s ) + { + TQString adds = prevAddr + match; + setCompletedText( adds ); + } + break; + } + } + case TDEGlobalSettings::CompletionNone: + default: // fall through + break; + } +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::slotPopupCompletion( const TQString& completion ) +{ + setText( m_previousAddresses + completion ); + cursorAtEnd(); +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::loadAddresses() +{ + s_completion->clear(); + s_addressesDirty = false; + + TQStringList adrs = addresses(); + for( TQStringList::ConstIterator it = adrs.begin(); it != adrs.end(); ++it) + addAddress( *it ); +} + +void AddressLineEdit::addAddress( const TQString& adr ) +{ + s_completion->addItem( adr ); + int pos = adr.find( '<' ); + if( pos >= 0 ) + { + ++pos; + int pos2 = adr.find( pos, '>' ); + if( pos2 >= 0 ) + s_completion->addItem( adr.mid( pos, pos2 - pos )); + } +} + +void AddressLineEdit::slotStartLDAPLookup() +{ + if( !s_LDAPSearch->isAvailable() || s_LDAPLineEdit != this ) + return; + startLoadingLDAPEntries(); +} + +void AddressLineEdit::stopLDAPLookup() +{ + s_LDAPSearch->cancelSearch(); + s_LDAPLineEdit = NULL; +} + +void AddressLineEdit::startLoadingLDAPEntries() +{ + TQString s( *s_LDAPText ); + // TODO cache last? + TQString prevAddr; + int n = s.findRev(','); + if (n>= 0) + { + prevAddr = s.left(n+1) + ' '; + s = s.mid(n+1,255).stripWhiteSpace(); + } + if( s.length() == 0 ) + return; + + loadAddresses(); // TODO reuse these? + s_LDAPSearch->startSearch( s ); +} + +void AddressLineEdit::slotLDAPSearchData( const TQStringList& adrs ) +{ + if( s_LDAPLineEdit != this ) + return; + for( TQStringList::ConstIterator it = adrs.begin(); it != adrs.end(); ++it ) { + TQString name(*it); + int pos = name.find( " <" ); + int pos_comma = name.find( ',' ); + // put name in quotes, if we have a comma in the name + if (pos>0 && pos_comma>0 && pos_comma<pos) { + name.insert(pos, '\"'); + name.prepend('\"'); + } + addAddress( name ); + } + + if( hasFocus() || completionBox()->hasFocus()) + { + if( completionMode() != TDEGlobalSettings::CompletionNone ) + { + doCompletion( false ); + } + } +} + +TQStringList AddressLineEdit::removeMailDupes( const TQStringList& adrs ) +{ + TQStringList src = adrs; + qHeapSort( src ); + TQString last; + for( TQStringList::Iterator it = src.begin(); it != src.end(); ) { + if( *it == last ) + { + it = src.remove( it ); + continue; // dupe + } + last = *it; + ++it; + } + return src; +} + +//----------------------------------------------------------------------------- +void AddressLineEdit::dropEvent(TQDropEvent *e) +{ + KURL::List uriList; + if(KURLDrag::canDecode(e) && KURLDrag::decode( e, uriList )) + { + TQString ct = text(); + KURL::List::Iterator it = uriList.begin(); + for (; it != uriList.end(); ++it) + { + if (!ct.isEmpty()) ct.append(", "); + KURL u(*it); + if ((*it).protocol() == "mailto") + ct.append( (*it).path() ); + else + ct.append( (*it).url() ); + } + setText(ct); + setEdited( true ); + } + else { + if (m_useCompletion) + m_smartPaste = true; + TQLineEdit::dropEvent(e); + m_smartPaste = false; + } +} + + +TQStringList AddressLineEdit::addresses() +{ + TQApplication::setOverrideCursor( KCursor::waitCursor() ); // loading might take a while + + TQStringList result; + TQString space(" "); + TQRegExp needQuotes("[^ 0-9A-Za-z\\x0080-\\xFFFF]"); + TQString endQuote("\" "); + TQString addr, email; + + TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(); + TDEABC::AddressBook::Iterator it; + for( it = addressBook->begin(); it != addressBook->end(); ++it ) { + TQStringList emails = (*it).emails(); + + TQString n = (*it).prefix() + space + + (*it).givenName() + space + + (*it).additionalName() + space + + (*it).familyName() + space + + (*it).suffix(); + + n = n.simplifyWhiteSpace(); + + TQStringList::ConstIterator mit; + + for ( mit = emails.begin(); mit != emails.end(); ++mit ) { + email = *mit; + if (!email.isEmpty()) { + if (n.isEmpty() || (email.find( '<' ) != -1)) + addr = TQString::null; + else { /* do we really need quotes around this name ? */ + if (n.find(needQuotes) != -1) + addr = '"' + n + endQuote; + else + addr = n + space; + } + + if (!addr.isEmpty() && (email.find( '<' ) == -1) + && (email.find( '>' ) == -1) + && (email.find( ',' ) == -1)) + addr += '<' + email + '>'; + else + addr += email; + addr = addr.stripWhiteSpace(); + result.append( addr ); + } + } + } + + TDEABC::DistributionListManager manager( addressBook ); + manager.load(); + result += manager.listNames(); + + TQApplication::restoreOverrideCursor(); + + return result; +} + +#include "addresslineedit.moc" diff --git a/tdeabc/addresslineedit.h b/tdeabc/addresslineedit.h new file mode 100644 index 000000000..ee10b5bbd --- /dev/null +++ b/tdeabc/addresslineedit.h @@ -0,0 +1,123 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Helge Deller <[email protected]> + 2002 Lubos Lunak <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSLINEEDIT_H +#define KABC_ADDRESSLINEEDIT_H +// $Id$ + +#include <tqobject.h> +#include <tqptrlist.h> +#include <tqtimer.h> + +#include "klineedit.h" +#include "kcompletion.h" + +class TDEConfig; + +namespace TDEABC { + +class LdapSearch; + +/** + * A lineedit with LDAP and kabc completion + * + * This lineedit is supposed to be used wherever the user types email addresses + * and might want a completion. You can simply use it as a replacement for + * KLineEdit or TQLineEdit. + * + * You can enable or disable the lineedit at any time. + * + * @see AddressLineEdit::enableCompletion() + */ +class KABC_EXPORT AddressLineEdit : public KLineEdit +{ + Q_OBJECT +public: + AddressLineEdit(TQWidget* parent, bool useCompletion = true, + const char *name = 0L); + virtual ~AddressLineEdit(); + + /** + * Reimplented for internal reasons. + * @ see KLineEdit::setFont() + */ + virtual void setFont( const TQFont& ); + + static TDEConfig *config(); + +public slots: + /** + * Set cursor to end of line. + */ + void cursorAtEnd(); + /** + * Toggle completion. + */ + void enableCompletion( bool enable ); + +protected: + /** + * Always call AddressLineEdit::loadAddresses() as the first thing. + * Use addAddress() to add addresses. + */ + virtual void loadAddresses(); + void addAddress( const TQString& ); + virtual void keyPressEvent(TQKeyEvent*); + virtual void dropEvent(TQDropEvent *e); + virtual void paste(); + virtual void insert(const TQString &t); + virtual void mouseReleaseEvent( TQMouseEvent * e ); + void doCompletion(bool ctrlT); + +private slots: + void slotCompletion() { doCompletion(false); } + void slotPopupCompletion( const TQString& ); + void slotStartLDAPLookup(); + void slotLDAPSearchData( const TQStringList& ); + +private: + void init(); + void startLoadingLDAPEntries(); + void stopLDAPLookup(); + TQStringList addresses(); + TQStringList removeMailDupes( const TQStringList& adrs ); + + TQString m_previousAddresses; + bool m_useCompletion; + bool m_completionInitialized; + bool m_smartPaste; + TQString m_typedText; // unused + + static bool s_addressesDirty; + static TDECompletion *s_completion; + static TQTimer *s_LDAPTimer; + static LdapSearch *s_LDAPSearch; + static TQString *s_LDAPText; + static AddressLineEdit *s_LDAPLineEdit; + static TDEConfig *s_config; + +private: + class AddressLineEditPrivate* d; +}; + +} + +#endif /* KABC_ADDRESSLINEEDIT_H */ diff --git a/tdeabc/agent.cpp b/tdeabc/agent.cpp new file mode 100644 index 000000000..2b2747697 --- /dev/null +++ b/tdeabc/agent.cpp @@ -0,0 +1,148 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "addressee.h" + +#include "agent.h" + +using namespace TDEABC; + +Agent::Agent() + : mAddressee( 0 ), mIntern( false ) +{ +} + +Agent::Agent( const TQString &url ) + : mAddressee( 0 ),mUrl( url ), mIntern( false ) +{ +} + +Agent::Agent( Addressee *addressee ) + : mAddressee( addressee ), mIntern( true ) +{ +} + +Agent::~Agent() +{ + delete mAddressee; + mAddressee = 0; +} + +bool Agent::operator==( const Agent &a ) const +{ + if ( mIntern != a.mIntern ) + return false; + + if ( !mIntern ) { + if ( mUrl != a.mUrl ) + return false; + } else { + if ( mAddressee && !a.mAddressee ) return false; + if ( !mAddressee && a.mAddressee ) return false; + if ( !mAddressee && !a.mAddressee ) return false; + if ( (*mAddressee) != (*a.mAddressee) ) return false; + } + + return true; +} + +bool Agent::operator!=( const Agent &a ) const +{ + return !( a == *this ); +} + +Agent &Agent::operator=( const Agent &addr ) +{ + if ( this == &addr ) + return *this; + + if ( addr.mIntern && addr.mAddressee ) { + if ( mAddressee ) + delete mAddressee; + + mAddressee = new Addressee; + *mAddressee = *(addr.mAddressee); + } + + mUrl = addr.mUrl; + mIntern = addr.mIntern; + + return *this; +} + +void Agent::setUrl( const TQString &url ) +{ + mUrl = url; + mIntern = false; +} + +void Agent::setAddressee( Addressee *addressee ) +{ + mAddressee = addressee; + mIntern = true; +} + +bool Agent::isIntern() const +{ + return mIntern; +} + +TQString Agent::url() const +{ + return mUrl; +} + +Addressee *Agent::addressee() const +{ + return mAddressee; +} + +TQString Agent::asString() const +{ + if ( mIntern ) + return "intern agent"; + else + return mUrl; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Agent &agent ) +{ + TQ_UINT32 hasAddressee = ( agent.mAddressee != 0 ); + + s << agent.mIntern << agent.mUrl << hasAddressee; + if ( hasAddressee ) + s << (*agent.mAddressee); + + return s; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Agent &agent ) +{ + TQ_UINT32 hasAddressee; + + s >> agent.mIntern >> agent.mUrl >> hasAddressee; + + if ( hasAddressee ) { + agent.mAddressee = new Addressee; + s >> (*agent.mAddressee); + } + + return s; +} diff --git a/tdeabc/agent.h b/tdeabc/agent.h new file mode 100644 index 000000000..b982456c5 --- /dev/null +++ b/tdeabc/agent.h @@ -0,0 +1,128 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_AGENT_H +#define KABC_AGENT_H + +class TQDataStream; + +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +class Addressee; + +/** + * Important!!! + * + * At the moment the vcard format does not support saving and loading + * this entity. + */ +class KABC_EXPORT Agent +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Agent & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Agent & ); + +public: + + /** + * Consturctor. Creates an empty object. + */ + Agent(); + + /** + * Consturctor. + * + * @param url A URL that describes the position of the agent file. + */ + Agent( const TQString &url ); + + /** + * Consturctor. + * + * @param addressee The addressee object of the agent. + */ + Agent( Addressee *addressee ); + + /** + * Destructor. + */ + ~Agent(); + + + bool operator==( const Agent & ) const; + bool operator!=( const Agent & ) const; + Agent &operator=( const Agent & ); + + /** + * Sets a URL for the location of the agent file. When using this + * function, isIntern() will return 'false' until you use + * setAddressee(). + * + * @param url The location URL of the agent file. + */ + void setUrl( const TQString &url ); + + /** + * Sets the addressee of the agent. When using this function, + * isIntern() will return 'true' until you use setUrl(). + * + * @param addressee The addressee object of the agent. + */ + void setAddressee( Addressee *addressee ); + + /** + * Returns whether the agent is described by a URL (extern) or + * by a addressee (intern). + * When this method returns 'true' you can use addressee() to + * get a Addressee object. Otherwise you can request the URL + * of this agent by url() and load the data from that location. + */ + bool isIntern() const; + + /** + * Returns the location URL of this agent. + */ + TQString url() const; + + /** + * Returns the addressee object of this agent. + */ + Addressee* addressee() const; + + /** + * Returns string representation of the agent. + */ + TQString asString() const; + +private: + Addressee *mAddressee; + TQString mUrl; + + int mIntern; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Agent & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Agent & ); + +} +#endif diff --git a/tdeabc/countrytransl.map b/tdeabc/countrytransl.map new file mode 100644 index 000000000..1459f0942 --- /dev/null +++ b/tdeabc/countrytransl.map @@ -0,0 +1,12381 @@ +Andorra ad +Andorra ad +أندورا ad +Андора ad +Андора ad +অ্যানডোরা ad +Andora ad +Andora ad +Ανδόρα ad +Andoro ad +آندورا ad +Andorre ad +Andóra ad +אנדורה ad +अंडोरा ad +アンドラ ad +អង់ដូរ៉ា ad +안도라 ad +ອີນເດີຍ ad +Andora ad +Андора ad +Андорра ad +ਐਂਡੋਰਾ ad +Andora ad +Андорра ad +Andora ad +Андора ad +Andora ad +அன்டோரா ad +Андора ad +แอนโดรา ad +Андорра ad +Андорра ad +Andore ad +安道尔 ad +安道爾 ad +United Arab Emirates ae +Vereenigde Arabiese Emirate ae +الإمارات العربية المتحدة ae +Злучаныя Арабскія Эміраты ae +ОАЕ ae +সংযুক্ত আরব আমিরশাহি ae +Stadoù-Unanet Arabeg ae +Ujedinjeni arapski emirati ae +Emirats Àrabs Units ae +Spojené arabské emiráty ae +Emiraethau Arabaidd Unedig ae +Forenende Arabiske Emirater ae +Vereinigte Arabische Emirate ae +Ενωμένα Αραβικά Εμιράτα ae +Uniĝintaj Arabaj Emirlandoj ae +Emiratos árabes unidos ae +Araabia Ühendemiraadid ae +Arabiar Emirato Batuak ae +امارات متحده عربی ae +Yhdistyneet Arabiemiraatit ae +Émirats Arabes Unis ae +Ferienigde Arabyske Emiraten ae +Aontas na nÉimíríochtaí Arabacha ae +Emiratos Árabes Unidos ae +איחוד האמירויות הערביות ae +संयुक्त अरब अमीरात ae +Ujedinjeni arapski emirati ae +Egyesült Arab Emirátusok ae +Sameinuðu arabísku furstadæmin ae +Emirati Arabi Uniti ae +アラブ首長国連邦 ae +អារ៉ាប់រួម ae +아랍 에미레이트 연합 ae +ສະຫະລັດ ae +Jungtiniai Arabų Emiratai ae +Apvienotie Arābu Emerāti ae +Обединети Арапски Емирати ae +Нэгдсэн арабын имрат ae +Emirati Għarab Magħquda ae +De forente arabiske emirater ae +Vereenigte Araabsche Emiraten ae +Verenigde Arabische Emiraten ae +Dei sameinte arabiske emirata ae +Di-Emirate tseo di Kopanego tsa Arab ae +ਸੰਯੁਕਤ ਅਰਬ ਅਮੀਰਾਤ ae +Zjednoczone Emiraty Arabskie ae +Emiratos Árabes Unidos ae +Emirados Árabes Unidos ae +Emiratele Arabe Unite ae +Объединенные Арабские Эмираты ae +Leta Zunze Ubumwe z'Abarabu ae +Ovttastuvvon arábalaš emiráhtat ae +Spojené arabské emiráty ae +Združeni arabski Emirati ae +Уједињени арапски емирати ae +Ujedinjeni arapski emirati ae +Förenade arabemiraten ae +யுனைடெட் அரபி எமிரேட்ஸ் ae +Аморати муттаҳидаи Араб ae +สหรัฐอาหรับอีมิเรตส์ ae +Birleşik Arap Emirlikleri ae +Berläşkän Ğäräp Ämirlekläre ae +Об'єднані Арабські Емірати ae +Бирлашган Араб Амирликлари ae +Mashango o tangananaho a Emirates ae +Emirat Arabes Unis ae +阿联酋 ae +阿拉伯聯合大公國 ae +Izindawo zezinduna zase-United Arab ae +Afghanistan af +أفغانستان af +Афганістан af +Афганистан af +আফগানিস্তান af +Afganistan af +Afganistan af +Afganistan af +Afghanistán af +Affganistan af +Αφγανιστάν af +Afganio af +Afghanistán af +Afganistan af +افغانستان af +Afganistan af +An Afganastáin af +Afganistan af +אפגניסטן af +अफगानिस्तान af +Afganistan af +Afganisztán af +Afganistan af +Afganistan af +アフガニスタン af +អាហ្វកានីស្ថាន af +아프가니스탄 af +ລີທົ່ວເນີຍ af +Afganistāna af +Авганистан af +Афганстан af +Afganistan af +ਅਫਗਾਨਿਸਤਾਨ af +Afganistan af +Afeganistão af +Afeganistão af +Afganistan af +Афганистан af +Afuganisitani af +Afganistan af +Afganistan af +Авганистан af +Avganistan af +Afganistan af +ஆப்கானிஸ்தான் af +Афғонистон af +อาฟกานิสถาน af +Afganistan af +Äfğänstan af +Афганістан af +Афғонистон af +Afganistan af +阿富汗 af +阿富汗 af +Antigua and Barbuda ag +Antigue en Barbuda ag +أنتيغوا و باربودا ag +Antigua və Barbuda ag +Антыгуа і Барбуда ag +Антигуа и Барбуда ag +অ্যান্টিগুয়া এবং বার্বুডা ag +Antigua ha Barbuda ag +Antigua i Barbuda ag +Antigua i Barbuda ag +Antigua a Barbuda ag +Antigwa a Barbwda ag +Antigua og Barbuda ag +Antigua und Barbuda ag +Αντίγκουα και Μπαρμπούντα ag +Antigvo-Barbudo ag +Antigua y Barbuda ag +Antigua ja Barbuda ag +Antigua eta Barbuda ag +آنتیگوا و باربودا ag +Antigua ja Barbados ag +Antigua og Barbuda ag +Antigua et Barbuda ag +Antigua en Barbuda ag +Antigua agus Barbúda ag +Antiga e Barbuda ag +אנטיגואה ובריבודה ag +एन्टिगुआ और बारबूडा ag +Antigua i Barbuda ag +Antigua és Barbuda ag +Antigua dan Barbuda ag +Antígva og Barbúda ag +Antigua e Barbuda ag +アンティグアバーブーダ ag +Antigua និង Barbuda ag +앤티가 바부다 ag +Antikva ir Barbuda ag +Antigva un Barbuda ag +Антигва и Барбуда ag +Антигуа ба Барбуда ag +Antigwa u Barbuda ag +Antigua og Barbuda ag +Antigua un Barbuda ag +Antigua en Barbuda ag +Antigua og Barbuda ag +Antigua le Barbuda ag +Antigua e Barbuda ag +ਐਂਟੀਗੁਆ ਤੇ ਬਾਰਬੁਡਾ ag +Antigua i Barbuda ag +Antígua e Barbuda ag +Antigua e Barbuda ag +Antigua şi Barbuda ag +Антигуа и Барбуда ag +Antigwa na Barubida ag +Antigua ja Barbuda ag +Antigua a Barbuda ag +Antigva in Barbuda ag +Антигва и Барбуда ag +Antigva i Barbuda ag +I-Antigua kanye ne Barbuda ag +Antigua och Barbuda ag +ஆன்டிகா மற்றும் பெர்முடா ag +Антигуо ва Барбудо ag +อันทิกัว และ บาร์บูดา ag +Antigua ve Barbuda ag +Antigua wä Barbuda ag +Трінідад і Тобаго ag +Антигуа ва Барбуда ag +Antigua và Barbuda ag +Antigua eyet Barbuda ag +Antigua ne Barbuda ag +安提瓜和巴布达 ag +安地瓜島和巴布達島 ag +Antigua kanye ne-Barbuda ag +Anguilla ai +أنغويلا ai +Ангілья ai +Ангила ai +অ্যাঙ্গুইলা ai +Angilla ai +Angwila ai +Ανγκουίλα ai +Angvilo ai +آنگوییلا ai +אנגווילה ai +एंगुएला ai +Angvilla ai +イギリス属領アンギラ ai +អង់ហ្ស៊ីឡា ai +앙길라 ai +ແພນວິນ ai +Ангилја ai +Ангуаилла ai +Angwilla ai +ਐਂਨਗੁਈਲਾ ai +Anghila ai +Ангилла ai +Angwiya ai +Angvila ai +Ангвила ai +Angvila ai +ஆன்கில்லா ai +Ангуилло ai +แองกีลา ai +Ангілья ai +Ангвилла ai +Anguila ai +安圭拉 ai +阿爾及利亞 ai +Albania al +Albanië al +ألبانيا al +Альбанія al +Албания al +অলবেনিয়া al +Albani al +Albanija al +Albània al +Albánie al +Albanien al +Albanien al +Αλβανία al +Albanio al +Albaania al +آلبانی al +Albanie al +Albanië al +An Albáin al +Albánia al +אלבניה al +अल्बानिया al +Albánia al +Albanía al +アルバニア al +អាល់បានី al +알바니아 al +ແອດແລນຕິກ al +Albanija al +Albānija al +Албанија al +Албани al +Albanija al +Albanien al +Albanië al +ਅਲਬਾਨੀਆ al +Albânia al +Albânia al +Албания al +Alubaniya al +Albánia al +Albánsko al +Albanija al +Албанија al +Albanija al +Albanien al +ஆல்பனியா al +Олбанӣ al +อัลเบเนีย al +Arnavutluk al +Албанія al +Албания al +Albaneye al +阿尔巴尼亚 al +阿亞巴尼亞 al +Armenia am +Armenië am +أرمينيا am +Армэнія am +Армения am +আর্মেনিয়া am +Armeni am +Armenija am +Armènia am +Arménie am +Armenien am +Armenien am +Αρμενία am +Armenio am +Armeenia am +ارمنستان am +Arménie am +Armenië am +An Airméin am +Arménia am +ארמניה am +आर्मेनिया am +Örményország am +Armenía am +アルメニア am +អារមេនី am +아르메니아 am +ອາເຈນຕິນາ am +Armėnija am +Armēnija am +Ерменија am +Армен am +Armenien am +Armenië am +ਅਰਮੀਨੀਆ am +Arménia am +Armênia am +Армения am +Arumeniya am +Arménsko am +Armenija am +Јерменија am +Jermenija am +Armenien am +ஆர்மேனியா am +Арманистон am +อาร์เมเนีย am +Ermenistan am +Ärmänstan am +Вірменія am +Арманистон am +Årmeneye am +亚美尼亚 am +亞美尼亞 am +Netherlands Antilles an +Nederlandse Antilles an +أنتيل هولندا an +Нідэрляндскія Антылы an +Холандски Антили an +নেদারল্যাণ্ডস অ্যান্টিলেস an +Antilh an Izelvroioù an +Nizozemski Antili an +Antilles del Països Baixos an +Nizozemské Antily an +Ynysoedd Iseldiraidd Y Carib? an +Nederlandske antiller an +Niederländische Antillen an +Ολλανδικές Αντίλλες an +Nederlandaj Antiloj an +Antillas holandesas an +Hollandi Antillid an +Antilla Holandarrak an +آنتیلس هلند an +Alankomaiden Antillit an +Antilles néerlandaises an +Nederlânske Antillen an +Aintillí na hÍsiltíre an +Antillas Holandesas an +नीदरलैंड एन्टीलीस an +Nizozemski Antili an +Holland-Antillák an +Hollensku Antillur an +Antille Olandesi an +オランダ領アンチル an +អង់ទីយ៍ហូល្លង់ an +네덜란드령 안틸레스 an +ເນເທີແລນ an +Nyderlandų Antilai an +Nīderlandes Antiļas an +Холандски Антили an +Недерландын Антиллэс an +De nederlandske Antillene an +Nedderlandsche Antillen an +Nederlandse Antillen an +Dei nederlandske Antillane an +ਨੀਂਦਰਲੈਂਡ ਐਂਟੀਲੀਸ an +Antyle Holenderskie an +Antilhas Holandês an +Antilhas Holandesas an +Antilele Olandeze an +Нидерландские Антильские острова an +Antiye z'Ubuholande an +Hollándalaš Antillat an +Holandské Antily an +Nizozemski Antili an +Холандски антили an +Holandski antili an +Nederländska Antillerna an +நெதர்லாந்து அன்டில்ஸ் an +Антилиси Ҳолланд an +เนเธอร์แลนด์ แอนทิลีส an +Hollanda Antilleri an +Niderland Antilläre an +Антільські острови (Нідерланди) an +Нидерландлар Антил Ороллари an +Hà Lan Antilles an +Antiyes Neyerlandesses an +荷属安的列斯群岛 an +荷屬安地列斯群島 an +Angola ao +أنغولا ao +Ангола ao +Ангола ao +অ্যাঙ্গোলা ao +Ανγκόλα ao +Angolo ao +آنگولا ao +Angóla ao +אנגולה ao +अंगोला ao +Angóla ao +アンゴラ ao +អង់ហ្គោឡា ao +앙골라 ao +ບັນແກເລີຍ ao +Ангола ao +Ангол ao +ਅੰਗੋਲਾ ao +Ангола ao +Ангола ao +ஆங்கோலா ao +Ангуло ao +แองโกลา ao +Ангола ao +Ангола ao +安哥拉 ao +安哥拉 ao +Argentina ar +Argentinië ar +الأرجنتين ar +Аргентына ar +Аржентина ar +আর্জেন্টিনা ar +Arc'hantina ar +Ariannin ar +Argentinien ar +Αργεντινή ar +Argentino ar +آرژانتین ar +Agentiina ar +Argentine ar +Argentinië ar +An Airgintín ar +Arxentina ar +ארגנטינה ar +अर्जेंटीना ar +Argentína ar +Argentína ar +アルゼンチン ar +អាហ្សង់ទីន ar +아르헨티나 ar +ອາເຈນຕິນາ ar +Argentīna ar +Аргентина ar +Аргентин ar +Arġentina ar +Argentinien ar +Argentinië ar +ਅਰਜ਼ਨਟੀਨਾ ar +Argentyna ar +Аргентина ar +Arijantina ar +Argentína ar +Аргентина ar +I-Argentina ar +ஆர்சென்டினா ar +Оржонтина ar +อาร์เจนตินา ar +Arjantin ar +Аргентина ar +Аргентина ar +Agenthina ar +Årdjintene ar +阿根廷 ar +阿根廷 ar +American Samoa as +Amerikanse Samoa as +ساموا الأمريكية as +Амэрыканскае Самоа as +Американски Самоа as +মার্কিন সামোয়া as +Samoa amerikanek as +Američka Samoa as +Samoa Americana as +Americká Samoa as +Samoa Americanaidd as +Samoa (USA) as +Amerikanisches Samoa as +Αμερικανική Σαμόα as +Amerika Samoo as +Samoa americana as +Ameerika Samoa as +Amerikar Samoa as +ساموای آمریکا as +Amerikan Samoa as +Samoa américaines as +Amerikaansk Samoa as +Samó Meiriceánach as +Samoa Americana as +סמואה האמריקנית as +अमेरिकी सामोआ as +Američka Samoa as +Amerikai Szamoa as +Bandaríska Samóa as +Samoa Americane as +アメリカンサモア as +សាមូអា អាមេរិក as +미국령 사모아 as +ອາເມລິກາເຫນືອ as +Amerikos Samoa as +Amerikas Samoa as +Американска Самоа as +Америк, Самоа as +Samoa Amerikana as +Amerikansk Samoa as +Amerikaansch Samoa as +Amerikaans Samoa as +Amerikansk Samoa as +ਅਮਰੀਕੀ ਸਾਮੋਆ as +Samoa Amerykańskie as +Samoa Americana as +Samoa Americana as +Samoa americană as +Американское Самоа as +Samowa Nyamerika as +Amerihkálaš Samoa as +Americká Samoa as +Ameriška Samoa as +Америчка Самоа as +Američka Samoa as +Amerikanska Samoa as +அமெரிக்கா சமோயா as +Самоаи Амрикоӣ as +อเมริกัน ซามัว as +Amerika Samoası as +Amerikalı Samoa as +Американське Самоа as +Америка Самоаси as +Samowa Amerikinne as +美属萨摩亚 as +美屬薩摩亞 as +Austria at +Oostenryk at +النمسا at +Avstriya at +Аўстрыя at +Австрия at +অস্ট্রিয়া at +Aostria at +Austrija at +Àustria at +Rakousko at +Awstria at +Østrig at +Österreich at +Αυστρία at +Aŭstrio at +اتریش at +Itävalta at +Eysturríki at +Autriche at +Eastenryk at +An Ostair at +אוסטריה at +आस्ट्रिया at +Austrija at +Ausztria at +Austurríki at +オーストリア at +អូទ្រីស at +오스트리아 at +ອອດສະເຕເລີຍ at +Austrija at +Austrija at +Австрија at +Австри at +Awtrija at +Østerrike at +Österriek at +Oostenrijk at +Austerrike at +ਆਸਟਰੀਆ at +Áustria at +Áustria at +Австрия at +Ositiriya at +Nuortariika at +Rakúsko at +Avstrija at +Аустрија at +Austrija at +I-Austria at +Österrike at +ஆஸ்த்திரியா at +Австрия at +ออสเตรีย at +Avusturya at +Австрія at +Австрия at +Ositiria at +Áo at +Otriche at +奥地利 at +奧地利 at +Australia au +Australië au +أستراليا au +Avustralya au +Аўстралія au +Австралия au +অস্ট্রেলিয়া au +Aostralia au +Australija au +Austràlia au +Austrálie au +Awstralia au +Australien au +Australien au +Αυστραλία au +Aŭstralio au +Austraalia au +استرالیا au +Australie au +Australië au +An Astráil au +Austrália au +אוסטרליה au +आस्ट्रेलिया au +Australija au +Ausztrália au +Ástralía au +オーストラリア au +អូស្ត្រាលី au +오스트레일리아 au +ອອດສະເຕເລີຍ au +Australija au +Austrālija au +Австралија au +Австрали au +Awstralja au +Australien au +Australië au +ਅਸਟਰੇਲੀਆ au +Austrália au +Austrália au +Австралия au +Ositaraliya au +Austrália au +Austrália au +Avstralija au +Аустралија au +Australija au +I-Australia au +Australien au +ஆஸ்த்திரேலியா au +Остролиё au +ออสเตรเลีย au +Avusturalya au +Австралія au +Австралия au +Ositiralia au +Úc au +Ostraleye au +澳大利亚 au +澳大利亞 au +Aruba aw +أروبا aw +Аруба aw +আরুবা aw +Arwba aw +Αρούμπα aw +Arubo aw +آروبا aw +ארובה aw +अरूबा aw +Arúba aw +オランダ自治領アルバ aw +អារូបា aw +아루바 aw +ເກມໄັພ່ aw +Аруба aw +Арува aw +ਅਰੂਬੀ aw +Аруба aw +Áruba aw +Аруба aw +அருபா aw +Арубо aw +อรูบา aw +Аруба aw +Аруба aw +Arouba aw +阿鲁巴 aw +阿魯巴 aw +Åland Islands ax +Åland Eilande ax +Острови Аланд ax +Illes Åland ax +Ålandské ostrovy ax +Åland-øerne ax +Aland ax +Νησιά Åland ax +Islas Aland ax +Ahvenamaa ax +Åland irlak ax +Ahvenanmaan saaret ax +Îles Åland ax +Åland-eilannen ax +Na hOileáin Åland ax +Illas Åland ax +Åland-szigetek ax +Álandseyjar ax +Isole Åland ax +オーランド諸島 ax +កោះ Åland ax +Åland salos ax +Острови Оланд ax +Åland-øyene ax +Åland-Inseln ax +Åland-eilanden ax +Åland-øyane ax +ਅਮਾਨ ਟਾਪੂ ax +Wyspy Åland ax +Ilhas Åland ax +Ilhas Åland ax +Аландские острова ax +Ibirwa by'Åland ax +Åland sullot ax +Ålandski otoki ax +Аландска острва ax +Alandska ostrva ax +Åland ax +หมู่เกาะอาลันด์ ax +Cayman Adaları ax +Aland Utrawları ax +Аландські острови ax +Аланд Ороллари ax +阿兰群岛 ax +奧蘭群島 ax +Azerbaijan az +أذربيجان az +Azərbaycan az +Азэрбайджан az +Азербайджан az +আজেরবাইজান az +Azerbeidjan az +Azerbejdžan az +Azerbaitjan az +Ázerbajdžánský az +Aserbaijan az +Azerbajdjan az +Aserbaidschan az +Αζερμπαϊτζάν az +Azerbajĝano az +Azerbaiján az +Aserbaidžaan az +آذربایجان az +Azerbaidäani az +Aserbadsjan az +Azerbeidjan az +An Asarbaiseáin az +אזרביג'ן az +अजरबैजान az +Azerbejdžan az +Azerbajdzsán az +Aserbaídsjan az +Azerbaigian az +アゼルバイジャン az +អាហ្ស៊ែរបែហ្សង់ az +아제르바이잔 az +ອາເຊີໄບຈັນ az +Azerbaidžanas az +Azerbaidžāna az +Азербејџан az +Азарбайжан az +Ażerbajġan az +Aserbajdsjan az +Aserbaidschan az +Azerbeidjan az +Aserbajdsjan az +ਅਜ਼ਰਬਾਈਜਾਨ az +Azerbejdżan az +Azerbaijão az +Azerbaijão az +Азербайджан az +Azeribayijani az +Aserbaižan az +Ázerbajdžánsky az +Azerbajdžan az +Азербејџан az +Azerbejdžan az +I-Azerbaijan az +அசர்பைசான் az +Озарбойҷон az +อาร์เซอร์ไบจัน az +Azerice az +Äzärbaycan az +Азербайджан az +Озарбайжон az +Azerbaydjan az +阿塞拜疆 az +亞塞拜然 az +Bosnia and Herzegovina ba +Bosnië en Herzegovina ba +البوسنا و الهرسك ba +Босьнія і Герцагавіна ba +Босна и Херцеговина ba +বসনিয়া এবং হারজিগোভিনা ba +Bosni hag Herzigovi ba +Bosna i Hercegovina ba +Bòsnia i Hercegovina ba +Bosna a Herzegovina ba +Bosnia a Hertsegofina ba +Bosnien-Herzegovina ba +Bosnien und Herzegowina ba +Βοσνία και Ερζεγοβίνη ba +Bosnio kaj Hercegovino ba +Bosnia y Herzegovina ba +Bosnia ja Hertsegovina ba +Bosnia eta Herzegovina ba +بوسنی و هرزگوین ba +Bosnia ja Herzegovina ba +Bosnia-Herzegovina ba +Bosnie herzégovine ba +Bosnië en Herzegovina ba +An Bhoisnia agus Heirseagóivéin ba +Bosnia e Herzegovina ba +בוסניה הרצגובינה ba +बोस्निया और हर्जेगोविना ba +Bosna i Hercegovina ba +Bosznia-Hercegovina ba +Bosnía og Hersegóvína ba +Bosnia e Erzegovina ba +ボスニアヘルツェゴビナ ba +បូស្ន៊ី និងហឺហ្ស៊េហ្គោវីណា ba +보스니아어와 헤르체고비나 ba +ບອສເນີຍ ແລະ ເຫີເຊີໂກວິນາ ba +Bosnija ir Hercegovina ba +Bosnija un Hercogovina ba +Босна и Херцеговина ba +Босни ба Херцеговина ba +Bożnia u Ħerżegovina ba +Bosnia-Hercegovina ba +Bosnien-Herzegowina ba +Bosnië en Herzegovina ba +Bosnia-Hercegovina ba +Bosnia le Herzegovina ba +ਬੋਸਨੀਆ ਤੇ ਹਰਜ਼ੀਗੋਵਿਨਾ ba +Bośnia i Hercegowina ba +Bósnia e Herzegovina ba +Bósnia Herzegovina ba +Bosnia şi Herţegovina ba +Босния и Герцеговина ba +Bosiniya na Herizegovina ba +Bosnia ja Hercegovina ba +Bosna a Hercegovina ba +Bosna in Hercegovina ba +Босна и Херцеговина ba +Bosna i Hercegovina ba +I-Bosnia kanye ne Herzegovina ba +Bosnien och Herzegovina ba +பொசுனியா மற்றும் ஹர்ஜிகோவினா ba +Босния ва Герсогавина ba +บอสเนียและเฮอร์เซโกวินา ba +Bosna Hersek ba +Bosnia wä Herzegovina ba +Боснія і Герцеговина ba +Босния ва Герцоговина ba +Mubosinia na Muhezegovina ba +Bosnia và Herzegovina ba +Bosneye ba +Bosnia ne Herzegovina ba +波斯尼亚和黑塞哥维那 ba +波士尼亞與赫塞哥維納 ba +Bosnia kanye ne-Herzegovina ba +Barbados bb +بربادوس bb +Барбадос bb +Барбейдос bb +বারবাডোস bb +Μπαρμπάντος bb +Barbado bb +باربادوس bb +Barbade bb +Barbadós bb +ברבדוס bb +बारबाडोस bb +バルバドス bb +បារបាដូស bb +바르바도스 bb +ບາລບາດອດສ bb +Barbadosas bb +Barbadosa bb +Барбадос bb +Барбодас bb +ਬਾਰਬਾਡੋਸ bb +Барбадос bb +Barubadosi bb +Барбадос bb +I-Barbados bb +பார்பேடாசு bb +Барбадос bb +บาร์บาดอส bb +Барбадос bb +Барбадос bb +Bårbades bb +巴巴多斯 bb +巴貝多 bb +Bangladesh bd +بنغلاديش bd +Banqladeş bd +Банглядэш bd +Бангладеш bd +বাংলাদেশ bd +Bangladaech bd +Bangladeš bd +Bangladéš bd +Bangladesch bd +Μπαγκλαντές bd +Bangladeŝo bd +بنگلادش bd +An Bhanglaidéis bd +בנגלדש bd +बांग्लादेश bd +Bangladeš bd +Banglades bd +Bangladess bd +バングラデシュ bd +បង់ក្លាដេស្ហ bd +방글라데시 bd +ບັງຄະລາເທດ bd +Bangladešas bd +Bangladeša bd +Бангладеш bd +Бангладеш bd +Bangladexx bd +Bangladesch bd +ਬੰਗਲਾਦੇਸ਼ bd +Bangladesz bd +Bangladeş bd +Бангладеш bd +Bangaladeshi bd +Bangladéš bd +Bangladeš bd +Бангладеш bd +Bangladeš bd +I-Bangladesh bd +பங்களாதேசு bd +Банглодеш bd +บังคลาเทศ bd +Bangladeş bd +Bangladeş bd +Бангладеш bd +Бангладеш bd +孟加拉国 bd +孟加拉 bd +Belgium be +België be +بلجيكا be +Belçika be +Бэльгія be +Белгия be +বেলজিয়াম be +Belgia be +Belgija be +Bèlgica be +Belgie be +Gwlad Belg be +Belgien be +Belgien be +Βέλγιο be +Belgio be +Bélgica be +Belgia be +Belgika be +بلژیک be +Belgia be +Belgia be +Belgique be +België be +An Bheilg be +Bélxica be +בלגיה be +बेल्जियम be +Belgija be +Belgia be +Belgía be +Belgio be +ベルギー be +បែលហ្ស៊ិក be +벨기에 be +ເບລຢ່ງມ be +Belgija be +Beļģija be +Белгија be +Белги be +Belġju be +Belgia be +Belgien be +België be +Belgia be +Bèlgica be +ਬੈਲਜੀਅਮ be +Belgia be +Bélgica be +Bélgica be +Belgia be +Бельгия be +Ububiligi be +Belgia be +Belgicko be +Belgija be +Белгија be +Belgija be +I-Belgium be +Belgien be +பெல்சியம் be +Белгия be +เบลเยียม be +Belçika be +Belgia be +Бельгія be +Белгия be +Bỉ be +Beldjike be +比利时 be +比利時 be +Burkina Faso bf +بوركينا فاسو bf +Буркіна Фасо bf +Буркина Фасо bf +বারকিনা ফাসো bf +Bwrcina Ffaso bf +Μπουρκίνα Φάσο bf +Burkino bf +بورکینافاسو bf +Buircíne Fasó bf +בורניקה פאסו bf +बुर्किना फासो bf +Burkina faso bf +Búrkína Fasó bf +ブルキナファソ bf +ប៊ូរគីណាហ្វាសូ bf +부르키나 파소 bf +ຕຸລະກີ bf +Буркина Фасо bf +Буркина Фасо bf +ਬੁਰਕਿਨਾ ਫਾਸੋ bf +Буркина-Фасо bf +Burukina Faso bf +Буркина Фасо bf +பர்கினா ஃபசோ bf +Буркина Фасу bf +เบอร์กินาฟาโซ bf +Буркіна-Фасо bf +Буркина-Фассо bf +Bourkina Fasso bf +布基纳法索 bf +布吉納法索 bf +Bulgaria bg +Bulgarye bg +بلغاريا bg +Bolgarıstan bg +Баўгарыя bg +България bg +বুলগেরিয়া bg +Bulgari bg +Bugarska bg +Bulgària bg +Bulharsko bg +Bwlgaria bg +Bulgarien bg +Bulgarien bg +Βουλγαρία bg +Bulgario bg +Bulgaaria bg +بلغارستان bg +Bulgarie bg +Bulgarije bg +An Bhulgáir bg +Bulgária bg +בולגריה bg +बुल्गारिया bg +Bugarska bg +Bulgária bg +Búlgaría bg +ブルガリア bg +ប៊ុលហ្ការី bg +불가리아 bg +ບັນແກເລີຍ bg +Bulgarija bg +Bulgārija bg +Бугарија bg +Болгари bg +Bulgarija bg +Bulgarien bg +Bulgarije bg +ਬੁਲਗਾਰੀਆ bg +Bułgaria bg +Bulgária bg +Bulgária bg +Болгария bg +Buligariya bg +Bulgária bg +Bulharsko bg +Bolgarija bg +Бугарска bg +Bugarska bg +I-Bulgaria bg +Bulgarien bg +பல்கேரியா bg +Булғористон bg +บัลแกเรีย bg +Bulgaristan bg +Болгарія bg +Болгария bg +Baligaria bg +Bulgåreye bg +保加利亚 bg +保加利亞 bg +Bahrain bh +البحرين bh +Бахрэйн bh +Бахрейн bh +বাহরেন bh +Barein bh +Bahrein bh +Bahrajn bh +Μπαχρέιν bh +Barejno bh +Bahrein bh +Bahrein bh +بحرین bh +Baghrein bh +Bairéin bh +Barein bh +בחריין bh +बहारीन bh +Barein bh +バーレーン bh +បារ៉ែន bh +바레인 bh +ຖັກກ່ງວ bh +Bahreinas bh +Bahreina bh +Бахреин bh +Бахрайн bh +Baħrain bh +Baghrein bh +ਬਹਿਰੀਨ bh +Bahrajn bh +Bahrein bh +Бахрейн bh +Bahirayini bh +Bahrajn bh +Bahrajn bh +Бахреин bh +Bahrein bh +I-Bahrain bh +Bahrein bh +பஹ்ரைன் bh +Баҳрайн bh +บาห์เรียน bh +Bahreyn bh +Bahreyn bh +Бахрейн bh +Баҳрайн bh +Bareyn bh +巴林 bh +巴林 bh +Burundi bi +بوروندي bi +Бурундзі bi +Бурунди bi +বুরুন্ডি bi +Bwrwndi bi +Μπουρουντί bi +Burundo bi +بروندی bi +An Bhurúin bi +בורונדי bi +बुरूंडी bi +Búrúndí bi +ブルンジ bi +ប៊ូរុនឌី bi +부룬디 bi +ເຄອຣດ bi +Burundija bi +Бурунди bi +Бурунди bi +ਬੁਰੁਨਡੀ bi +Бурунди bi +Бурунди bi +புருன்டி bi +Бурундӣ bi +บูรันดิ bi +Бурунді bi +Бурунди bi +Bouroundi bi +布隆迪 bi +浦隆地 bi +Benin bj +Denin bj +بينين bj +Бэнін bj +Бенин bj +বেনিন bj +Μπενίν bj +Benino bj +بنین bj +Bénin bj +Beinin bj +בנין bj +बेनिन bj +Benín bj +ベナン bj +បេណាំង bj +베냉 bj +ບອສເນີຍ bj +Benina bj +Бенин bj +Бенин bj +ਬੀਨਿਨ bj +Benim bj +Бенин bj +Bene bj +Бенин bj +பெனின் bj +Бенини bj +เบนิน bj +Бенін bj +Бенин bj +贝宁 bj +貝南 bj +Bermuda bm +برمودا bm +Бэрмуды bm +Бермуда bm +বার্মুডা bm +Bermud bm +Bermudy bm +Bermwda bm +Bermudas bm +Βερμούδες bm +Bermudoj bm +برمودا bm +Bermudes bm +Beirmiúda bm +ברמודה bm +बरमूडा bm +Bermúdaeyjar bm +英領バーミューダ bm +ប៊េរមូដា bm +버뮤다 bm +ເຍລລະມັນ bm +Bermudų bm +Bermudas bm +Бермуди bm +Бермуда bm +ਬੀਰਮੁਡਾ bm +Bermudy bm +Bermude bm +Бермудские Острова bm +Berimuda bm +Bermudy bm +Bermudi bm +Бермуда bm +பெருமுடா bm +Бермудо bm +เบอร์มิวดา bm +Бермуди bm +Бермуда Ороллари bm +Bermudes bm +百慕大 bm +百慕達 bm +Brunei Darussalam bn +بروناي دار السلام bn +Брунэй bn +Бруней bn +ব্রুনেই দারএসসলাম bn +Darussalam Brunei bn +Brunej bn +Brwnei Darwsalam bn +Brunei bn +Μπρουνέι Νταρουσαλάμ bn +Brunejo bn +Brunei bn +برونویی بیتالمقدس bn +Brunei bn +Brúiné bn +בורניי דרוסלם bn +ब्रूनेई दारेस्सलाम bn +Brunei Szultánság bn +Brúnei Darussalam bn +Brunei bn +ブルネイ bn +ប្រ៊ុយណេ bn +브루나이 bn +ເບລາລັສເຊີຍ bn +Bruneja Darusalama bn +Брунеи Дар ес Салам bn +Бруней Даруссалам bn +Brunei bn +Brunei bn +Brunei bn +ਬਰੂਨੀ ਡਾਰੂਸਲਾਮ bn +Brunei Dar-es-Salam bn +Brunei bn +Бруней bn +Buruneyi Darusalamu bn +Brunei bn +Brunei Darusalam bn +Брунеј Дарусалам bn +Brunej Darusalam bn +ப்ரூனை டருசலாம் bn +Брунеи Байтулмуқаддас bn +บรูไนดูรัสซาลาม bn +Brunei bn +Бруней Даруссалам bn +Бруней Доруссалом bn +Bruney Darussalam bn +文莱达鲁萨兰 bn +文萊達魯薩蘭 bn +Bolivia bo +Bolivië bo +بوليفيا bo +Boliviya bo +Балівія bo +Боливия bo +বলিভিয়া bo +Bolivija bo +Bolívia bo +Bolívie bo +Bolifia bo +Bolivien bo +Βολιβία bo +Bolivio bo +Boliivia bo +بولیوی bo +Bolivie bo +An Bholaiv bo +Bolívia bo +בוליביה bo +बोलिविया bo +Bolivija bo +Bolívia bo +Bólivía bo +ボリビア bo +បូលីវី bo +볼리비아 bo +ໂບລີເວີຍ bo +Bolivija bo +Bolīvija bo +Боливија bo +Боливи bo +Bolivja bo +Bolivien bo +ਬੋਲਵੀਆ bo +Boliwia bo +Bolívia bo +Bolívia bo +Боливия bo +Boliviya bo +Bolívia bo +Bolivija bo +Боливија bo +Bolivija bo +I-Bolivia bo +பொலிவியா bo +Боливия bo +โบลิเวีย bo +Bolivya bo +Болівія bo +Боливия bo +Boliveye bo +玻利维亚 bo +玻利維亞 bo +Brazil br +Brazilië br +البرازيل br +Braziliya br +Бразылія br +Бразилия br +ব্রাজিল br +Brasil br +Brazílie br +Brasil br +Brasilien br +Brasilien br +Βραζιλία br +Brazilo br +Brasil br +Brasiilia br +Brasil br +برزیل br +Brasilia br +Brésil br +Brazilië br +An Bhrasaíl br +Brasil br +ברזיל br +ब्राजील br +Brazília br +Brasilía br +Brasile br +ブラジル br +ប្រេហ្ស៊ីល br +브라질 br +ບາຊີລ br +Brazilija br +Brazīlija br +Бразил br +Бразил br +Brażil br +Brasil br +Brasilien br +Brazilië br +Brasil br +Brasil br +ਬਰਾਜ਼ੀਲ br +Brazylia br +Brasil br +Brasil br +Brazilia br +Бразилия br +Burezile br +Brasil br +Brazília br +Brazilija br +Бразил br +I-Brazil br +Brasilien br +பிரேசில் br +Бразил br +บราซิล br +Brezilya br +Бразилія br +Бразилия br +Burazili br +Braezi br +巴西 br +巴西 br +Bahamas bs +جزر الباهاما bs +Багамы bs +Бахамски острови bs +বাহামাস bs +Bahami bs +Bahames bs +Bahamy bs +Ynysoedd Bahama bs +Μπαχάμες bs +Bahamoj bs +Bahama bs +باهاماس bs +Bahaman saaret bs +Na Bahámaí bs +Baamas bs +בהמס bs +बहामा bs +Bahamák bs +Bahamaeyjar bs +バハマ bs +បាហាម៉ា bs +바하마 bs +ປານາມາ bs +Bahamų bs +Бахами bs +Бахамас bs +Baħamas bs +ਬਾਹਾਮਾਸ bs +Bahamy bs +Багамские острова bs +Bahamasi bs +Bahamy bs +Bahami bs +Бахами bs +Bahami bs +பனாமா bs +Боҳомос bs +บาฮามา bs +Bahamalar bs +Багами bs +Багама Ороллари bs +巴哈马 bs +巴拿馬 bs +Bhutan bt +بوتان bt +Бутан bt +Бутан bt +ভূটান bt +Butañ bt +Butan bt +Bhútán bt +Bhwtan bt +Μπουτάν bt +Butano bt +Bhután bt +بوتان bt +Bhoutan bt +An Bhútáin bt +Bután bt +בהוטן bt +भूटान bt +Bhután bt +Bútan bt +ブータン bt +ប៊ូតាន bt +부탄 bt +ຖັກກ່ງວ bt +Bhutano bt +Butāna bt +Бутан bt +Бутан bt +Butan bt +ਭੁਟਾਨ bt +Butão bt +Butão bt +Butan bt +Бутан bt +Butani bt +Butan bt +Бутан bt +Butan bt +பூடான் bt +Бутон bt +ภูฏาน bt +Butan bt +Бутан bt +Бутан bt +Boutan bt +不丹 bt +不丹 bt +Botswana bw +بوتسوانا bw +Батсвана bw +Ботсуана bw +বটসওয়ানা bw +Bocvana bw +Μποτσουάνα bw +Bocvano bw +بوتسووانا bw +An Bhotsuáin bw +Botsuana bw +בוצאונה bw +बोत्सवाना bw +Botsvana bw +Botsvana bw +ボツワナ bw +បុតស្វាណា bw +보츠와나 bw +ບອດສເນີຍ bw +Botsvanos bw +Botsvāna bw +Боцвана bw +Ботсвана bw +ਬੋਟਸਵਾਨਾ bw +Botsuana bw +Ботсвана bw +Botsvana bw +Боцвана bw +Bocvana bw +பாட்ஸ்வனா bw +Ботсвана bw +บอทสวานา bw +Botsvana bw +Ботсвана bw +Боцвана bw +Boswana bw +博茨瓦纳 bw +波札那 bw +Belarus by +روسيا البيضاء by +Беларусь by +Беларус by +বেলারুস by +Belarusi by +Bjelorusija by +Bielorússia by +Bělorusko by +Belarws by +Hviderusland by +Weißrussland by +Λευκορωσία by +Belorusio by +Valgevene by +بلاروس by +Valkovenäjä by +Hvítarusland by +Bélarus by +Wyt-Rusland by +An Bhealarúis by +Bielorúsia by +בלרוס by +बेलारूस by +Bjelorusija by +Fehéroroszország by +Hvíta-Rússland by +Bielorussia by +ベラルーシ by +បេឡារុស្ស by +벨라루스 by +ເບລາລັສ by +Baltarusija by +Baltkrievija by +Белорусија by +Цагаан орос by +Hviterussland by +Wittrussland by +Wit-Rusland by +Kviterussland by +ਬੇਲਾਰੂਸ by +Białoruś by +Bielorrússia by +Беларусь by +Belarusi by +Vilges-Ruošša by +Bielorusko by +Belorusija by +Белорусија by +Belorusija by +I-Belarus by +Vitryssland by +பெலாரூசு by +Белорусиё by +เบลารุส by +Білорусія by +Белорус by +Belaruss by +白俄罗斯 by +白俄羅斯 by +Belize bz +بيليز bz +Бэлізе bz +Белийз bz +বেলিজ bz +Beliz bz +Bel?s bz +Μπελίζε bz +Belizo bz +بلیز bz +An Bheilís bz +בליז bz +बेलिज bz +Belís bz +ベリーズ bz +បេលីហ្ស bz +벨리즈 bz +ເບລຍ່ງມ bz +Belizo bz +Beliza bz +Белизе bz +Белизэ bz +Beliż bz +ਬੀਲੀਜ਼ਿ bz +Белиз bz +Белиз bz +Beliz bz +பெல்சியம் bz +Белиз bz +เบลไลซ์ bz +Beliz bz +Беліз bz +Белиз bz +伯利兹 bz +比利時 bz +Default C +Standaard C +افتراضي C +Ön Qurğulu C +Па ўмаўчаньні C +По подразбиране C +ডিফল্ট C +Dre ziouer C +Omissió C +Výchozí C +Rhagosodedig C +Standard C +Standard C +Προκαθορισμένο C +Apriora C +Predeterminado C +Vaikimisi C +Lehenetsia C +پیشفرض C +Oletus C +Forsettur C +Par défaut C +Standert C +Réamhshocrú C +Por Omisión C +ברירת מחדל C +डिफ़ॉल्ट C +Uobičajeno C +Standard C +Alapértelmezett C +Standar C +Sjálfgefið C +Predefinito C +標準 C +លំនាំដើម C +기본 C +ຄ່າປະລິຍາຍ C +Numatyta C +Noklusētais C +Почетно C +Стандарт C +Normali C +Standard C +Standard C +Standaard C +Standard C +Thuso ya Tshoganetso C +Omission C +ਮੂਲ C +Domyślnie C +Por Omissão C +Padrão C +Implicit C +По умолчанию C +Mburabuzi C +Standárda C +Štandardný C +Privzeto C +Подразумевано C +Podrazumevano C +Förval C +முன்னிருப்பு C +Пешфарзӣ C +ค่าปริยาย C +Öntanımlı C +Ğädäti C +Типовий C +Андоза C +Mặc định C +Prémetou C +Okwendalo C +默认 C +預設 C +Okwendalo C +Canada ca +Kanada ca +كندا ca +Kanada ca +Канада ca +Канада ca +কানাডা ca +Kanada ca +Kanada ca +Canadà ca +Kanada ca +Kanada ca +Καναδάς ca +Kanado ca +Canadá ca +Kanada ca +Kanada ca +کانادا ca +Kanada ca +Kanada ca +Kanada ca +Ceanada ca +Canadá ca +קנדה ca +कनाडा ca +Kanada ca +Kanada ca +Kanada ca +Kanada ca +カナダ ca +កាណាដា ca +캐나다 ca +ແຄນາດາ ca +Kanada ca +Kanāda ca +Канада ca +Канад ca +Kanada ca +Kanada ca +ਕੈਨੇਡਾ ca +Kanada ca +Canadá ca +Canadá ca +Канада ca +Kanada ca +Kanada ca +Kanada ca +Канада ca +Kanada ca +I-Canada ca +Kanada ca +கனடா ca +Канада ca +แคนาดา ca +Kanada ca +Kanada ca +Канада ca +Канада ca +加拿大 ca +加拿大 ca +Cocos (Keeling) Islands cc +Kokos Eilande cc +جزر كوكوس (كيلينغ) cc +Кокосови острови cc +কোকোস (কীলিং) দ্বীপপুঞ্জ cc +Inizi Koko (Keeling) cc +Kokosovo (Keeling) ostrvo cc +Illes Cocos (Keeling) cc +Kokosové ostrovy (Keeling) cc +Ynysoedd y Cocos (Keeling) cc +Cocos/Keeling-Inseln cc +Νήσοι Κόκος (Κήλινγκ) cc +Kokosinsuloj cc +Islas Cocos (Keeling) cc +Kookossaared cc +Cocos Irlak cc +جزایر کوکوس کیلینگ cc +Cookinsaaret cc +Îles Cocos cc +Oileán na gCócónna (Keeling) cc +Illas Cocos (Keeling) cc +איי קוקוס cc +कोकोस (कीलिंग) आइलैंड्स cc +Cocos (Keeling) Otoci cc +Kókusz-szigetek (Keeling) cc +Kókoseyjar cc +Isole Cocos (Keeling) cc +オーストラリア領ココス島 cc +កោះ Cocos (Keeling) cc +코코스 제도 cc +Kokosu salas cc +Острови Кокос (Килинг) cc +Cocos (Keeling) арлууд cc +Gżejjer Cocos (Keeling) cc +Kokosøyene cc +Cocos- (Keeling-) Inseln cc +Kokosøyane cc +ਕੋਕੋਸ(ਕਿਨਿੰਗ) ਟਾਪੂ cc +Wyspy Kokosowe (Keelinga) cc +Ilhas Cocos (Keeling) cc +Ilhas Cocos cc +Insulele Cocos (Keeling) cc +Кокосовые (Килинг) острова cc +Ibirwa Kokosi cc +Kokosullut cc +Kokosove Ostrovy cc +Kokosovi (Keelingovi) otoki cc +Кокосова (Килингова) острва cc +Kokosova (Kilingova) ostrva cc +Kokosöarna cc +கோகோஸ் (கீலிங்) தீவுகள் cc +Ҷазираи Кокос (Килинг) cc +หมู่เกาะโคคอส (Keeling) cc +Keeling Adaları cc +Kokos (Keeling) Utrawları cc +Кокосові острови cc +Кокос (Килинг) Ороллари cc +Iyes Cocos cc +科科斯群岛 cc +可可斯群島 cc +Congo, The Democratic Republic of the cd +Kongo, Demokratiese republiek van die cd +Дэмакратычная Рэспубліка Конга cd +ДР Конго cd +কঙ্গোর গণতান্ত্রিক প্রজাতন্ত্র cd +Kongo, Demokratska republika cd +Congo, República Democràtica del cd +Kongo cd +Congo, Gweriniaeth Democrataidd y cd +Congo, den demokratiske republik cd +Kongo, Republik cd +Κονγκό, Δημοκρατία του cd +Kongo, la Demokratia Respubliko de la cd +Congo, República democrática del cd +Kongo (DV) cd +Kongoko Errepublika Demokratikoa cd +Kongon demokraattinen tasavalta cd +République Démocratique du Congo cd +Kongo, de democratische republyk van de cd +Poblacht Dhaonlathach an Chongó cd +Congo, República Democrática do cd +קונגו, הרפובליקה הדמוקרטית של cd +डेमोक्रेटिक रिपब्लिक ऑफ कॉगो cd +Kongói Demokratikus Köztársaság cd +Kongó, Austur cd +Congo, Repubblica Democratica del cd +コンゴ,民主共和国 cd +សាធារណរដ្ឋប្រជាធិបតេយ្យកុងហ្គោ cd +Kongo demokratinė respublika cd +Kongo demokrātiskā republika cd +Конго, Демократска Република на cd +Kongo (RD) cd +Kongo cd +Kongo (De demokraatsche Republiek) cd +Congo, Democratische republiek cd +Kongo cd +ਕਾਂਗੋ, ਲੋਕਤੰਤਰੀ ਗਣਰਾਜ cd +Republika Demokratyczna Kongo cd +Congo, República Democrática do cd +República Democrática do Congo cd +Congo, Republica Democrată cd +Демократическая Республика Конго cd +Kongo, Repubulika Iharanira Demokarasi ya cd +Kongo cd +Demokratická Republika Kongo cd +Kongo, demokratična republika cd +Конго, Демократска Република cd +Kongo, Demokratska Republika cd +Demokratiska republiken Kongo cd +கான்கோ, குடியரசு cd +Ҷумҳурии демократии Ҳонконг cd +สาธารณรัฐประชาธิปไตยคองโก cd +Demokratik Kongo Cumhuriyeti cd +Kongo, Demokrat Cömhüriäte cd +Конго, демократична республіка cd +Конго Демократик Республикаси cd +Congo, republike democratike cd +刚果民主共和国 cd +剛果民主共和國 cd +Central African Republic cf +Sentrale Afrika Republiek cf +جمهورية أفريقيا الوسطى cf +Цэнтральнаафрыканская Рэспубліка cf +ЦАР cf +মধ্য আফ্রিকান রিপাবলিক cf +Republik centrafricaine cf +Centralnoafrička Republika cf +República Centro Africana cf +Středoafrická republika cf +Gweriniaeth Canolig Affrica cf +Central-afrikanske Republik cf +Zentralafrikanische Republik cf +Δημοκρατία Κεντρικής Αφρικής cf +Mezafrika Respubliko cf +República Centroafricana cf +Kesk-Aafrika Vabariik cf +Afrika Erdiko Errepublika cf +جمهوری افریقای مرکزی cf +Keski-Afrikan tasavalta cf +République centrafricaine cf +Sintraal Afrikaanse Republyk cf +Poblacht na hAfraice Láir cf +República Centro Africana cf +הרפובליקה האפריקנית התיכונה cf +सेंट्रल अफ्रीकन रिपब्लिक cf +Centralna Afrička Republika cf +Közép-Afrikai Köztársaság cf +Mið-Afríkulýðveldið cf +Repubblica Centrafricana cf +中央アフリカ共和国 cf +សាធារណរដ្ឋអាហ្វ្រិកកណ្ដាល cf +중앙 아프리카 공화국 cf +ໂດມິນິກັນ cf +Centrinės Afrikos Respublika cf +Centrālāfrikas republika cf +Централноафриканска Република cf +Төв африкын ард улс cf +Repubblika Ċentrali Afrikana cf +Den sentralafrikanske republikk cf +Zentraalafrikaansche Republiek cf +Centraal Afrikaanse Republiek cf +Den sentralafrikanske republikken cf +ਕੇਂਦਰੀ ਅਫਰੀਕੀ ਗਣਰਾਜ cf +Republika Środkowej Afryki cf +República Central Africana cf +República da África Central cf +Republica Centrafricană cf +Центрально-Африканская Республика cf +Repubulika ya Santara Afurika cf +Guovddášafrihkálaš republihkka cf +Stredoafrická Republika cf +Centralnoafriška republika cf +Централноафричка Република cf +Centralnoafrička Republika cf +Centralafrikanska Republiken cf +மைய ஆப்பிரிக்க குடியரசு cf +Ҷумҳурии Африқои Марказӣ cf +สาธารณรัฐอัฟริกากลาง cf +Orta Afrika Cumhuriyeti cf +Üzäk Afrika Cömhüriäte cf +Центральна африканська республіка cf +Марказий Африка Республикаси cf +Cộng hoà Trung Phi cf +Cintrafrike cf +中非共和国 cf +多明尼加共和國 cf +Congo cg +Konsole cg +الكونغو cg +Конга cg +Конго cg +কঙ্গো cg +Kongo cg +Kongo cg +Kongo cg +Kongo cg +Κονγκό cg +Kongo (Brazavila) cg +Kongo cg +Kongo cg +کنگو cg +Kongo cg +Kongo cg +Congó cg +קונגו cg +कोंगो cg +Kongo cg +Kongó cg +Kongó, Vestur cg +コンゴ cg +កុងហ្គោ cg +콩고 cg +ຄອນໂໍຊລ cg +Kongo cg +Kongo cg +Конго cg +Конго cg +Kongo cg +Kongo-Brazaville cg +Kongo cg +Kongo-Brazaville cg +ਕਾਂਗੋ cg +Kongo cg +Конго cg +Kongo cg +Kongo cg +Kongo cg +Kongo cg +Конго cg +Kongo cg +Kongo cg +கான்கோ cg +Конго cg +คองโก cg +Kongo cg +Kongo cg +Конго cg +Конго cg +刚果 cg +剛果 cg +Switzerland ch +Switserland ch +سويسرا ch +İsveçrə ch +Швэйцарыя ch +Швейцария ch +সুইজারল্যাণ্ড ch +Suis ch +Švicarska ch +Suïssa ch +Švýcarsko ch +Y Swistir ch +Schweiz ch +Schweiz ch +Ελβετία ch +Svislando ch +Suiza ch +Šveits ch +Suitza ch +سوییس ch +Sveitsi ch +Suisse ch +Switserlân ch +An Eilvéis ch +Suíza ch +שוייץ ch +स्विट्जरलैंड ch +Švicarska ch +Svájc ch +Swiss ch +Sviss ch +Svizzera ch +スイス ch +ស្វ៊ីស ch +스위스 ch +ສະວິສເຊີແລນ ch +Šveicarija ch +Šveice ch +Швајцарија ch +Швецарь ch +Svizzera ch +Sveits ch +Swiez ch +Zwitserland ch +Sveits ch +Suissa ch +ਸਵਿਟਜ਼ਰਲੈਂਡ ch +Szwajcaria ch +Suíça ch +Suíça ch +Elveţia ch +Швейцария ch +Swazilande ch +Šveica ch +Švajčiarsko ch +Švica ch +Швајцарска ch +Švajcarska ch +I-Switzerland ch +Schweiz ch +சுவிட்சர்லாந்து ch +Свитзерланд ch +สวิสเซอร์แลนด์ ch +İsviçre ch +İswiçrä ch +Швейцарія ch +Швейцария ch +Thuỵ Sĩ ch +Swisse ch +瑞士 ch +瑞士 ch +Cote d'ivoire ci +ساحل العاج ci +Бераг Слановай Косьці ci +Кот Дивоар ci +Aod an Olifant ci +Obala Slonovače ci +Costa d'ivori ci +Pobřeží slonoviny ci +Y Traeth Ifori ci +Elfenbenskysten ci +Ακτή Ελεφαντοστού ci +Eburio ci +Costa de Marfil ci +Cote d'Ivoire ci +Boli kosta ci +کُتِ دیوُیر ci +Côte d'Ivoire ci +Ivoorkust ci +An Cósta Eabhair ci +कोट डि'वॉरे ci +Baci kocke ci +Elefántcsontpart ci +Fílabeinsströndin ci +Costa d'Avorio ci +コートジボアール ci +កូដឌីវ័រ ci +코트디부아르 ci +ປ່ອຍຫມາກກະລອກ ci +Kotdivuāra ci +Брегот на Слоновата Коска ci +Kosta tal-Avorju ci +Elfenbenskysten ci +Elfenbeenküst ci +Ivoorkust ci +Elfenbeinskysten ci +ਕਾਂਟੋ ਡੀਵੋਇਰੀ ci +Wybrzeże Kości Słoniowej ci +Costa do Marfim ci +Coasta de Azur ci +Кот Д'Ивуар ci +Kote divuware ci +Elfenčalánriddu ci +Slonokoščena obala ci +Обала слоноваче ci +Obala slonovače ci +Elfenbenskusten ci +Соҳили Оҷ ci +อ่าวไอวอรี ci +Кот Д'Івуар ci +Кот д'Ивуар ci +Bờ biển ngà ci +Coisse d' Ivwere ci +科特迪瓦 ci +象牙海岸 ci +Cook islands ck +Cook Eilande ck +جزر كوك ck +Астравы Кука ck +Острови Кук ck +কুক দ্বীপপুঞ্জ ck +Inizi Kook ck +Kukova ostrva ck +Illes Cook ck +Cookovy ostrovy ck +Ynysoedd Cook ck +Cook-øerne ck +Cook-Inseln ck +Νησιά Κουκ ck +Kukinsuloj ck +Islas Cook ck +Cooki saared ck +Cook Irlak ck +جزایر کوک ck +Cooksaaret ck +Îles Cook ck +Oileáin Chook ck +Illas Cook ck +איי קוק ck +कुक आइलैंड ck +Cook otoci ck +Cook-szigetek ck +Cooks-eyjar ck +Isole Cook ck +ニュージーランド自治領クック諸島 ck +កោះ Cook ck +쿡 제도 ck +ຄຸກກີ້ ck +Kuko salų ck +Kuka salas ck +Кукови острови ck +Cook арлууд ck +Gżejjer Cook ck +Cookøyene ck +Cookinseln ck +Cook Eilanden ck +Cookøyane ck +ਕੁੱਕ ਟਾਪੂ ck +Wyspy Cooka ck +Ilhas Cook ck +Ilhas Cook ck +Insulele Cook ck +Острова Кука ck +Ibirwa bya Kuke ck +Cooksullut ck +Cookove ostrovy ck +Cookovi otoki ck +Кукова острва ck +Kukova ostrva ck +Cooköarna ck +குக் தீவு ck +Ҷазираи Кук ck +หมู่เกาะคุก ck +Cook Adaları ck +Kok Utrawları ck +Острови Кука ck +Кук Ороллари ck +Iyes Cook ck +库克群岛 ck +庫克群島 ck +Chile cl +Chilië cl +تشيلي cl +Şili cl +Чылі cl +Чили cl +চিলি cl +Čile cl +Xile cl +Tsile cl +Χιλή cl +Ĉilio cl +Tšiili cl +Txile cl +شیلی cl +Chili cl +Chili cl +An tSile cl +צ'ילה cl +चिली cl +Čile cl +Chili cl +Cile cl +チリ cl +ឈីលី cl +칠레 cl +ຊີລີ cl +Čilė cl +Čīle cl +Чиле cl +Чили cl +Ċile cl +Chili cl +ਚਿੱਲੀ cl +Cile cl +Чили cl +Shili cl +Čile cl +Čile cl +Чиле cl +Čile cl +I-Chile cl +சிலி cl +Чилли cl +ชิลี cl +Şili cl +Çili cl +Чилі cl +Чили cl +Chi lê cl +Tchili cl +智利 cl +智利 cl +Cameroon cm +Kameroon cm +الكاميرون cm +Камэрун cm +Камерун cm +ক্যামেরুন cm +Kameroun cm +Kamerun cm +Camerun cm +Kamerun cm +Y Camer?n cm +Cameroun cm +Kamerun cm +Καμερούν cm +Kameruno cm +Camerún cm +Kamerun cm +Kamerun cm +کامرون cm +Kamerun cm +Cameroun cm +Kameroen cm +Camarún cm +Camerún cm +קמרון cm +कैमरून cm +Kamerun cm +Kamerun cm +Kamerún cm +Camerun cm +カメルーン cm +កាមេរូន cm +카메룬 cm +ຕາລາງງານ - K cm +Kamerūno cm +Kamerūna cm +Камерун cm +Камерун cm +Kamerun cm +Kamerun cm +Kamerun cm +Cameroen cm +Kamerun cm +ਕੈਮਰੂਨ cm +Kamerun cm +Camarões cm +Camarões cm +Camerun cm +Камерун cm +Kameruni cm +Kamerun cm +Komerun cm +Kamerun cm +Камерун cm +Kamerun cm +Kamerun cm +கமீரூன் cm +Камерун cm +คาเมรูน cm +Kamerun cm +Kameroon cm +Камерун cm +Камерун cm +Camrone cm +喀麦隆 cm +喀麥隆 cm +China cn +الصين cn +Çin cn +Кітай cn +Китай cn +চীন cn +Sina cn +Kina cn +Xina cn +Čína cn +Tseina cn +Kina cn +Κίνα cn +Ĉinujo cn +Hiina cn +Txina cn +چین cn +Kiina cn +Kina cn +Chine cn +An tSín cn +סין cn +चीन cn +Kina cn +Kína cn +Cina cn +Kína cn +Cina cn +中国 cn +ចិន cn +중국 cn +ຈີນ cn +Kinija cn +Ķīna cn +Кина cn +Хятад cn +Ċina cn +Kina cn +Kina cn +Xina cn +ਚੀਨ cn +Chiny cn +Китай cn +Ubushinwa cn +Kiinná cn +Čína cn +Kitajska cn +Кина cn +Kina cn +I-China cn +Kina cn +சீனா cn +Хитой cn +จีน cn +Çin cn +Çin cn +Китай cn +Хитой cn +Trung Quốc cn +Chine cn +中国 cn +中國 cn +Colombia co +Colombië co +كولمبيا co +Калюмбія co +Колумбия co +কলোম্বিয়া co +Kolumbi co +Kolumbija co +Colòmbia co +Kolumbie co +Kolumbien co +Κολομβία co +Kolumbio co +Kolumbia co +Kolonbia co +کلمبیا co +Kolumbia co +Colombie co +Columbia co +An Cholóim co +Colómbia co +קולומביה co +कोलम्बिया co +Kolumbija co +Kolumbia co +Kólumbía co +コロンビア co +កូឡុំប៊ី co +콜롬비아 co +ໂຄລຳເບີຍ co +Kolumbija co +Kolumbija co +Колумбија co +Колумб co +Kolumbja co +Kolumbien co +Columbia co +ਕੋਲੰਬੀਆ co +Kolumbia co +Colômbia co +Colômbia co +Columbia co +Колумбия co +Kolombiya co +Kolombia co +Kolumbia co +Kolumbija co +Колумбија co +Kolumbija co +I-Colombia co +கொலம்பியா co +Колумбия co +โคลัมเบีย co +Kolombiya co +Kolombia co +Колумбія co +Колумбия co +Colombeye co +Columbia co +哥伦比亚 co +哥倫比亞 co +Costa Rica cr +كوستاريكا cr +Коста Рыка cr +Коста Рика cr +কোস্টা রিকা cr +Kosta Rika cr +Kostarika cr +Kostarika cr +Κόστα Ρίκα cr +Kostariko cr +کاستاریکا cr +Kosta Rika cr +Cósta Ríce cr +קוסטה ריקה cr +कोस्टा रिका cr +Kosta rika cr +Kostaríka cr +コスタリカ cr +កូស្តារីកា cr +코스타 리카 cr +ໂຄເອເທີຍ cr +Kosta Rika cr +Kostarika cr +Коста Рика cr +Коста Рика cr +ਕੋਸਟਾ ਰੀਕਾ cr +Kostaryka cr +Коста-Рика cr +Kosita Rika cr +Kostarika cr +Kostarika cr +Костарика cr +Kostarika cr +I-Costa Rica cr +கோஸ்டா ரிகா cr +Коста Рика cr +คอสตาริกา cr +Kosta Rika cr +Kosta Rika cr +Коста-Ріка cr +Коста Рика cr +哥斯达黎加 cr +哥斯大黎加 cr +Cuba cu +Kuba cu +كوبا cu +Куба cu +Куба cu +কিউবা cu +Kuba cu +Kuba cu +Kuba cu +Ciwba cu +Kuba cu +Κούβα cu +Kubo cu +Kuuba cu +Kuba cu +کوبا cu +Kuuba cu +Kuba cu +Cúba cu +קובה cu +क्यूबा cu +Kuba cu +Kuba cu +Kúba cu +キューバ cu +គុយបា cu +쿠바 cu +ເກມໄພ່ cu +Kuba cu +Kuba cu +Куба cu +Куба cu +Kuba cu +Kuba cu +ਕਿਊਬਾ cu +Kuba cu +Куба cu +Kuba cu +Kuba cu +Kuba cu +Куба cu +Kuba cu +I-Cuba cu +Kuba cu +கியுபா cu +Куба cu +คิวบา cu +Küba cu +Kuba cu +Куба cu +Куба cu +古巴 cu +古巴 cu +Cape Verde cv +Kaap Verde cv +كاب فيردي cv +Кабо Верде cv +কেপ ভারডি cv +Penn Verde cv +Zelenortska ostrva cv +Cap Verd cv +Kapverdy cv +Cape Ferde cv +Kapverdiske øer cv +Cap Verdische Inseln cv +Πράσινο Ακρωτήριο cv +Kapo-Verdo cv +Cabo Verde cv +Roheneeme saared cv +Cabo Verde cv +کیپورده cv +Kap Verde cv +Cap vert cv +Kaap Verdië cv +Rinn Verde cv +Cabo Verde cv +כף וורדה cv +कैप वर्डे cv +Zöldfoki-szigetek cv +Grænhöfðaeyjar cv +Capo Verde cv +カーポベルデ cv +កាបវែរ cv +카보베르데 cv +ເກມໄພ່ cv +Kabaverde cv +Кејп Верде cv +Капе Вэрдэ cv +Kapp Verde cv +Kap Verde cv +Kaap Verdië cv +Kapp Verde cv +ਕੇਪ ਵੀਰਡੀ cv +Cabo Verde cv +Cabo Verde cv +Capul Verde cv +Кабо-Верде cv +Kapu Veri cv +Кејп Верд cv +Kejp Verd cv +Kap Verde cv +கேப் வெர்ட் cv +Димоғи Верде cv +แหลมเวอร์ดี cv +Kape Verde cv +Кабо-Верде cv +Кейп Верде cv +Cap Vert cv +佛得角 cv +維德角 cv +Christmas Island cx +Kersfees Eiland cx +جزر الكريسماس cx +Остров Рождество cx +ক্রিস্টমাস দ্বীপ cx +Inizi Nedeleg cx +Božično ostrvo cx +Illa de Pascua cx +Vánoční ostrovy cx +Ynys y Nadolig cx +Juleøen cx +Weihnachtsinsel cx +Νήσος των Χριστουγέννων cx +Kristnaskinsulo cx +Islas Christmas cx +Jõulusaar cx +Eguberri Irla cx +جزایر کریسمس cx +Joulusaari cx +Île de Noël cx +Christmas Eilân cx +Oileán na Nollag cx +Illas Christmas cx +איי כריסטמס cx +क्रिसमस आइलैंड cx +Uskršnji otoci cx +Karácsony-szigetek cx +Jólaey cx +Isola Christmas cx +クリスマス諸島 cx +កោះ Christmas cx +크리스마스 섬 cx +ຄິດສະຕອລ cx +Kalėdų salos cx +Ziemassvētku salas cx +Велигденски Острови cx +Кристмас арлууд cx +Christmasøya cx +Wiehnachtsinsel cx +Christmasøya cx +ਕ੍ਰਿਸਮਿਸ ਟਾਪੂ cx +Wyspy Bożego Narodzenia cx +Ilhas Natal cx +Ilhas do Natal cx +Insulele Christmas cx +Остров Рождества cx +Ikirwa cya Noheli cx +Christmassuollu cx +Vianočné Ostrovy cx +Božični otok cx +Божићно острво cx +Božićno ostrvo cx +Julön cx +கிருஸ்துமஸ் தீவு cx +Ҷазираи Кристмас cx +เกาะคริสต์มาส cx +Yılbaşı Adaları cx +Christmas Utrawları cx +Острів Різдва cx +Крисмас Ороли cx +Đảo giáng sinh cx +圣诞岛 cx +聖誕島 cx +Cyprus cy +Siprus cy +قبرص cy +Кіпр cy +Кипър cy +সাইপ্রাস cy +Chipr cy +Kipar cy +Xipre cy +Kypr cy +Cypern cy +Zypern cy +Κύπρος cy +Cipro cy +Chipre cy +Küpros cy +Txipre cy +قبرس cy +Kypros cy +Chypre cy +An Chipir cy +Chipre cy +קפריסין cy +साइप्रस cy +Cipar cy +Ciprus cy +Kýpur cy +Cipro cy +キプロス cy +ស៊ីពរ៍ cy +키프로스 cy +ບີບອັດ cy +Kipro cy +Kipra cy +Кипар cy +Сипрус cy +Ċipru cy +Kypros cy +Zypern cy +Kypros cy +ਕਿਉਪਰਸ cy +Cypr cy +Chipre cy +Chipre cy +Cipru cy +Кипр cy +Shipure cy +Kypros cy +Ciper cy +Кипар cy +Kipar cy +Cypern cy +சிப்ரஸ் cy +Кипр cy +ไซปรัส cy +Kıbrıs cy +Kiper cy +Кіпр cy +Кипр cy +Síp cy +Chîpe cy +塞浦路斯 cy +賽普勒斯 cy +Czechia cz +Czechië cz +التشيك cz +Çex Respublikası cz +Чэхія cz +Чешка република cz +চেকিয়া cz +Tchekia cz +Češka cz +Txèquia cz +Česko cz +Y Weriniaeth Siec cz +Tjekkiet cz +Tschechien cz +Τσεχία cz +Ĉeĥio cz +República Checa cz +Tšehhi cz +Txekia cz +چک cz +Tsekki cz +République tchèque cz +Tsjechië cz +Poblacht na Seice cz +Chéquia cz +צ'כיה cz +चेक cz +Češka cz +Csehország cz +Tékkland cz +Repubblica Ceca cz +チェコ cz +ឆេក cz +체코 cz +Čekija cz +Čehija cz +Чешка cz +Чехиа cz +Cżekia cz +Tsjekkia cz +Tschechien cz +Tsjechië cz +Tsjekkia cz +Chèquia cz +ਚੈੱਚੀਆ cz +Czechy cz +República Checa cz +República Tcheca cz +Cehia cz +Чехия cz +Ceke cz +Čeahkka cz +Česko cz +Češka cz +Чешка cz +Češka cz +I-Czechia cz +Tjeckien cz +செக்யா cz +Чехия cz +เชค cz +Çek Cumhuriyeti cz +Çexiä cz +Чехія cz +Чехия cz +Séc cz +Tchekeye cz +捷克 cz +捷克 cz +Germany de +Duitsland de +ألمانيا de +Almaniya de +Нямеччына de +Германия de +জার্মানি de +Alamagn de +Njemačka de +Alemanya de +Německo de +Yr Almaen de +Tyskland de +Deutschland de +Γερμανία de +Germanio de +Alemania de +Saksamaa de +Alemania de +آلمان de +Saksa de +Týskland de +Allemagne de +Dûtslân de +An Ghearmáin de +Alemaña de +גרמניה de +जर्मनी de +Njemačka de +Németország de +Jerman de +Þýskaland de +Germania de +ドイツ de +អាល្លឺម៉ង់ de +독일 de +ເຍລລະມັນນີ de +Vokietija de +Vācija de +Германија de +Герман de +Jerman de +Ġermanja de +Tyskland de +Düütschland de +Duitsland de +Tyskland de +Alemanya de +ਜਰਮਨੀ de +Niemcy de +Alemanha de +Alemanha de +Germania de +Германия de +Ubudage de +Duiska de +Nemecko de +Nemčija de +Немачка de +Nemačka de +I-Germany de +Tyskland de +ஜெர்மனி de +Олмон de +เยอรมันนี de +Almanya de +Almania de +Німеччина de +Олмония de +Đức de +Almagne de +德国 de +德國 de +IJalimani de +Djibouti dj +جيبوتي dj +Джыбуці dj +Джибути dj +জিবৌতি dj +Đibuti dj +Džibuti dj +Jib?ti dj +Dschibuti dj +Τζιμπουτί dj +Ĝibutio dj +جیبوتی dj +Xibuti dj +ג'יבוטי dj +डिबौती dj +Džibuti dj +Dzsibuti dj +Djíbútí dj +Gibuti dj +ジブチ dj +ហ្ស៊ីបូទី dj +지부티 dj +ພັດພາ dj +Džibutis dj +Džibutija dj +Џибути dj +Жибут dj +Dġibuti dj +Dschibouti dj +ਡਜੀਬੁਉਟੀ dj +Dżibuti dj +Djibuti dj +Djibuti dj +Джибути dj +Jibuti dj +Djibuhti dj +Džibuty dj +Džibuti dj +Џибути dj +Džibuti dj +I-Djibouti dj +டிஜிபொடி dj +Ҷибойти dj +จิบูติ dj +Cibuti dj +Djibuti dj +Джібуті dj +Жибути dj +吉布提 dj +吉布地 dj +Denmark dk +Denemarke dk +الدنمارك dk +Danimarka dk +Данія dk +Дания dk +ডেনমার্ক dk +Danmark dk +Danska dk +Dinamarca dk +Dánsko dk +Denmarc dk +Danmark dk +Dänemark dk +Δανία dk +Danlando dk +Dinamarca dk +Taani dk +Danimarka dk +دانمارک dk +Tanska dk +Danmark dk +Danemark dk +Denemarken dk +An Danmhairg dk +Dinamarca dk +דנמרק dk +डेनमार्क dk +Danska dk +Dánia dk +Danmörk dk +Danimarca dk +デンマーク dk +ដាណឺម៉ាក dk +덴마크 dk +ເດນມາກ dk +Danija dk +Dānija dk +Данска dk +Дани dk +Danimarka dk +Danmark dk +Dänmark dk +Denemarken dk +Danmark dk +Dinamarca dk +ਡੈੱਨਮਾਰਕ dk +Dania dk +Dinamarca dk +Dinamarca dk +Danemarca dk +Дания dk +Danimarike dk +Dánmárku dk +Dánsko dk +Danska dk +Данска dk +Danska dk +I-Denmark dk +Danmark dk +டென்மார்க் dk +Денмарк dk +เดนมาร์ก dk +Danimarka dk +Dania dk +Данія dk +Дания dk +Đan Mạch dk +Daenmåtche dk +丹麦 dk +丹麥 dk +Dominica dm +Dominisië dm +دومينيكا dm +Дамініка dm +Доминика dm +ডমিনিকা dm +Dominik dm +Dominika dm +Dominika dm +Dominikanische Republik dm +Ντομίνικα dm +Dominiko dm +دومینیکا dm +Dominique dm +Doiminice dm +דומינקה dm +डोमिनिका dm +Dominika dm +Dóminíka dm +ドミニカ dm +ដូមីនីកា dm +도미니카 dm +ໂລມາເນີຍ dm +Dominika dm +Dominika dm +Доминика dm +Доминика dm +Dominika dm +ਡੋਮਾਨੀਕਾ dm +Dominika dm +Dominicana dm +Доминика dm +Dominikani dm +Dominikánsko dm +Dominikanska republika dm +Доминика dm +Dominika dm +டொமினிகா dm +Доминика dm +โดมินากัน dm +Dominik dm +Dominika dm +Домініка dm +Доминика dm +Dominike dm +多米尼加 dm +多明尼加 dm +Dominican Republic do +Dominikaanse Republiek do +جمهورية الدومينيكان do +Dominik Respublikası do +Дамініканская Рэспубліка do +Доминиканска република do +ডমিনিকান রিপাবলিক do +Republik Dominikan do +Dominikanska Republika do +República Dominicana do +Dominikánská republika do +Gweriniaeth Dominica do +Dominikanske Republik do +Dominikanische Republik do +Δομινικανή Δημοκρατία do +Dominika Respubliko do +República Dominicana do +Dominikaani Vabariik do +Dominikar Errepublika do +جمهوری دامینیکن do +Dominikaaninen tasavalta do +République dominicaine do +Dominicaanse Republyk do +An Phoblacht Dhoiminiceach do +República Dominicana do +הרפובליקה הדומיניקנית do +डोमिनिकन रिपब्लिक do +Dominikanska Republika do +Dominikai Köztársaság do +Republik Dominika do +Dóminíska lýðveldið do +Repubblica Dominicana do +ドミニカ共和国 do +សាធារណរដ្ឋដូមីនីកែន do +도미니카 공화국 do +ໂດມິນີກັນ do +Dominikos Respublika do +Dominikas Republika do +Доминиканска Република do +Домникан ард улс do +Repubblika Dominikana do +Den dominikanske republikk do +Dominikaansche Republiek do +Dominicaanse Republiek do +Den dominikanske republikken do +Republica Dominicana do +ਡੋਮਾਨੀਕਾ ਗਣਰਾਜ do +Dominikana do +República Dominicana do +República Dominicana do +Republica Dominicană do +Доминиканская республика do +Repubulika Dominikani do +Dominihkalaš republihkka do +Dominikánska republika do +Dominikanska republika do +Доминиканска Република do +Dominikanska Republika do +I-Dominican Republic do +Dominikanska republiken do +டொமினிக்கன் குடியரசு do +Ҷумҳурии Доминика do +สาธารณรัฐโดมินิกัน do +Dominik Cumhuriyeti do +Dominika Cömhüriäte do +Домініканська республіка do +Доминикана Республикаси do +Muvhuso wa Dominican do +Cộng hoà Dominican do +Republike Dominikinne do +IRepublic yeDominican do +多米尼加共和国 do +多明尼加共和國 do +Algeria dz +Algerië dz +الجزائر dz +Альжыр dz +Алжир dz +অ্যালজেরিয়া dz +Aljeri dz +Alžir dz +Algèria dz +Alžírsko dz +Algeriet dz +Algerien dz +Αλγερία dz +Algerio dz +Argelia dz +Alžeeria dz +الجزیره dz +Algérie dz +Algerije dz +An Ailgéir dz +Alxéria dz +אלג'יריה dz +अल्जीरिया dz +Alžir dz +Algéria dz +Alsír dz +アルジェリア dz +អាល់ហ្សេរី dz +알제리 dz +ບັນກາເລີຍ dz +Alžyras dz +Alžīrija dz +Алжир dz +Алжер dz +Alġerija dz +Algerie dz +Algerien dz +Algerije dz +Algerie dz +ਅਲਜੀਰੀਆ dz +Algieria dz +Argélia dz +Argélia dz +Алжир dz +Aligeriya dz +Alžírsko dz +Alžirija dz +Алжир dz +Alžir dz +I-Algeria dz +Algeriet dz +அல்ஜிரியா dz +Алҷазоир dz +อัลจีเรีย dz +Aljır dz +Алжир dz +Жазоир dz +Aldjereye dz +阿尔及利亚 dz +阿爾及利亞 dz +Equador ec +Ewenaar ec +الإكوادور ec +Ekvator ec +Эквадор ec +Еквадор ec +ইকুয়েডর ec +Ecuador ec +Ekvador ec +Ekvádor ec +Ecwador ec +Ecuador ec +Ισημερινός ec +Ekvadoro ec +Ecuador ec +Ekuador ec +اکوادور ec +Équateur ec +Eacuadór ec +Ecuador ec +אקוודור ec +इक्वेडॉर ec +Ekvador ec +Ecuador ec +Ekvador ec +Ecuador ec +エクアドル ec +អេក្វាឌ័រ ec +에콰도르 ec +ເອກໍດໍ ec +Ekvadoras ec +Ekvadora ec +Еквадор ec +Эквадор ec +Ekwador ec +Ecuador ec +Ecuador ec +Ecuador ec +ਏਕਾਵੇਡਰ ec +Ekwador ec +Ecuador ec +Эквадор ec +Ekwateri ec +Ekvador ec +Ekvádor ec +Ekvador ec +Еквадор ec +Ekvador ec +I-Equador ec +ஈக்வெடார் ec +Эквадор ec +เอกวาดอร์ ec +Ekvator ec +Еквадор ec +Эквадор ec +Ecwåteur ec +厄瓜多尔 ec +厄瓜多 ec +Estonia ee +Estlandies ee +استونيا ee +Estoniya ee +Эстонія ee +Естония ee +এস্টোনিয়া ee +Estonija ee +Estònia ee +Estonsko ee +Estland ee +Estland ee +Εσθονία ee +Estlando ee +Eesti ee +استونی ee +Eesti ee +Estonie ee +Estland ee +An Eastóin ee +אסטוניה ee +एस्तोनिया ee +Estonija ee +Észtország ee +Eistland ee +エストニア ee +អេស្តូនី ee +에스토니아 ee +ເອໂທເນີຍ ee +Estija ee +Igaunija ee +Естонија ee +Эстони ee +Estonja ee +Estland ee +Estland ee +Estland ee +Estland ee +Estònia ee +ਈਸਟੋਨੀਆ ee +Estónia ee +Estônia ee +Эстония ee +Esitoniya ee +Estteeana ee +Estónsko ee +Estonija ee +Естонија ee +Estonija ee +I-Estonia ee +Estland ee +எசுடோனியா ee +Эстония ee +เอสโทเนีย ee +Estonya ee +Естонія ee +Эстония ee +Estoneye ee +爱沙尼亚 ee +愛沙尼亞 ee +Egypt eg +Egipte eg +مصر eg +Misir eg +Эгіпэт eg +Египет eg +মিশর eg +Ejipt eg +Egipat eg +Egipte eg +Yr Aifft eg +Egypten eg +Ägypten eg +Αίγυπτος eg +Egiptujo eg +Egipto eg +Egiptus eg +Egipto eg +مصر eg +Egypti eg +Egyptaland eg +Égypte eg +Egypte eg +An Éigipt eg +Exipto eg +מצרים eg +इजिप्त eg +Egipat eg +Egyiptom eg +Egyptaland eg +Egitto eg +エジプト eg +អេហ្ស៊ីប eg +이집트 eg +ອີຢີບ eg +Egiptas eg +Ēģipte eg +Египет eg +Египт eg +Mesir eg +Eġittu eg +Ägypten eg +Egypte eg +Egepeta eg +ਮਿਸਰ eg +Egipt eg +Egipto eg +Egito eg +Egipt eg +Египет eg +Misiri eg +Egypta eg +Egipt eg +Египат eg +Egipat eg +I-Egypt eg +Egypten eg +எகிப்து eg +Миср eg +อียิปต์ eg +Mısır eg +Mısır eg +Єгипет eg +Миср eg +Ai Cập eg +Edjipe eg +埃及 eg +埃及 eg +Igibhithe eg +Western Sahara eh +Westelike Sahara eh +الصحراء الغربية eh +Заходняя Сахара eh +Западна Сахара eh +পশ্চিম সাহারা eh +Sahara occidental eh +Zapadna Sahara eh +Sàhara Occidental eh +Západní Sahara eh +Gorllewin Sahara eh +Vestsahara eh +Westsahara eh +Δυτική Σαχάρα eh +Okcidenta Saharo eh +Sahara occidental eh +Lääne-Sahara eh +Mendebaldeko Sahara eh +صحرای غربی eh +Länsi-Sahara eh +Sahara occidental eh +West Sahara eh +An Sahára Thiar eh +Saara Ocidental eh +מערב סהרה eh +पश्चिमी सहारा eh +Westerm Sahara eh +Nyugat-Szahara eh +Vestur-Sahara eh +Sahara Occidentale eh +西サハラ eh +សាហារ៉ាខាងលិច eh +서사하라 eh +ພື້ນທີ່ທຳງານ eh +Vakarų Sahara eh +Rietumsahāra eh +Западна Сахара eh +Барууг сахар eh +Saħara tal-Punent eh +Vest-Sahara eh +Westsahara eh +West Sahara eh +Vest-Sahara eh +ਦੱਖਣੀ ਸਹਾਰਾ eh +Zachodnia Sahara eh +Sara Ocidental eh +Sahara Ocidental eh +Sahara de Vest eh +Западная Сахара eh +Sahara y'Iburengerazuba eh +Oarje-Sahara eh +Západna Sahara eh +Zahodna Sahara eh +Западна Сахара eh +Zapadna Sahara eh +Västsahara eh +மேற்கத்திய சஹாரா eh +Саҳрои Ғарбӣ eh +ซาฮาร่าตะวันตก eh +Batı Sahara eh +Batış Sahara eh +Західна Сахара eh +Ғарбий Сахара eh +Tây Sahara eh +Sara Coûtchantrece eh +西撒哈拉 eh +西盛哈拉 eh +Eritrea er +اريتريا er +Эрытрэя er +Еритрея er +এরিট্রিয়া er +Eritre er +Eritreja er +Ερυθραία er +Eritreo er +اریتره er +Érythrée er +Eiritré er +אריתריאה er +एरिट्रीया er +Eritreja er +Erítrea er +エリトリア er +អេរីទ្រា er +에리트레아 er +ແກ້ໄຂແຟ້ມທຳງານ er +Eritrėja er +Eritreja er +Еритреја er +Эритреа er +ਈਰੀਟਰੀਆ er +Erytrea er +Eritreia er +Eritréia er +Эритрея er +Eritereya er +Eritreja er +Еритреја er +Eritreja er +ரிட்ரியா er +Эритрия er +เอริเทรีย er +Eritre er +Ерітрея er +Эритрия er +Eritrêye er +厄立特里亚 er +厄利垂亞 er +Spain es +Spanje es +أسبانيا es +İspaniya es +Гішпанія es +Испания es +স্পেন es +Spagn es +Španija es +Espanya es +Španělsko es +Sbaen es +Spanien es +Spanien es +Ισπανία es +Hispanio es +España es +Hispaania es +Espainia es +اسپانیا es +Espanja es +Spania es +Espagne es +Spanje es +An Spáinn es +España es +ספרד es +स्पेन es +Španjolska es +Spanyolország es +Spanyol es +Spánn es +Spagna es +スペイン es +អេស្ប៉ាញ es +스페인 es +ສະເປັນ es +Ispanija es +Spānija es +Шпанија es +Испани es +Sepanyol es +Spanja es +Spania es +Spanien es +Spanje es +Spania es +Espanha es +ਸਪੇਨ es +Hiszpania es +Espanha es +Espanha es +Spania es +Испания es +Esipanye es +Spánia es +Španielsko es +Španija es +Шпанија es +Španija es +I-Spain es +Spanien es +சுபெயின் es +Испаниё es +สเปน es +İspanya es +İspania es +Іспанія es +Испания es +Tây Ban Nha es +Sipagne es +西班牙 es +西班牙 es +Ethiopia et +Ethiopië et +اثيوبيا et +Этыёпія et +Етиопия et +ইথিওপিয়া et +Etiopi et +Etiopija et +Etiòpia et +Etiopie et +Ethiopien et +Äthiopien et +Αιθιοπία et +Etiopio et +Etiopía et +Etioopia et +Etiopia et +اتیوپی et +Etiopia et +Éthiopie et +Ethiopië et +An Aetóip et +Etiopia et +אתיופיה et +इथियोपिया et +Etiopija et +Etiópia et +Eþíópía et +Etiopia et +エチオピア et +អេត្យូពី et +에티오피아 et +ເອໂທເນີຍ et +Etiopija et +Etiopija et +Етиопија et +Этопи et +Etjopia et +Etiopia et +Äthiopien et +Ethiopië et +Etiopia et +ਈਥੋਪੀਆ et +Etiopia et +Etiópia et +Etiópia et +Etiopia et +Эфиопия et +Etiyopiya et +Etiopia et +Etiópia et +Etiopija et +Етиопија et +Etiopija et +Etiopien et +எதியோபியா et +Ҳабашистон et +เอธิโอเปีย et +Etiyopya et +Efiopia et +Ефіопія et +Эфиопия et +Etiopeye et +埃塞俄比亚 et +衣索比亞 et +Finland fi +فنلندا fi +Finlandiya fi +Фінляндыя fi +Финландия fi +ফিনল্যাণ্ড fi +Finska fi +Finlàndia fi +Finsko fi +Y Ffindir fi +Finnland fi +Φινλανδία fi +Finnlando fi +Finlandia fi +Soome fi +Finlandia fi +فنلاند fi +Suomi fi +Finnland fi +Finlande fi +Finlân fi +An Fhionlainn fi +Finlándia fi +פינלנד fi +फिनलैंड fi +Finska fi +Finnország fi +Finlandia fi +Finnland fi +Finlandia fi +フィンランド fi +ហ្វាំងឡង់ fi +핀란드 fi +ຟີນແລນ fi +Suomija fi +Somija fi +Финска fi +Финнланд fi +Finlandja fi +Finnland fi +Finlandia fi +ਫਿਨਲੈਂਡ fi +Finlandia fi +Finlândia fi +Finlândia fi +Finlanda fi +Финляндия fi +Finilande fi +Suopma fi +Fínsko fi +Finska fi +Финска fi +Finska fi +I-Finland fi +பின்லாந்து fi +Финлонд fi +ฟินแลนด์ fi +Finlandiya fi +Finland (Suomi) fi +Фінляндія fi +Финляндия fi +Phần Lan fi +Finlande fi +芬兰 fi +芬蘭 fi +Fiji fj +فيجي fj +Фіджы fj +Острови Фиджи fj +ফিজি fj +Fidji fj +Fidži fj +Fidži fj +Ffiji fj +Fidschi fj +Φίτζι fj +Fiĝioj fj +Fidži fj +فیجی fj +Fidji fj +Fidsí fj +פיג'י fj +फिजी fj +Fidzsi fj +Fídjieyjar fj +Figi fj +フィジー fj +ហ្វ៊ីហ្ស៊ី fj +피지 fj +ມີດີ fj +Fidži fj +Фиџи fj +Фижи fj +Fiġi fj +Fidschi fj +ਫਿੱਜੀ fj +Fidżi fj +Ilhas Fiji fj +Фиджи fj +Fidži fj +Fidži fj +Фиџи fj +Fidži fj +பிஜி fj +Фиҷи fj +ฟิจิ fj +Фіджі fj +Фижи fj +Fidji fj +斐济 fj +菲濟 fj +Falkland Islands (Malvinas) fk +Falkland Eilande (Malvinas) fk +جزر الفوكلاند (المالفيناس) fk +Фалклендскія астравы (Мальвіны) fk +Фолклендски острови fk +ফকল্যাণ্ড দ্বীপপুঞ্জ (মলভিনাস) fk +Inizi Falklandi (Malvinas) fk +Foklandska ostrva (Malvini) fk +Illes Falkland (Malvines) fk +Falklandy (Malvíny) fk +Ynysoedd Y Ffalcland (Malfinas) fk +Falkland-øerne fk +Falkland-Inseln (Malvinen) fk +Νησιά Φώκλαντ (Malvinas) fk +Falklandoj fk +Islas Falkland (Malvinas) fk +Falklandi saared (Malviinid) fk +Falkland Irlak (Malvinak) fk +جزایر فالکلند مالویناس fk +Falklandin saaret (Malvinassaaret) fk +Îles Falkland (Malvinas) fk +Falkland Eilannen (Malvinas) fk +Na hOileáin Fháclainne (Malvinas) fk +Illas Falkland (Malvinas) fk +איי פולקלנד fk +फाकलैंड आइलैंड (मालविनास) fk +Folklandska otočja (Malvini) fk +Falkland-szigetek fk +Falklandseyjar fk +Isole Falkland (Malvine) fk +フォークランド諸島 fk +កោះ Falkland (Malvinas) fk +포클랜드 군도 (말비나스) fk +Folklendu salas fk +Фокландски Острови (Малвини) fk +Фалкланд арлууд (Малвинас) fk +Gżejjer Falkland (Malvinas) fk +Falklandsøyene fk +Falklandinseln (Malvinas) fk +Falkland Eilanden (Malvinas) fk +Falklandsøyane fk +ਫਾਕਲੈਂਡ ਟਾਪੂ fk +Wyspy Falklandzkie (Malwiny) fk +Ilhas Falkland (Malvinas) fk +Ilhas Malvinas fk +Insulele Falkland (Malvine) fk +Фолклендские (Мальвинские) острова fk +Ibirwa bya Falikilande (Maluvinasi) fk +Falklánddasullot fk +Falklandské Ostrovy (Malviny) fk +Falklandski otoki (Malvini) fk +Фолкландска острва (Малвини) fk +Folklandska ostrva (Malvini) fk +Falklandsöarna fk +ஃபால்க் தீவு(மால்வினாஸ்) fk +Ҷазираи фолкланд (Малвина) fk +หมู่เกาะฟอล์คแลนด์ (Malvinas) fk +Falkland Adaları fk +Falkland Utrawları (Malvinnar) fk +Фолклендські острови (Британія) fk +Фолкленд (Малвин) Ороллари fk +Iyes Malouwines fk +福克兰群岛(马尔维纳斯) fk +福克蘭群島 (馬爾維納斯) fk +Micronesia, Federated States of fm +Micronesië, Vereenigde State van fm +Федэрацыя Мiкранэзіі fm +Микронезия fm +মাইক্রোনেশিয়া, ফেডারেটেড স্টেটস অব fm +Mikronezija, Federalne države fm +Micronesia, Estats Federats de fm +Mikronésie fm +Micronesia, Taleithau Cyfunol fm +Mikronesien, de forenede stater af fm +Mikronesien, Föderation von fm +Μικρονησίας, Ομόσπονδες πολιτείες της fm +Mikronezio, Respubliko de fm +Micronesia, Estados federados de fm +Mikroneesia fm +Mikronesiako Estatu Federatuak fm +Mikronesian liittovaltio fm +Etats Fédérés de Micronésie fm +Micronesië, Federale staten Fan fm +Stáit Cónascacha na Micrinéise fm +Micronésia, Estados Federados de fm +מיקרונזיה, מדינות הפדרציה של fm +फेडरेटेड स्टेट ऑफ माइक्रोनेसिया fm +Mikronézia fm +Míkrónesía, Sambandsríki fm +Micronesia, stati federati di fm +ミクロネシア,米自由連邦 fm +រដ្ឋសហព័ន្ធមិក្រូនេស៊ី fm +Mikronezija fm +Mikronēzija fm +Микронезија, Федеративни Држави на fm +Mikronesja (Stati Federati ta') fm +Mikronesiaføderasjonen fm +Mikronesien, Vereenigte Staten vun fm +Micronesië, Federale staten van fm +Mikronesiaføderasjonen fm +ਮਾਇਕਰੋਨੀਸੀਆ, ਸੰਘੀ ਪ੍ਰਾਂਤ fm +Federacja Stanów Mikronezji fm +Micronésia, Estados Federados da fm +Estados Federados da Micronésia fm +Micronezia, Statele Federative fm +Микронезия fm +Mikoronesiya, Leta Zishyizwehamwe fm +Mikronesiafederašuvdna fm +Spojené štáty Mikronézie fm +Mikronezija, Združene države fm +Микронезија, Федерација држава fm +Mikronezija, Federacija država fm +Mikronesiska federationen fm +மைக்ரோனிசா, ஒருங்கிணைந்த மாநிலம் fm +สหพันธรัฐมิโครนีเซีย fm +Mikronezya Federasyonu fm +Mikronesia, Berläşkän İlläre fm +Мікронезія, федеративні штати fm +Микронезия fm +Micronezeye fm +密克罗尼西亚联邦 fm +密克羅尼西亞聯邦 fm +Faroe Islands fo +Faroe Eilande fo +جزر الفيرو fo +Острови Фаро fo +ফারো দ্বীপপুঞ্জ fo +Enez Faroe fo +Farska ostrva fo +Illes Faroe fo +Faerské ostrovy fo +Ynysoedd Ffar?e fo +Færøerne fo +Färöer-Inseln fo +Νήσοι Φερόε fo +Ferooj fo +islas Faroe fo +Fääri saared fo +Faroe Irlak fo +جزایر فارو fo +Färsaaret fo +Îles Féroé fo +Faroe Eilannen fo +Na Scigirí (Oileáin Fharó) fo +Illas Feroe fo +איי פארו fo +फारोए आइलैंड fo +Faroe Otoci fo +Faroe-szigetek fo +Færeyjar fo +Isole Fær Øer fo +フェロー諸島 fo +កោះហ្វ៉ារ៉ូ fo +페로 제도 fo +ໄອແລນ fo +Faroe salos fo +Fēru salas fo +Фарски Острови fo +Фарое арлууд fo +Gżejjer Faroe fo +Færøyene fo +Färöerinseln fo +Faroe Eilanden fo +Færøyane fo +ਫਾਰੋਈ ਟਾਪੂ fo +Wyspy Faroe fo +Ilhas Faroe fo +Ilhas Faroe fo +Insulele Feroe fo +Фарерские острова fo +Ibirwa bya Farowe fo +Fearsuolu fo +Ostrovy Faroe fo +Otoki Faroe fo +Фарска острва fo +Farska ostrva fo +Färöarna fo +ஃபரோ தீவுகள் fo +Ҷазираи Фару fo +หมู่เกาะฟาโร fo +Faroe Adaları fo +Faroe Utrawları fo +Фарерські острови fo +Фарер Ороллари fo +Đảo Faroe fo +Iye Faeroyé fo +法罗群岛 fo +法羅群島 fo +France fr +Frankryk fr +فرنسا fr +Fransa fr +Францыя fr +Франция fr +ফ্রান্স fr +Frañs fr +Francuska fr +França fr +Francie fr +Ffrainc fr +Frankrig fr +Frankreich fr +Γαλλία fr +Francio fr +Francia fr +Prantsusmaa fr +Frantzia fr +فرانسه fr +Ranska fr +Frakland fr +Frankryk fr +An Fhrainc fr +Franza fr +צרפת fr +फ्रांस fr +Francuska fr +Franciaország fr +Prancis fr +Frakkland fr +Francia fr +フランス fr +បារាំង fr +프랑스 fr +ຝຣັ່ງ fr +Prancūzija fr +Francija fr +Франција fr +Франц fr +Perancis fr +Franza fr +Frankrike fr +Frankriek fr +Frankrijk fr +Frankrike fr +Fora fr +França fr +ਫਰਾਂਸ fr +Francja fr +França fr +França fr +Franţa fr +Франция fr +Ubufaransa fr +Fránkriika fr +Francúzsko fr +Francija fr +Француска fr +Francuska fr +I-France fr +Frankrike fr +பிரான்சு fr +Фаронса fr +ฝรั่งเศส fr +Fransa fr +Fransia fr +Франція fr +Франция fr +Fura fr +Pháp fr +Fransi fr +法国 fr +法國 fr +Gabon ga +الغابون ga +Габон ga +Габон ga +গ্যাবন ga +Gabun ga +Γκαμπόν ga +Gabono ga +Gabón ga +گابون ga +An Ghabúin ga +Gabón ga +גבון ga +गेबॉन ga +ガボン ga +ហ្គាបុង ga +가봉 ga +ແກລ່ງນ ga +Gabonas ga +Gabona ga +Габон ga +Габон ga +Gabun ga +ਗਾਬੋਨ ga +Gabão ga +Gabão ga +Габон ga +Gabo ga +Габон ga +காபான் ga +Габон ga +กาบอน ga +Габон ga +Габон ga +加蓬 ga +加彭 ga +United Kingdom gb +Vereenigde Koninkryk gb +المملكة المتحدة gb +Birləşmiş Krallıq gb +Злучанае Каралеўства gb +Великобритания gb +ইউনাইটেড কিংডম gb +Rouantelezh Unanet gb +Velika Britanija gb +Regne Unit gb +Spojené království gb +Y Deyrnas Unedig gb +Storbritannien gb +Großbritannien gb +Ηνωμένο Βασίλειο gb +Britio gb +Reino Unido gb +Suurbritannia gb +Erresuma Batua gb +بریتانیا gb +Iso-Britannia gb +Stórabretland gb +Royaume Uni gb +Ferienigd Keninkryk gb +An Ríocht Aontaithe gb +Reino Unido gb +בריטניה gb +यूनाइटेड किंगडम gb +Ujedinjeno Kraljevstvo gb +Egyesült Királyság gb +Inggris gb +Bretland gb +Regno Unito gb +イギリス gb +ចក្រភពអង់គ្លេស gb +영국 gb +ສະຫະລາດສະອານາຈັກ gb +Jungtinė Karalystė gb +Apvienotā Karaliste gb +Обединето Кралство gb +Их британ gb +Renju Unit gb +Storbritannia gb +Grootbritannien gb +Verenigd Koninkrijk gb +Storbritannia gb +Regne Unit gb +ਬਰਤਾਨੀਆ gb +Wielka Brytania gb +Reino Unido gb +Reino Unido gb +Anglia gb +Великобритания gb +Ubwongereza gb +Stuorrabrittania gb +Anglicko gb +Združeno kraljestvo gb +Уједињено Краљевство gb +Ujedinjeno Kraljevstvo gb +I-United Kingdom gb +Storbritannien gb +ஐக்கிய ராஜ்ஜியம் gb +Подшоҳии Муттаҳида gb +สหราชอาณาจักร gb +Birleşik Krallık gb +Berläşkän Padşahlıq gb +Великобританія gb +Буюк Британия gb +Anh gb +Rweyåme Uni gb +United Kingdom gb +英国 gb +聯合王國 gb +United Kingdom gb +Grenada gd +غرينادا gd +Qrenada gd +Грэнада gd +Гренада gd +গ্রেনাডা gd +Granada gd +Γρενάδα gd +Grenado gd +Granada gd +گرانادا gd +Grenade gd +Granada gd +גרנדה gd +ग्रेनाडा gd +Granada gd +グレナダ gd +ហ្គ្រីណាដា gd +그러네이다 gd +ເກນາດາ gd +Grenāda gd +Гренада gd +Гренада gd +Granada gd +ਗਰੀਨਾਡਾ gd +Granada gd +Granada gd +Гренада gd +Gerenada gd +I-Grenada gd +கிரெனடா gd +Гронодо gd +เกรนาดา gd +Гренада gd +Гренада gd +Grenåde gd +格林纳达 gd +格瑞那達 gd +Georgia ge +Georgië ge +جورجيا ge +Грузія ge +Грузия ge +জর্জিয়া ge +Jeorji ge +Gruzija ge +Geòrgia ge +Gruzie ge +Georgien ge +Georgien ge +Γεωργία ge +Georgino ge +Gruusia ge +گرجستان ge +Géorgie ge +Georgië ge +An tSeoirsia ge +Xeórxia ge +ג'ורג'יה ge +ज्यार्जिया ge +Grúzia ge +Georgía ge +ジョージア島 ge +ហ្សកហ្ស៊ី ge +그루지아 ge +ເຊີເບີຍ ge +Gruzija ge +Gruzija ge +Грузија ge +Георги ge +Ġorġia ge +Georgien ge +Georgië ge +ਜਾਰਜੀਆ ge +Gruzja ge +Geórgia ge +Geórgia ge +Грузия ge +Jeworugiya ge +Gruzija ge +Грузија ge +Gruzija ge +Georgien ge +ஜியோர்ஜியா ge +Гурҷистон ge +จอร์เจีย ge +Gürcistan ge +Görcestan ge +Грузія ge +Гуржистон ge +Djeyordjeye ge +格鲁吉亚 ge +喬治亞 ge +Ghana gh +غانا gh +Гана gh +Гана gh +ঘানা gh +Gwana gh +Gana gh +Γκάνα gh +Ganao gh +غنا gh +Gána gh +Gana gh +גאנה gh +घाना gh +Gana gh +ガーナ gh +ហ្កាណា gh +가나 gh +ຈີນ gh +Gana gh +Gana gh +Гана gh +Гана gh +Gana gh +ਘਾਨਾ gh +Gana gh +Gana gh +Gana gh +Гана gh +Gana gh +Gana gh +Гана gh +Gana gh +I-Ghana gh +கானா gh +Ғано gh +กานา gh +Гана gh +Гана gh +Gana gh +加纳 gh +迦納 gh +Gibraltar gi +جبل طارق gi +Гібралтар gi +Гибралтар gi +জিব্রল্টার gi +Jibraltar gi +Γιβραλτάρ gi +Gibraltaro gi +گیبرالتار gi +Giobráltar gi +Xibraltar gi +גיברלטר gi +जिब्राल्टर gi +Gibraltár gi +Gíbraltar gi +Gibilterra gi +ジブラルタル gi +지브롤터 gi +ມອລຕາ gi +Gibraltaras gi +Gibraltārs gi +Гибралтар gi +Гибралтар gi +Ġibiltar gi +ਗੀਬਰਾਲਟਾਰ gi +Гибралтар gi +Jiburalitari gi +Гибралтар gi +ஜிப்ரல்டார் gi +Ҷабалуттариқ gi +ยิบรอลตา gi +Cebelitarık gi +Гібралтар gi +Гибралтар gi +Djibraltar gi +直布罗陀 gi +直布羅陀 gi +Greenland gl +Groenland gl +Гренландия gl +গ্রীনল্যাণ্ড gl +Griñland gl +Groenlàndia gl +Grónsko gl +Y Lasynys gl +Grønland gl +Grönland gl +Ισλανδία gl +Groenlandia gl +Gröönimaa gl +Gröönlanti gl +Groenland gl +Grienlân gl +An Ghraonlainn gl +Groenlándia gl +Grönland gl +Grænland gl +Groenlandia gl +グリーンランド gl +Grenlandija gl +Гренланд gl +Grønland gl +Gröönland gl +Groenland gl +Grønland gl +ਗਰੀਨਲੈਂਡ gl +Grenlandia gl +Gronelândia gl +Гренландия gl +Goronilande gl +Ruonáeatnan gl +Grenlandija gl +Гренланд gl +Grenland gl +Grönland gl +Гринландия gl +กรีนแลนด์ gl +Grönland gl +Гренландія gl +Гренландия gl +格陵兰 gl +格陵蘭 gl +Gambia gm +Gambië gm +غامبيا gm +Гамбія gm +Гамбия gm +গামবিয়া gm +Gambi gm +Gambija gm +Gàmbia gm +Gambie gm +Γκάμπια gm +Gambio gm +گامبیا gm +Gambie gm +An Ghaimbia gm +Gámbia gm +גמביה gm +जाम्बिया gm +Gambija gm +Gambía gm +ガンビア gm +ហ្កាំប៊ី gm +감비아 gm +ແກມມາ gm +Gambija gm +Gambija gm +Гамбија gm +Гамби gm +Gambja gm +ਗੈਂਬੀਆ gm +Gâmbia gm +Gâmbia gm +Гамбия gm +Gambiya gm +Gambija gm +Гамбија gm +Gambija gm +காம்பியா gm +Гомбиё gm +แกมเบีย gm +Гамбія gm +Гамбия gm +Gambeye gm +冈比亚 gm +甘比亞 gm +Guinea gn +غينيا gn +Гвінэя gn +Гвинея gn +গিনি gn +Gine gn +Gvineja gn +Gini gn +Γουινέα gn +Gvineo gn +Ginea gn +گینه gn +Guinée gn +An Ghuine gn +Guiné gn +גינאה gn +गुईना gn +Gvineja gn +Gínea gn +ギニア gn +ហ្គីណេ gn +기니 gn +ເຖາວັນ gn +Gvinėja gn +Gvineja gn +Гвинеја gn +Гуйнеа gn +Ginea gn +ਗੁਇਨੀਆ gn +Gwinea gn +Guiné gn +Guiné gn +Гвинея gn +Gineya gn +Gvineja gn +Гвинеја gn +Gvineja gn +க்யுனியா gn +Гине gn +กินี gn +Gine gn +Гвінея gn +Гвинея gn +Guinêye gn +几内亚 gn +幾內亞 gn +Guadeloupe gp +غواديلوب gp +Гвадэлупа gp +Гваделупа gp +গাডেলুপ gp +Gwadeloup gp +Gvadalupe gp +Guadalupe gp +Gwadel?p gp +Γουαδελούπη gp +Gvadelupo gp +Guadalupe gp +Guadalupe gp +گوادلوپ gp +Guadalúip gp +Guadalupe gp +גאודלופה gp +ग्वाडेलोप gp +Gvadelúpeyjar gp +Guadalupa gp +仏領グアドループ gp +ហ្គាដឺលុប gp +과들루프 gp +ເດີລຸກ gp +Gvandelupa gp +Гваделупе gp +Gwadelup gp +ਗੁਆਡੀਓਪੀ gp +Gwadelupa gp +Guadalupe gp +Guadalupe gp +Guadelupa gp +Гваделупа gp +Gwaderupe gp +Гвадалупе gp +Gvadalupe gp +க்வாடெல்போப் gp +Гвадалуппо gp +เกาะกัวเดอลูป gp +Guadelupa gp +Гваделупа gp +Гваделупа gp +瓜德罗普 gp +瓜德魯普 gp +Equatorial Guinea gq +Ekwatoriaal Guinea gq +غينيا الاستوائية gq +Экватарыяльная Гвінэя gq +Екваториална Гвинея gq +ইকুয়েটোরিয়াল গিনি gq +Guine équatoriale gq +Ekvatorijalna Gvineja gq +Guinea Equatorial gq +Rovníková Guinea gq +Gini Gyhydeddol gq +Ækvatorial Guinea gq +Äquatorial-Guinea gq +Ισημερινή Γουινέα gq +Ekvatora Gvineo gq +Guinea equatorial gq +Ekvatoriaal-Guinea gq +Ginea Ekuatoriala gq +گینه اکوادور gq +Päiväntasaajan Guinea gq +Guinée équatoriale gq +Guine Mheánchiorclach gq +Guinea Ecuatorial gq +גינאה המשוונית gq +इक्वेटोरियल गुएना gq +Ekvatorijalna Gvineja gq +Egyenlítői Guinea gq +Miðbaugs-Gínea gq +Guinea Equatoriale gq +赤道ギニア gq +ហ្គីណេអេក្វាទ័រ gq +적도 기니 gq +ການສອນ gq +Ekvatoriaus Gvinėja gq +Ekvatoriālā Gvineja gq +Екваторијална Гвинеја gq +Equatorial Гуйнеа gq +Ginea Ekwatorjali gq +Ekvatorial-Guinea gq +Äquatoriaal-Guinea gq +Equatoriaal Guinea gq +Ekvatorial-Guinea gq +ਏਕੂਲੇਟਰਲ ਗੁਈਨਿਆ gq +Gwinea Równikowa gq +Guiné Equatorial gq +Guiné Equatorial gq +Guinea Ecuatorială gq +Экваториальная Гвинея gq +Gineya Ekwatoriyale gq +Ekvatorialalaš-Guinea gq +Rovníkova Guinea gq +Ekvatorialna Gvineja gq +Екваторијална Гвинеја gq +Ekvatorijalna Gvineja gq +Ekvatorialguinea gq +ஈகோடோரியல் க்யுனியா gq +Гинеи Экваторӣ gq +กินี ตรงเส้นศูนย์สูตร gq +Ekvatoral Gine gq +Equatorlı Guinea gq +Екваторіальна Гвінея gq +Экваториал Гвинея gq +Guinêye Ecwåtoriåle gq +赤道几内亚 gq +赤道幾內亞 gq +Greece gr +Griekeland gr +اليونان gr +Yunanıstan gr +Грэцыя gr +Гърция gr +গ্রীস gr +Gres gr +Grčka gr +Grècia gr +Řecko gr +Gwlad Groeg gr +Grækenland gr +Griechenland gr +Ελλάδα gr +Grekujo gr +Grecia gr +Kreeka gr +Grezia gr +یونان gr +Kreikka gr +Grikkaland gr +Grèce gr +Grikelân gr +An Ghréig gr +Grécia gr +יוון gr +ग्रीस gr +Grčka gr +Görögország gr +Grikkland gr +Grecia gr +ギリシャ gr +ក្រិក gr +그리스 gr +ກີຊ gr +Graikija gr +Grieķija gr +Грција gr +Грек gr +Greċja gr +Hellas gr +Grekenland gr +Griekenland gr +Hellas gr +Grèça gr +ਗਰੀਸ gr +Grecja gr +Grécia gr +Grécia gr +Grecia gr +Греция gr +Ubugereki gr +Greika gr +Grécko gr +Grčija gr +Грчка gr +Grčka gr +I-Greece gr +Grekland gr +கிரீசு gr +Юнон gr +กรีซ gr +Yunanistan gr +Yunanstan gr +Греція gr +Юнонистон gr +Hy Lạp gr +Grece gr +希腊 gr +希臘 gr +Guatemala gt +Gautemala gt +غواتيمالا gt +Quatemala gt +Гватэмала gt +Гватемала gt +গুয়াতেমালা gt +Gvatemala gt +Gwatemala gt +Γουατεμάλα gt +Gvatemalo gt +گواتمالا gt +Guatamala gt +גואטמלה gt +ग्वाटेमाला gt +Gvatemala gt +Gvatemala gt +グァテマラ gt +ហ្គាតេម៉ាឡា gt +과테말라 gt +ກັວເຕມາລາ gt +Gvatemala gt +Gvatemala gt +Гватемала gt +Гуятемала gt +Gwatemala gt +ਗੁਆਟੇਮਾਲਾ gt +Gwatemala gt +Гватемала gt +Gwatemala gt +Gvatemala gt +Гватемала gt +Gvatemala gt +I-Guatemala gt +குவாத்தமாலா gt +Гватемоло gt +กัวเตมาลา gt +Гватемала gt +Гватемала gt +Gwatemala gt +危地马拉 gt +瓜地馬拉 gt +Guam gu +غوام gu +Гуам gu +Гуам gu +গুয়াম gu +Gwam gu +Gw?m gu +Γκουάμ gu +Gvamo gu +گوام gu +גואם gu +गुवाम gu +Gvam gu +グァム gu +ហ្គាំម gu +괌 gu +ແກມມາ gu +Guama gu +Гвам gu +Гуам gu +Gwam gu +ਗੁਆਮ gu +Гуам gu +Gwamu gu +Гуам gu +காம் gu +Гуамма gu +กวม gu +Гуам gu +Гуам gu +Gwam gu +关岛 gu +關島 gu +Guinea-Bissau gw +غينيا-بيساو gw +Гвінэя-Бісаў gw +Гвинея Бисау gw +গিনি-বিসো gw +Gine-Biso gw +Gvineja-Bisau gw +Gini-Bisaw gw +Γουινέα-Μπισσάου gw +Gvineo Bisaŭa gw +Ginea-Bissau gw +گینه بیسائو gw +Guinée-Bissau gw +Guine-Bhissau gw +גינאה ביסאו gw +गुएना-बिसाऊ gw +Bissau-Guinea gw +Gínea-Bissá gw +ギニアビサオ gw +ហ្គីណេប៊ីសៅ gw +기니비사 gw +ລັດເຊີຍ gw +Gvineja-Bisava gw +Гвинеја Бисао gw +Гуйнеа-Биссау gw +Ginea-Bissaw gw +ਗੁਇਨਿਆ-ਬਿਸ਼ਾਉ gw +Gwinea-Bissau gw +Guiné Bissau gw +Guiné-Bissau gw +Гвинея-Бисау gw +Gineya-Bisawu gw +Гвинеја Бисао gw +Gvineja Bisao gw +க்யுனியா-பிஸ்ஸா gw +Гвинеи Биссои gw +กินี - บิสซอ gw +Gine-Bissau gw +Гвінея-Бісау gw +Гвинея-Биссау gw +Guinêye-Bissaw gw +几内亚比绍 gw +幾內亞比紹 gw +Guyana gy +غيانا gy +Гвіяна gy +Гуайана gy +গায়ানা gy +Gwiana gy +Gvajana gy +Giana gy +Γουιάνα gy +Gujano gy +گویان gy +Guyane gy +An Ghuáin gy +Guiana gy +גויאנה gy +गुयाना gy +Gvæjana gy +ガイアナ gy +ហ្គីយ៉ាណា gy +가이아나 gy +ຈີນ gy +Gviana gy +Gajana gy +Гвајана gy +Гуяна gy +Gujana gy +ਗੁਆਨਾ gy +Gujana gy +Guiana gy +Guiana gy +Guiana gy +Гайана gy +Giyana gy +Gvajana gy +Гвајана gy +Gvajana gy +கானா gy +Гуана gy +กูยาน่า gy +Guana gy +Гайяна gy +Гвиана gy +圭亚那 gy +蓋亞納 gy +Hong Kong SAR(China) hk +Hong Kong SAR (China) hk +Хонг Конг (Китай) hk +হং কং SAR(চীন) hk +Hong Kong SAR(Sina) hk +Hong Kong SAR(Xina) hk +Hong Kong SAR (Čína) hk +Hongkong SAR(Kina) hk +Χονγκ Κονγκ SAR (Κίνα) hk +Hongkong hk +Hong Kong SAR(Txina) hk +Hong Kong SAR (Kiina) hk +Hong Kong SAR (Chine) hk +Hong Cong SAR(An tSín) hk +Hong Kong hk +הונג קונג SAR (סין) hk +Hongkong (Kína) hk +Hong Kong (sjálfstjórnarhérað í Kína) hk +Hong Kong SAR(Cina) hk +香港(中国) hk +ហុងចិន (ចិន) hk +Hong Kongas SAR(Kinija) hk +Хонг Конг САР(Кина) hk +Hongkong SAR(Kina) hk +Hong Kong hk +Hongkong SAR(Kina) hk +ਹਾਂਗ-ਕਾਂਗ SAR(ਚੀਨ) hk +Hong Kong SAR (Chiny) hk +Hong Kong SAR (China) hk +Гонконг hk +Hong Kong SAR (Ubushinwa) hk +Hongkong SAR(Kiinná) hk +Hong Kong SAR (Kitajska) hk +SAR Hong Kong (Кина) hk +SAR Hong Kong (Kina) hk +Hong Kong (Kina) hk +ஹாங்காங் SAR(சீனா) hk +ฮ่องกง hk +Hong Kong (Çin) hk +Гонконг SAR (Китай) hk +Гонконг (Хитой) hk +中国香港特别行政区 hk +香港 SAR(中國) hk +Honduras hn +هندوراس hn +Гандурас hn +Хондурас hn +হণ্ডুরাস hn +Hondures hn +Hondwras hn +Ονδούρα hn +Honduro hn +هندوراس hn +Hondúras hn +הונדורס hn +होंडुरास hn +Hondúras hn +ホンジュラス hn +ហុងឌូរ៉ាស់ hn +온두라스 hn +ຫອນດູລັດ hn +Hondūras hn +Hondurasa hn +Хондурас hn +Хондурас hn +Ħonduras hn +Hondures hn +ਹੰਨਡੂਰਸ hn +Гондурас hn +Hondirasi hn +Хондурас hn +I-Honduras hn +ஆண்டுராஸ் hn +Ҳиндурос hn +ฮอนดูรัส hn +Гондурас hn +Гондурас hn +洪都拉斯 hn +宏都拉斯 hn +Croatia hr +Kroasië hr +كرواتيا hr +Xırvatıstan hr +Харватыя hr +Хърватска hr +ক্রোয়াশিয়া hr +Kroatia hr +Hrvatska hr +Croàcia hr +Chorvatsko hr +Kroatien hr +Kroatien hr +Κροατία hr +Kroatio hr +Croacia hr +Horvaatia hr +Kroazia hr +کرواسی hr +Kroatia hr +Kroatia hr +Croatie hr +Kroatië hr +An Chróit hr +Croácia hr +קרואטיה hr +क्रोएशिया hr +Hrvatska hr +Horvátország hr +Kroasia hr +Króatía hr +Croazia hr +クロアチア hr +ក្រូអាត hr +크로아티아 hr +ໂຄເອເທີຍ hr +Kroatija hr +Horvātija hr +Хрватска hr +Кроати hr +Kroazja hr +Kroatia hr +Kroatien hr +Kroatië hr +Kroatia hr +Croacia hr +ਕਰੋਆਟਿਆ hr +Chorwacja hr +Croácia hr +Croácia hr +Croaţia hr +Хорватия hr +Korowasiya hr +Kroátia hr +Chorvátsko hr +Hrvaška hr +Хрватска hr +Hrvatska hr +I-Croatia hr +Kroatien hr +க்ரோடியா hr +Хорватӣ hr +โครเอเธีย hr +Hırvatistan hr +Kroatia hr +Хорватія hr +Хорватия hr +Crowåceye hr +克罗地亚 hr +克羅埃西亞 hr +Haiti ht +Haïti ht +هايتي ht +Гаіці ht +Хаити ht +হাইতি ht +Haití ht +Αϊτή ht +Haitio ht +Haití ht +هاییتی ht +Haïti ht +Háítí ht +האיטי ht +हैती ht +Haítí ht +ハイチ ht +ហែទី ht +아이티 ht +ວາດຮູບ - K ht +Haitis ht +Хаити ht +Хайти ht +Ħaiti ht +ਹਾਇਟੀ ht +Гаити ht +Hayiti ht +Хаити ht +ஹைதி ht +Ҳаити ht +ไฮติ ht +Гаїті ht +Гаити ht +Hayiti ht +海地 ht +海地 ht +Hungary hu +Hongarye hu +هنغاريا hu +Macarıstan hu +Вугоршчына hu +Унгария hu +হাঙ্গেরী hu +Hungaria hu +Mađarska hu +Hongria hu +Maďarsko hu +Hwngari hu +Ungarn hu +Ungarn hu +Ουγγαρία hu +Hungario hu +Hungría hu +Ungari hu +Hungaria hu +مجارستان hu +Unkari hu +Ungarn hu +Hongrie hu +Hongarije hu +An Ungáir hu +Hungria hu +הונגריה hu +हंगरी hu +Mađjarska hu +Magyarország hu +Hungaria hu +Ungverjaland hu +Ungheria hu +ハンガリー hu +ហុងគ្រី hu +헝가리 hu +ຫັງກາລີ hu +Vengrija hu +Ungārija hu +Унгарија hu +Унгар hu +Ungerija hu +Ungarn hu +Ungarn hu +Hongarije hu +Ungarn hu +Hongria hu +ਹੰਗਰੀ hu +Węgry hu +Hungria hu +Hungria hu +Ungaria hu +Венгрия hu +Hongiriya hu +Ungár hu +Maďarsko hu +Madžarska hu +Мађарска hu +Mađarska hu +I-Hungary hu +Ungern hu +ஹங்கேரி hu +Маҷористон hu +ฮังการี hu +Macaristan hu +Macarstan hu +Угорщина hu +Венгрия hu +Hongreye hu +匈牙利 hu +匈牙利 hu +Indonesia id +Indonesië id +إندونيسيا id +İndoneziya id +Інданэзія id +Индонезия id +ইন্দোনেশিয়া id +Indonezi id +Indonezija id +Indonèsia id +Indonésie id +Indonesien id +Indonesien id +Ινδονησία id +Indonezio id +Indoneesia id +اندونزی id +Indonésie id +Indonesië id +An Indinéis id +Indonésia id +אינדונזיה id +इंडोनेशिया id +Indonezija id +Indonézia id +Indónesía id +インドネシア id +ឥណ្ឌូនេស៊ី id +인도네시아 id +ອີຍໂດນີເຊີຍ id +Indonezija id +Indonēzija id +Индонезија id +Индонез id +Indoneżja id +Indonesien id +Indonesië id +ਇੰਡੋਨੇਸ਼ੀਆ id +Indonezja id +Indonésia id +Indonésia id +Indonezia id +Индонезия id +Indonesiya id +Indonézia id +Indonezija id +Индонезија id +Indonezija id +I-Indonesia id +Indonesien id +இந்தோனீசியா id +Индонезӣ id +อินโดนีเซีย id +İndonezya id +İndonesia id +Індонезія id +Индонезия id +Indonezeye id +印度尼西亚 id +印尼 id +Ireland ie +Ierland ie +أيرلندا ie +İrlandiya ie +Ірляндыя ie +Ирландия ie +আয়ারল্যাণ্ড ie +Iwerzhon ie +Irska ie +Irlanda ie +Irsko ie +Iwerddon ie +Irland ie +Irland ie +Ιρλανδία ie +Islando ie +Irlanda ie +Iirimaa ie +Irlanda ie +ایرلند ie +Irlanti ie +Írland ie +Irlande ie +Ierlân ie +Éire ie +Irlanda ie +אירלנד ie +आयरलैंड ie +Irska ie +Írország ie +Irlandia ie +Írland ie +Irlanda ie +アイルランド ie +អៀរឡង់ ie +아일랜드 ie +ໄອແລນ ie +Airija ie +Īrija ie +Ирска ie +Ирланд ie +Irlanda ie +Irland ie +Irland ie +Ierland ie +Irland ie +Irlanda ie +ਆਇਰਲੈਂਡ ie +Irlandia ie +Irlanda ie +Irlanda ie +Irlanda ie +Ирландия ie +Irilande ie +Irlánda ie +Írsko ie +Irska ie +Ирска ie +Irska ie +I-Ireland ie +Irland ie +அயர்லாந்து ie +Ирлонд ie +ไอร์แลนด์ ie +İrlanda ie +İreland, İrlandia ie +Ірландія ie +Ирландия ie +Irlande ie +伊朗 ie +愛爾蘭 ie +Israel il +اسرائيل il +İzrail il +Ізраіль il +Израел il +ইসরাইল il +Izrael il +Izrael il +Ισραήλ il +Israelo il +Iisrael il +اسراییل il +Ísrael il +Israël il +Iosrael il +ישראל il +इज़राइल il +Izrael il +Izrael il +Ísrael il +Israele il +イスラエル il +អ៊ីស្រាអែល il +이스라엘 il +ອິດສະລະເອລ il +Izraelis il +Izraēla il +Израел il +Изриал il +Iżrael il +ਇਜ਼ਰਾਈਲ il +Izrael il +Израиль il +Isirayeli il +Izrael il +Izrael il +Израел il +Izrael il +I-Israel il +இசுரேல் il +Исроил il +อิสราเอล il +İsrail il +İsrael il +Ізраїль il +Исроил il +Israyel il +USirayeli il +以色列 il +以色列 il +India in +Indië in +الهند in +Hindistan in +Індыя in +Индия in +ভারত in +Indez in +Indija in +Índia in +Indie in +Indien in +Indien in +Ινδία in +Hindujo in +هندوستان in +Intia in +Inde in +An India in +Índia in +הודו in +भारत in +Indija in +Indland in +インド in +ឥណ្ឌា in +인도 in +ອິນເດີຍ in +Indija in +Indija in +Индија in +Энэтхэг in +Indja in +Indien in +ਭਾਰਤ in +Indie in +Índia in +Índia in +Индия in +Ubuhinde in +Indija in +Индија in +Indija in +I-India in +Indien in +இந்தியா in +Ҳиндустон in +อินเดีย in +Hindistan in +Hindstan in +Індія in +Ҳиндистон in +Ấn Độ in +Inde in +印度 in +印度 in +Endiya in +Iraq iq +Irak iq +العراق iq +İraq iq +Ірак iq +Ирак iq +ইরাক iq +Irak iq +Irak iq +Irák iq +Irac iq +Irak iq +Irak iq +Ιράκ iq +Irako iq +Irak iq +Iraak iq +Irak iq +عراق iq +Irak iq +Irak iq +Irak iq +Irak iq +An Iaráic iq +עיראק iq +इराक iq +Irak iq +Irak iq +Írak iq +イラク iq +អ៊ីរ៉ាក់ iq +이라크 iq +ອີລັກ iq +Irakas iq +Irāka iq +Ирак iq +Ирак iq +Irak iq +Irak iq +Irak iq +Irak iq +ਇਰਾਕ iq +Irak iq +Iraque iq +Iraque iq +Irak iq +Ирак iq +Iraki iq +Iráka iq +Irák iq +Irak iq +Ирак iq +Irak iq +I-Iraq iq +Irak iq +ஈராக் iq +Ироқ iq +อิรัก iq +Irak iq +Ğíraq iq +Ірак iq +Ироқ iq +Irak iq +伊拉克 iq +伊拉克 iq +Iran ir +أيران ir +Іран ir +Иран ir +ইরান ir +Írán ir +Ιράν ir +Irano ir +Iraan ir +ایران ir +An Iaráin ir +Irán ir +איראן ir +इरान ir +Irán ir +Íran ir +イラン ir +អ៊ីរ៉ង់ ir +이란 ir +ອີລັກ ir +Iranas ir +Irāna ir +Иран ir +Иран ir +ਈਰਾਨ ir +Irão ir +Irã ir +Иран ir +Irani ir +Irána ir +Irán ir +Иран ir +I-Iran ir +ஈரான் ir +Эрон ir +อิหร่าน ir +İran ir +İran ir +Іран ir +Эрон ir +伊朗 ir +伊朗 ir +Iceland is +Ysland is +أيسلندا is +İslandiya is +Ісьляндыя is +Исландия is +আইসল্যাণ্ড is +Island is +Island is +Islàndia is +Island is +Ynys yr I? is +Island is +Island is +Ισλανδία is +Islando is +Islandia is +Island is +Islandia is +ایسلند is +Islanti is +Ísland is +Islande is +Yslân is +An Íoslainn is +Islándia is +איסלנד is +आयरलैंड is +Island is +Izland is +Islandia is +Ísland is +Islanda is +アイスランド is +អ៊ីស្លង់ is +아이슬란드 is +ໄອຊແລນ is +Islandija is +Islande is +Исланд is +Исланд is +Islandja is +Island is +Island is +IJsland is +Island is +Islandia is +ਆਈਸਲੈਂਡ is +Islandia is +Islândia is +Islândia is +Islanda is +Исландия is +Isilande is +Islánda is +Island is +Islandija is +Исланд is +Island is +I-Iceland is +Island is +தீவு is +Ислонд is +ไอซ์แลนด์ is +İzlanda is +İsland is +Ісландія is +Исландия is +Izlande is +冰岛 is +冰島 is +Icelandi is +Italy it +Italië it +ايطاليا it +İtalyia it +Італія it +Италия it +ইতালী it +Italia it +Italija it +Itàlia it +Itálie it +Yr Eidal it +Italien it +Italien it +Ιταλία it +Italio it +Italia it +Itaalia it +Italia it +ایتالیا it +Italia it +Italia it +Italie it +Italië it +An Iodáil it +Itália it +איטליה it +इटली it +Italija it +Olaszország it +Italia it +Ítalía it +Italia it +イタリア it +អ៊ីតាលី it +이탈리아 it +ອີຕາລີ it +Italija it +Itālija it +Италија it +Итали it +Itali it +Italja it +Italia it +Italien it +Italië it +Italia it +Italia it +ਇਟਲੀ it +Włochy it +Itália it +Itália it +Italia it +Италия it +Ubutaliyani it +Itália it +Taliansko it +Italija it +Италија it +Italija it +I-Italy it +Italien it +இத்தாலி it +Итолиё it +อิตาลี it +İtalya it +İtalia it +Італія it +Италия it +Ý it +Itåleye it +Ithali it +意大利 it +義大利 it +Jamaica jm +Jamaika jm +جامايكا jm +Yamayka jm +Ямайка jm +Ямайка jm +জামাইকা jm +Jamaika jm +Jamajka jm +Jamajka jm +Jamaika jm +Τζαμάικα jm +Jamajko jm +Jamaika jm +جاماییکا jm +Jamaika jm +Jamaïque jm +An Iamáice jm +Xamaica jm +ג'מייקה jm +जमैका jm +Jamajka jm +Jamaika jm +Jamaika jm +Jamaíka jm +Giamaica jm +ジャマイカ jm +ហ្សាម៉ាអ៊ិគ jm +자메이카 jm +ຈາໄມກາ jm +Jamaika jm +Jamaika jm +Јамајка jm +Ямайк jm +Ġamajka jm +Jamaika jm +ਜੈਮੇਕਾ jm +Jamajka jm +Ямайка jm +Jamayika jm +Jamajka jm +Jamajka jm +Јамајка jm +Jamajka jm +I-Jamaica jm +சமெய்க்கா jm +Ҷомойко jm +จาไมก้า jm +Jamaika jm +Jamayka jm +Ямайка jm +Ямайка jm +Djamayike jm +牙买加 jm +牙買加 jm +Jordan jo +Jordaan jo +الأردن jo +İordaniya jo +Ярданія jo +Йордания jo +জর্ডান jo +Jordani jo +Jordània jo +Jordán jo +Gwlad Iorddonen jo +Jordanien jo +Ιορδανία jo +Jordanio jo +Jordania jo +Jordaania jo +Jordania jo +اردن jo +Jordania jo +Jordanie jo +Jordanië jo +An Iordáin jo +Xordánia jo +ירדן jo +जॉर्डन jo +Jordánia jo +Jórdanía jo +Giordania jo +ヨルダン jo +ហ្ស៊កដានី jo +요르단 jo +ຈໍແດນ jo +Jordanija jo +Jordānija jo +Јордан jo +Ёрдан jo +Ġordan jo +Jordanien jo +Jordanië jo +ਜਾਰਡਨ jo +Jordania jo +Jordânia jo +Jordânia jo +Iordania jo +Иордания jo +Yorudani jo +Jordánia jo +Jordánsko jo +Jordanija jo +Јордан jo +I-Jordan jo +Jordanien jo +ஜோர்டான் jo +Урдон jo +จอร์แดน jo +Ürdün jo +Йорданія jo +Иордан jo +Djordaneye jo +约旦 jo +約旦 jo +Ijolidani jo +Japan jp +اليابان jp +Yaponiya jp +Японія jp +Япония jp +জাপান jp +Japon jp +Japó jp +Japonsko jp +Siapan jp +Ιαπωνία jp +Japanio jp +Japón jp +Jaapan jp +Japonia jp +ژاپن jp +Japani jp +Japon jp +An tSeapáin jp +Xapón jp +יפן jp +जापान jp +Japán jp +Jepang jp +Giappone jp +日本 jp +ជប៉ុន jp +일본 jp +ຍີ່ປຸ່ນ jp +Japonija jp +Japāna jp +Јапонија jp +Япон jp +Jepun jp +Ġappun jp +Japon jp +ਜਾਪਾਨ jp +Japonia jp +Japão jp +Japão jp +Japonia jp +Япония jp +Ubuyapani jp +Japána jp +Japonsko jp +Japonska jp +Јапан jp +I-Japan jp +சப்பான் jp +Ҷопон jp +ญี่ปุ่น jp +Japonya jp +Japan, Yaponia jp +Японія jp +Япония jp +Nhật bản jp +Djapon jp +日本 jp +日本 jp +Kenya ke +Kenië ke +كينيا ke +Кенія ke +Кения ke +কেনিয়া ke +Kenija ke +Keňa ke +Cenia ke +Kenia ke +Κένυα ke +Kenjo ke +Kenia ke +کنیا ke +Kenia ke +An Chéinia ke +Kenia ke +קניה ke +केन्या ke +Kenija ke +Kenía ke +ケニア ke +កេនយ៉ា ke +케냐 ke +ເວນດາ ke +Kenija ke +Kenija ke +Кенија ke +Кения ke +Kenja ke +Kenia ke +ਕੀਨੀਆ ke +Kenia ke +Quénia ke +Quênia ke +Kenia ke +Кения ke +Keňa ke +Kenija ke +Кенија ke +Kenija ke +கென்யா ke +Куниё ke +เคนยา ke +Kenia ke +Кенія ke +Кения ke +Kenia ke +肯尼亚 ke +肯亞 ke +Kyrgyzstan kg +قيرغيزستان kg +Кыргызстан kg +Киргизстан kg +কির্গিজস্তান kg +Kirgistan kg +Kirgistan kg +Kyrgigstan kg +Kyrgyzstán kg +Cyrgystan kg +Kirgizistan kg +Kirgisien kg +Κιργιζιστάν kg +Kirgizujo kg +Kyrgyzstán kg +Kõrgõzstan kg +قرقیزستان kg +Kirghizstan kg +An Chirgeastáin kg +Kirguizistán kg +קירגיסטן kg +किर्गिजिस्तान kg +Kirgizisztán kg +Kirgisistan kg +Kirghizistan kg +キルギスタン kg +គៀរហ្គីស្តង់ kg +키르기스스탄 kg +ຄສິຕັລ kg +Kirgistanas kg +Kirgizstāna kg +Киргистан kg +Киргизстан kg +Kirgiżstan kg +Kirgisistan kg +Kirgisien kg +Kirgizië kg +Kirgisistan kg +ਕਿਰਗਸਤਾਨ kg +Kigistan kg +Quirguistão kg +Quirguistão kg +Kirgiztan kg +Киргизстан kg +Kirigizisitani kg +Kirgisistan kg +Kirgizstan kg +Киргистан kg +Kirgistan kg +Kirgizistan kg +கிர்கிஸ்தான் kg +Қирғизистон kg +คีจิสถาน kg +Kırgızistan kg +Qırğızstan kg +Киргизстан kg +Қирғизистон kg +Kirguiztan kg +吉尔吉斯斯坦 kg +吉爾吉斯 kg +Cambodia kh +Kambodië kh +كمبوديا kh +Камбоджа kh +Камбоджа kh +কামবোডিয়া kh +Kambodj kh +Kambođa kh +Cambodja kh +Kambodža kh +Kambodscha kh +Καμπότζη kh +Kamboĝo kh +Kambodža kh +Canbodia kh +کامبوج kh +Kambodza kh +Cambodge kh +Cambodja kh +An Chambóid kh +Camboia kh +קמבודיה kh +कम्बोडिया kh +Kambođa kh +Kambodzsa kh +Kambódía kh +Cambogia kh +カンボジア kh +កម្ពុជា kh +캄보디아 kh +ໂຄລຳເບີຍ kh +Kambodža kh +Kambodža kh +Камбоџа kh +Камбодиа kh +Kemboja kh +Kambodja kh +Kambodsja kh +Kambodscha kh +Cambodja kh +Kambodsja kh +ਕੰਬੋਡੀਆ kh +Kambodża kh +Cambodja kh +Cambodja kh +Cambogia kh +Камбоджа kh +Kamboji kh +Kamboža kh +Kambodža kh +Kambodža kh +Камбоџа kh +Kambodža kh +Kambodja kh +கம்போடியா kh +Камбуҷа kh +กัมพูชา kh +Kamboçya kh +Kambodia kh +Камбоджа kh +Камбоджа kh +Cam pu chia kh +Cambodje kh +柬埔寨 kh +柬埔寨 kh +Kiribati ki +كيريباتي ki +Кiрыбацi ki +Кирибати ki +কিরিবাটি ki +Ciribati ki +Κιριμπάτι ki +Kiribato ki +کیریباتی ki +Ciribeas ki +קיריבאטי ki +किरीबाती ki +Kíribatí ki +キリバス ki +គិរិបាទី ki +키리바시 ki +ແຟຄທັລ - K ki +Кирибати ki +Крибати ki +ਕਿਰਿਬਟੀ ki +Кирибати ki +Кирибати ki +கிரிபடி ki +Карибот ki +คิริบาติ ki +Кірібаті ki +Кирибати ki +基里巴斯 ki +吉里巴斯 ki +Comoros km +جزر القمر km +Каморы km +Коморски острови km +কমোরস km +Komoros km +Komori km +Komory km +Ynysoedd Y Comoros km +Comorerne km +Komoren km +Κομόρες km +Komoroj km +Komoorid km +کوموروس km +Komorit km +Comores km +Na Comóir km +קומורוס km +कोमोरो km +Kómoreyjar km +Comore km +コモロ km +កុំម៉ូរ៉ូស km +코모로 km +ສີ km +Komoru salas km +Коморски острови km +Соморос km +Komoros km +Komorene km +Komoren km +Komorane km +ਕੋਮੋਰੋਸ km +Komory km +Коморские острова km +Komore km +Komorot km +Komori km +Комора km +Komora km +Komorerna km +காமாரோஸ் km +Коморос km +โคโมรอส km +Komoros km +Komorlar km +Коморські острови km +Коморос km +Comores km +科摩罗 km +葛摩 km +St. Kitts and Nevis kn +St. Kitts en Nevis kn +سانت كيتس و نيفيس kn +St. Kitts və Nevis kn +Сэнт-Крыстофер і Нэвіс kn +Св. Китс и Невис kn +সেন্ট কিটস এবং নেভিস kn +S. Kitts ha Nevis kn +St. Kitts i Nevis kn +Sv. Kitts a Nevis kn +Ynysoedd St. Kitts a Nevis kn +St. Kitts-Nevis kn +St. Kitts und Nevis kn +Άγιος Χριστόφορος (Σαιντ Κιτς) και Νέβις kn +Sent-Kristofo kaj Neviso kn +St. Kitts y Nevis kn +St. Kitts ja Nevis kn +St. Kitts eta Nevis kn +سن کیتس و نویس kn +St. Kitts ja Nevis kn +St Kitts et Nevis kn +St. Kitts en Nevis kn +San Críostóir Nimheas kn +Saint Kitts e Nevis kn +סנט קיטס ונביס kn +सेंट किट्स तथा नेविस kn +St. Kitts és Nevis kn +St. Kitts dan Nevis kn +Sankti Kristófer og Nevis kn +Saint Kitts e Nevis kn +セントクリストファーネイビス kn +សង់ឃីត និង នេវីស kn +세인트 키츠 네비스 kn +Šv. Kitts ir Nevis kn +Senkitsa un Nevisa kn +Св. Китс и Невис kn +St. Киттс ба Невис kn +St. Kitts u Nevis kn +St. Kitts og Nevis kn +St. Kitts un Nevis kn +St. Kitts en Nevis kn +St. Kitts og Nevis kn +St. Kitts le Nevis kn +St. Kitts e Nevis kn +ਸੇਂਟ ਕਿਟਸ ਤੇ ਨਿਵੀਸ kn +St. Kitts e Nevis kn +St Kitts e Nevis kn +Sf. Kitts şi Nevis kn +Сент-Китс и Невис kn +Mutagatifu Kitsi na Nevisi kn +St. Kitts ja Nevis kn +St. Kitts a Nevis kn +St. Kitts in Nevis kn +Св. Китс и Невис kn +Sv. Kits i Nevis kn +I-St. Kitts and Nevis kn +St. Kitts och Nevis kn +செயின்ட் கிட்சு & நெவிசு kn +Синт Киттс ва Невис kn +เซนต์กิตส์และเนวิส kn +St. Kitts ve Nevis kn +Santa Kitts wä Nevis kn +Федерація Сент-Кітс і Невіс kn +Сент-Кристофер ва Невис kn +St. Kitts na Nevis kn +St. Kitts và Nevis kn +St. Kitts neNevis kn +圣基茨和尼维斯 kn +聖克理斯多福及尼維斯 kn +St. Kitts kanye no-Nevis kn +North Korea kp +Noord Korea kp +كوريا الشمالية kp +Şimali Koreya kp +Паўночная Карэя kp +Северна Корея kp +উত্তর কোরিয়া kp +Norzh-Korea kp +Sjeverna Koreja kp +Corea del Nord kp +Severní Korea kp +Gogledd Corea kp +Nordkorea kp +Nord-Korea kp +Βόρεια Κορέα kp +Nordkoreo kp +Corea del Norte kp +Põhja-Korea kp +Ipar Korea kp +کره شمالی kp +Pohjois-Korea kp +Norðurkorea kp +Corée du nord kp +Noard-Korea kp +An Chóiré Thuaidh kp +Corea do Norte kp +צפון קוריאה kp +उत्तरी कोरिया kp +Sjeverna Koreja kp +Észak-Korea kp +Korea Utara kp +Norður-Kórea kp +Corea del Nord kp +朝鮮民主主義人民共和国 kp +កូរ៉េខាងជើង kp +조선민주주의 인민공화국 kp +ເກົາລີເຫນືອ kp +Šiaurės Korėja kp +ZiemeļKoreja kp +Северна Кореја kp +Хойд солонгос kp +Korea ta' Fuq kp +Nord-Korea kp +Noordkorea kp +Noord-Korea kp +Nord-Korea kp +Lebowa la Korea kp +Corea dèu Nord kp +ਉੱਤਰੀ ਕੋਰੀਆ kp +Korea Północna kp +Coreia do Norte kp +Coréia do Norte kp +Coreea de Nord kp +Северная Корея kp +Koreya y'Amajyaruguru kp +Davvi-Korea kp +severná Kórea kp +Severna Koreja kp +Северна Кореја kp +Severna Koreja kp +I-North Korea kp +Nordkorea kp +வட கொரியா kp +Кореяи Шимолӣ kp +เกาหลีเหนือ kp +Kuzey Kore kp +Tönyaq Korea kp +Північна Корея kp +Шимолий Корея kp +Devhula ha Korea kp +Bắc Triều Tiên kp +Bijhe Corêye kp +Umntla Korea kp +朝鲜 kp +北韓 kp +Enyakatho ne-Korea kp +South Korea kr +Suid Korea kr +كوريا الجنوبية kr +Cənubi Koreya kr +Паўднёвая Карэя kr +Южна Корея kr +দক্ষিণ কোরিয়া kr +Su-Korea kr +Južna Koreja kr +Corea del Sud kr +Jižní Korea kr +De Corea kr +Sydkorea kr +Süd-Korea kr +Νότια Κορέα kr +Sudkoreo kr +Corea del Sur kr +Lõuna-Korea kr +Hego Korea kr +کره جنوبی kr +Etelä-Korea kr +Suðurkorea kr +Corée du sud kr +Sûd-Korea kr +An Chóiré Theas kr +Corea do Sur kr +דרום קוריאה kr +दक्षिणी कोरिया kr +Južna Koreja kr +Dél-Korea kr +Korea Selatan kr +Suður-Kórea kr +Corea del Sud kr +大韓民国 kr +កូរ៉េខាងត្បូង kr +대한민국 kr +ເກົາລີໃຕ້ kr +Pietų Korėja kr +DievidKoreja kr +Јужна Кореја kr +Өмнөд солонгос kr +Korea t'Isfel kr +Sør-Korea kr +Söödkorea kr +Zuid-Korea kr +Sør-Korea kr +Borwa bja Korea kr +Corea dèu Sud kr +ਦੱਖਣੀ ਕੋਰੀਆ kr +Korea Południowa kr +Coreia do Sul kr +Coréia do Sul kr +Coreea de Sud kr +Южная Корея kr +Koreya y'Amajyepfo kr +Lulli-Korea kr +Južná Kórea kr +Južna Koreja kr +Јужна Кореја kr +Južna Koreja kr +I-South Korea kr +Sydkorea kr +தென் கொரியா kr +Кореяи Ҷанубӣ kr +เกาหลีใต้ kr +Güney Kore kr +Könyaq Korea kr +Південна Корея kr +Жанубий Корея kr +Korea tshipembe kr +Hàn Quốc kr +Nonne Corêye kr +Umzantsi Korea kr +韩国 kr +南韓 kr +Emzansi Korea kr +Kuwait kw +Kuwaït kw +الكويت kw +Кувэйт kw +Кувейт kw +কুয়েত kw +Kowaet kw +Kuvajt kw +Kuvajt kw +Coweit kw +Κουβέιτ kw +Kuvajto kw +Kuveit kw +کویت kw +Kuvait kw +Kowait kw +Koeweit kw +Cuáit kw +כווית kw +कुवैत kw +Kuvajt kw +Kuvait kw +Kúveit kw +クェート kw +គុយវ៉ែត kw +쿠웨이트 kw +ແຕ້ມຮູບ- K kw +Kuveitas kw +Kuveita kw +Кувајт kw +Кувейт kw +Koeweit kw +ਕੁਵੈਤ kw +Koweit kw +Kuveit kw +Кувейт kw +Koweti kw +Kuvajt kw +Kuvajt kw +Кувајт kw +Kuvajt kw +I-Kuwait kw +குவைத் kw +Қувейт kw +คูเวต kw +Küwäyt kw +KКувейт kw +Кувайт kw +Kuweyt kw +科威特 kw +科威特 kw +Cayman Islands ky +Cayman Eilande ky +جزر الكايمان ky +Кайманови острови ky +কেম্যান দ্বীপপুঞ্জ ky +Inizi Kaeman ky +Kajmanska ostrva ky +Illes Caimà ky +Kajmanské ostrovy ky +Ynysoedd Caiman ky +Cayman-øerne ky +Kaiman-Inseln ky +Νησιά Κάυμαν ky +Kejmanoj ky +Islas Caimán ky +Kaimanisaared ky +Kaiman Irlak ky +جزایر کِیمن ky +Cayman-saaret ky +Îles Caïman ky +Kaaiman Eilannen ky +Oileáin na gCadhman ky +Illas Caimán ky +איי קיימן ky +केमन आइलैंड ky +Kajmanski Otoci ky +Kajmán-szigetek ky +Cayman-eyjar ky +Isole Cayman ky +英領ケイマン諸島 ky +កោះកៃម៉ាន ky +케이맨 제도 ky +ຄາຕາລັນ ky +Kaimanų salos ky +Kaimanu salas ky +Кајмански Острови ky +Cayman арлууд ky +Gżejjer Cayman ky +Caymanøyene ky +Kayman-Inseln ky +Kaaiman Eilanden ky +Caymanøyane ky +ਕਾਅਮਾਨ ਟਾਪੂ ky +Kajmany ky +Ilhas Caimão ky +Ilhas Cayman ky +Insulele Cayman ky +Каймановы острова ky +Ibirwa bya Kayimani ky +Caymansullot ky +Kajmanske Ostrovy ky +Kajmanski otoki ky +Кајманска острва ky +Kajmanska ostrva ky +Caymanöarna ky +கேமான் தீவுகள் ky +Ҷазираи Кайман ky +หมู่เกาะเคย์แมน ky +Cayman Adaları ky +Kayman Utrawları ky +Кайман острів ky +Кайман Ороллари ky +Iyes Cayman ky +开曼群岛 ky +開曼群島 ky +Kazakhstan kz +كازاخستان kz +Казахстан kz +Казахстан kz +কাজাকস্তান kz +Kazakstan kz +Kazahstan kz +Kazachstán kz +Casacstan kz +Kasachstan kz +Καζακστάν kz +Kazaĥujo kz +Kazakhstán kz +Kasahstan kz +قزاقستان kz +Kazakstan kz +Kazachstan kz +An Chasacstáin kz +Kazaxistán kz +קזחסטאן kz +कज़ाखिस्तान kz +Kazahstan kz +Kazahsztán kz +Kasakstan kz +Kazakistan kz +カザフスタン kz +កាហ្សាក់ស្តង់ kz +카자흐스탄 kz +ແກແລກຕິກ - K kz +Kazachstanas kz +Kazahstāna kz +Казакстан kz +Казак kz +Każakstan kz +Kasakhstan kz +Kasachstan kz +Kazachstan kz +Kasakhstan kz +ਕਾਜ਼ਾਕਸਤਾਨ kz +Kazachstan kz +Cazaquistão kz +Cazaquistão kz +Cazahstan kz +Казахстан kz +Kazakisitani kz +Kasakhstan kz +Kazachstan kz +Kazahstan kz +Казахстан kz +Kazahstan kz +Kazakstan kz +கஜஸ்தான்` kz +Қазоқистон kz +คาซัคสถาน kz +Kazakistan kz +Qazaqstan kz +Казахстан kz +Қозоғистон kz +Kazaxhtan kz +哈萨克斯坦 kz +哈薩克 kz +Laos la +لاوس la +Лаос la +Лаос la +লাওস la +Λάος la +Laoso la +لائوس la +Láós la +לאוס la +लाओस la +Laosz la +ラオス la +ឡាវ la +라오스 la +ລາວ la +Laosas la +Laosa la +Лаос la +Лаос la +ਲਿਉਸ la +Лаос la +Lawosi la +Лаос la +லாஸ் la +Лаос la +ลาว la +Лаос la +Лаос la +Lào la +Lawosse la +老挝 la +寮國 la +Lebanon lb +Libanon lb +لبنان lb +Ліван lb +Ливан lb +লেবানন lb +Liban lb +Liban lb +Líban lb +Libanon lb +Libanus lb +Libanon lb +Libanon lb +Λίβανος lb +Libano lb +Líbano lb +Liibanon lb +Libano lb +لبنان lb +Libanon lb +Libanon lb +Liban lb +Libanon lb +An Liobáin lb +Líbano lb +לבנון lb +लेबनान lb +Libanon lb +Libanon lb +Líbanon lb +Libano lb +レバノン lb +លីបង់ lb +레바논 lb +ເດນ່ງນ lb +Libanas lb +Libāna lb +Либан lb +Либанон lb +Lubnan lb +Libanu lb +Libanon lb +Libanon lb +Libanon lb +Libanon lb +ਲਿਬਨਾਨ lb +Liban lb +Líbano lb +Líbano lb +Liban lb +Ливан lb +Libani lb +Libanon lb +Libanon lb +Libanon lb +Либан lb +Liban lb +I-Lebanon lb +Libanon lb +லெபனான் lb +Лубнон lb +เลบานอน lb +Ліван lb +Лебанон lb +Li Băng lb +Liban lb +黎巴嫩 lb +黎巴嫩 lb +St. Lucia lc +سانت لوسيا lc +Сэнт-Люсія lc +Св. Лучия lc +সেন্ট লুসিয়া lc +S. Lucia lc +Svatá Lucie lc +St. Lwsia lc +Σάντα Λουτσία lc +Sent-Lucio lc +Santa Lucía lc +سن لوسیا lc +Sankta Lusia lc +Sainte Lucie lc +San Lúisia lc +Santa Lucia lc +סנטה לוסיה lc +सेंट लूसिया lc +Sankti Lúsía lc +Santa Lucia lc +セントルシア lc +សង់លូស៊ីយ៉ា lc +세인트 루시아 lc +ເຊັນລູເຊີຍ lc +Šv Liucija lc +Sv. Lūcija lc +Св. Луција lc +St. Лусиа lc +St. Luċija lc +ਸੇਂਟ ਲੂਉਸ lc +Santa Lúcia lc +Santa Lúcia lc +Sf. Lucia lc +Сент-Люсия lc +Mutagatifu Lusiya lc +Sv. Júlia lc +Sv. Lucija lc +Св. Луција lc +Sv. Lucija lc +I-St. Lucia lc +சென்ட் லூசியா lc +Синт Лусиё lc +เซนต์ลูเซีย lc +Santa Lüçiä lc +Сент-Люсія lc +Сент-Люсия lc +Ste Luceye lc +圣卢西亚 lc +聖露西亞 lc +Liechtenstein li +ليشتنشتاين li +Ліхтэнштэйн li +Лихтенщайн li +লিখটেনস্টাইন li +Lihtenštajn li +Lichtenštejnsko li +Λίχτενσταϊν li +Liĥtenŝtejno li +Liechtestein li +لیختن اشتاین li +An Lichtinstéin li +ליכטנשטין li +लिचटेनस्टीन li +Lihtenštajn li +リヒテンシュタイン li +លិចទេនស្តែន li +리히텐슈타인 li +ຟ້າແມບ li +Lichtenšteinas li +Lihtenšteina li +Лихтенштајн li +Лихтэнштайн li +Liechtensteen li +ਲੀਚਟੀਨਸਟੀਨ li +Lichtensztajn li +Лихтенштейн li +Liyeshitensiteyini li +Лихтенштајн li +Lihtenštajn li +லச்சென்ஸ்டென் li +Лихтанштоин li +ลิชเทนสไตน์ li +Lihtenştayn li +Lihtenstein li +Ліхтенштейн li +Лихтенштейн li +Lîchtensteyn li +列支敦士登 li +列支敦斯登 li +Sri Lanka lk +سريلانكا lk +Шры-Ланка lk +Шри Ланка lk +শ্রীলঙ্কা lk +Šri Lanka lk +Srí Lanka lk +Sri Lanca lk +Σρι Λάνκα lk +Sri-Lanko lk +سریلانکا lk +Srí Lanca lk +סרי לנקה lk +श्री लंका lk +Šri Lanka lk +Srí Lanka lk +スリランカ lk +ស្រីលង្កា lk +스리랑카 lk +ເຊີເບີຍ lk +Šri Lanka lk +Šrilanka lk +Шри Ланка lk +Шириланк lk +ਸ੍ਰੀਲੰਕਾ lk +Шри-Ланка lk +Siri Lanka lk +Šri Lanka lk +Шри Ланка lk +Šri Lanka lk +இலங்கை lk +Сри Лонко lk +ศรีลังกา lk +Şri Lanka lk +Шрі-Ланка lk +Шри Ланка lk +斯里兰卡 lk +斯里蘭卡 lk +Liberia lr +Liberië lr +ليبيريا lr +Лібэрыя lr +Либерия lr +লাইবেরিয়া lr +Liberija lr +Libèria lr +Libérie lr +Λιβερία lr +Liberio lr +Libeeria lr +لیبریا lr +Libéria lr +An Libéir lr +Libéria lr +לוב lr +लाइबेरिया lr +Liberija lr +Libéria lr +Líbería lr +リベリア lr +លីបេរីយ៉ា lr +라이베리아 lr +ລິຊາ lr +Libērija lr +Либерија lr +Либери lr +Liberja lr +ਲੀਬਿਰੀਆ lr +Libéria lr +Libéria lr +Либерия lr +Liberiya lr +Lýbia lr +Liberija lr +Либерија lr +Liberija lr +லிபிரியா lr +Либериё lr +ไลบีเรีย lr +Liberya lr +Ліберія lr +Либерия lr +利比里亚 lr +賴比瑞亞 lr +Lesotho ls +ليسوتو ls +Лесота ls +Лесото ls +লেসোথো ls +Lesoto ls +Lesoto ls +Λεσόθο ls +Lesoto ls +Lesoto ls +لسوتو ls +Leosóta ls +Lesoto ls +לסוטו ls +लेसोथो ls +Lesótó ls +レソト ls +ឡេសូតូ ls +레소토 ls +ທົດສອບ ls +Lesoto ls +Лесото ls +Лисото ls +Leżoto ls +ਲਿਉਥੂ ls +Lesoto ls +Lesoto ls +Lesoto ls +Лесото ls +Lesoto ls +Lesoto ls +Лесото ls +Lesoto ls +லஸொதோ ls +Лисуту ls +เลโซโต ls +Lesoto ls +Lesoto ls +Лесото ls +Лесото ls +Lessoto ls +莱索托 ls +賴索扥 ls +Lithuania lt +Lithuanië lt +ليتوانيا lt +Litvaniya lt +Літва lt +Литва lt +লিথুয়েনিয়া lt +Lituani lt +Litvanija lt +Lituània lt +Litva lt +Lithwania lt +Litauen lt +Litauen lt +Λιθουανία lt +Litovio lt +Lituania lt +Leedu lt +Lituania lt +لیتوانی lt +Liettua lt +Lituanie lt +Litouwen lt +An Liotuáin lt +Lituánia lt +ליטא lt +लिथुआनिया lt +Litva lt +Litvánia lt +Litháen lt +Lituania lt +リトアニア lt +លីទុយអានី lt +리투아니아 lt +ລິທົ່ວເນີຍ lt +Lietuva lt +Lietuva lt +Литванија lt +Литва lt +Litwanja lt +Litauen lt +Litauen lt +Litouwen lt +Litauen lt +ਲੀਥੂਨੀਆ lt +Litwa lt +Lituânia lt +Lituânia lt +Lituania lt +Литва lt +Litwaniya lt +Lietuva lt +Litva lt +Litva lt +Литванија lt +Litvanija lt +I-Lithuania lt +Litauen lt +லித்துவேனியா lt +Литвониё lt +ลิธัวเนีย lt +Litvanya lt +Lituania lt +Литва lt +Литва lt +Litwaneye lt +立陶宛 lt +立陶宛 lt +Luxembourg lu +Luxenburg lu +لوكسمبورغ lu +Lüksemburq lu +Люксэмбург lu +Люксембург lu +লাক্সেমবুর্গ lu +Luksembourg lu +Luksemburg lu +Luxemburg lu +Lucembursko lu +Lwcsembwrg lu +Luxemburg lu +Λουξεμβούργο lu +Luksemburgo lu +Luxemburgo lu +Luksemburg lu +Luxenburgo lu +لوگزامبورگ lu +Luxemburg lu +Luksemborg lu +Luxemburg lu +Lucsamburg lu +Luxemburgo lu +לוקסמבורג lu +लक्समबर्ग lu +Luksemburg lu +Luxemburg lu +Lúxemborg lu +Lussemburgo lu +ルクセンブルグ lu +លុចហ្សំបួរ lu +룩셈부르크 lu +ລັກແຊມເບີກ lu +Liuksemburgas lu +Luksemburga lu +Луксембург lu +Люксембүрг lu +Lussemburgu lu +Luxemborg lu +Luxemburg lu +ਲਕਸ਼ਮਬਰਗ lu +Luksemburg lu +Luxemburgo lu +Luxemburgo lu +Luxemburg lu +Люксембург lu +Lugizamburu lu +Luxemburg lu +Luxemburg lu +Luksemburg lu +Луксембург lu +Luksemburg lu +I-Luxembourg lu +Luxemburg lu +லக்சம்போர்க் lu +Лукзамбург lu +ลักเซมเบอร์ก lu +Lüksemburg lu +Lüksemburg lu +Люксембург lu +Люксембург lu +Lussimbork lu +卢森堡 lu +盧森堡 lu +Latvia lv +لاتفيا lv +Latviya lv +Латвія lv +Латвия lv +লাতভিয়া lv +Latvija lv +Letònia lv +Lotyšsko lv +Latfia lv +Letland lv +Lettland lv +Λεττονία lv +Latvio lv +Letonia lv +Läti lv +لاتویا lv +Lettonie lv +Letland lv +An Laitvia lv +Letónia lv +לטביה lv +लाटविया lv +Latvija lv +Lettország lv +Lettland lv +Lettonia lv +ラトビア lv +ឡាតវីយ៉ា lv +라트비아 lv +ລັດເວີຍ lv +Latvija lv +Latvija lv +Латвија lv +Латви lv +Latvja lv +Lettland lv +Letland lv +ਲਾਟਵੀਆ lv +Łotwa lv +Letónia lv +Латвия lv +Lativiya lv +Látvia lv +Lotyšsko lv +Latvija lv +Латвија lv +Latvija lv +I-Latvia lv +Lettland lv +லட்வியா lv +Латвонӣ lv +ลัธเวีย lv +Litvanya lv +Латвія lv +Латвия lv +Lativia lv +Letoneye lv +拉脱维亚 lv +拉脫維亞 lv +Libya ly +Libië ly +ليبيا ly +Лівія ly +Либия ly +লিবিয়া ly +Julia ly +Libija ly +Líbia ly +Lýbie ly +Libia ly +Libyen ly +Libyen ly +Λιβύη ly +Libio ly +Libia ly +Liibüa ly +Libia ly +لیبی ly +Lybie ly +Libië ly +An Libia ly +Líbia ly +לוב ly +लीबिया ly +Libija ly +Líbia ly +Líbía ly +Libia ly +リビア ly +លីប៊ី ly +리비아 ly +ລິຊາ ly +Libija ly +Lībija ly +Либија ly +Либя ly +Libja ly +Libyen ly +Libië ly +ਲੀਬੀਆ ly +Libia ly +Líbia ly +Líbia ly +Libia ly +Ливия ly +Libiya ly +Lýbia ly +Libija ly +Либија ly +Libija ly +I-Libya ly +Libyen ly +லிபியா ly +Либия ly +ลิเบีย ly +Libia ly +Лівія ly +Либия ly +Libeye ly +利比亚 ly +利比亞 ly +Morocco ma +Morokko ma +المغرب ma +Марока ma +Мароко ma +মরক্কো ma +Marok ma +Maroko ma +Marroc ma +Maroko ma +Moroco ma +Marokko ma +Marokko ma +Μαρόκο ma +Maroko ma +Marruecos ma +Maroko ma +Maroko ma +مراکش ma +Marokko ma +Marokko ma +Maroc ma +Marokko ma +Maracó ma +Marrocos ma +מרוקו ma +मोरक्को ma +Maroko ma +Marokkó ma +Marokkó ma +Marocco ma +モロッコ ma +ម៉ារ៉ុក ma +모로코 ma +ເມົາລິ ma +Marokas ma +Maroka ma +Мароко ma +Морокко ma +Marokk ma +Marokko ma +Marokko ma +Marokko ma +Marokko ma +ਮੋਰਕੋ ma +Maroko ma +Marrocos ma +Marrocos ma +Maroc ma +Марокко ma +Maroke ma +Marokko ma +Maroko ma +Maroko ma +Мароко ma +Maroko ma +I-Morocco ma +Marocko ma +மோராகோ ma +Марокко ma +โมร็อคโค ma +Morokko ma +Марокко ma +Марокаш ma +Ma rốc ma +Marok ma +摩洛哥 ma +摩洛哥 ma +Monaco mc +Monako mc +موناكو mc +Манака mc +Монако mc +মোনাকো mc +Monako mc +Monako mc +Mònaco mc +Monako mc +Μονακό mc +Monako mc +Mónaco mc +موناکو mc +Monacó mc +Mónaco mc +מונקו mc +मोनेको mc +Monako mc +Mónakó mc +モナコ mc +ម៉ូណាកូ mc +모나코 mc +ເມົາລິ mc +Monakas mc +Monako mc +Монако mc +Монако mc +Monako mc +ਮੋਨਕੋ mc +Monako mc +Mónaco mc +Mônaco mc +Монако mc +Monako mc +Monako mc +Monako mc +Монако mc +Monako mc +மனாகோ mc +Монако mc +โมนาโค mc +Monako mc +Manako mc +Монако mc +Монако mc +摩纳哥 mc +摩納哥 mc +Moldova md +مولدوفا md +Малдова md +Молдавия md +মলডোভা md +Moldavi md +Moldàvia md +Moldávie md +Moldofa md +Moldawien md +Μολδαβία md +Moldavujo md +Moldavia md +Moldavia md +مولداوی md +Moldavie md +An Mholdóiv md +Moldávia md +מולדובה md +मॉल्दोवा md +Moldóva md +Moldavia md +モルドバ md +ម៉ុលដូវ៉ា md +몰도바 md +ສະໂລວັກ md +Moldāvija md +Молдавија md +Молдав md +Moldavja md +Moldawien md +Moldavië md +ਮੋਡੋਵਾ md +Mołdawia md +Moldávia md +Молдова md +Molidova md +Moldávsko md +Молдавија md +Moldavija md +Moldavien md +மால்டோவா md +Молдавӣ md +มอลโดวา md +Молдова md +Молдова md +摩尔多瓦 md +摩爾多瓦 md +Madagascar mg +Madagaskar mg +مدغشقر mg +Мадагаскар mg +Мадагаскар mg +মাদাগাস্কার mg +Madagaskar mg +Madagaskar mg +Madagaskar mg +Madagaskar mg +Μαδαγασκάρη mg +Madagaskaro mg +Madagaskar mg +ماداگاسکار mg +Madagaskar mg +מדגסקר mg +मेडागास्कर mg +Madagaskar mg +Madagaszkár mg +Madagaskar mg +マダガスカル mg +ម៉ាដាហ្កាស្ការ mg +마다카스카르 mg +ຄາສະບາລ - K mg +Madagaskaras mg +Madagaskara mg +Мадаскар mg +Мадагаскар mg +Madagaskar mg +Madagaskar mg +Madagaskar mg +Madagaskar mg +ਮੈਡਾਗਾਸਕਰ mg +Madagaskar mg +Madagáscar mg +Мадагаскар mg +Madagasikari mg +Madagaskar mg +Madagaskar mg +Madagaskar mg +Мадагаскар mg +Madagaskar mg +Madagaskar mg +மடகஸ்கார் mg +Мадогоскор mg +มาดากัสกา mg +Madagaskar mg +Madagaskar mg +Мадагаскар mg +Мадагаскар mg +马达加斯加 mg +馬達加斯加 mg +Marshall Islands mh +Marshall EIlande mh +جزر مارشال mh +Маршалавы астравы mh +Маршалски острови mh +মারশাল দ্বীপপুঞ্জ mh +Inizi Marshall mh +Maršalova ostrva mh +Illes Marshall mh +Marshallovy ostrovy mh +Ynysoedd Marshall mh +Marshall-øerne mh +Marshall-Inseln mh +Νησιά Μάρσαλ mh +Marŝaloj mh +Islas Marshall mh +Marshalli saared mh +Marshall Irlak mh +جزایر مارشال mh +Marshallinsaaret mh +Îles Marshall mh +Marshall Eilânen mh +Oileáin Mharshall mh +Illas Marshall mh +איי מרשל mh +मार्शल आइलैंड mh +Marshall Otoci mh +Marshall-szigetek mh +Marshall-eyjar mh +Isole Marshall mh +米自由連合マーシャル諸島 mh +កោះ Marshall mh +마샬 제도 mh +ລາດສະອານາຈັກໄທຍ mh +Marshalo salos mh +Māršalu salas mh +Маршалови Острови mh +Маршаллын арлууд mh +Gżejjer Marshall mh +Marshalløyene mh +Marshallinseln mh +Marshall Eilanden mh +Marshalløyane mh +ਮਾਰਸ਼ਲ ਟਾਪੂ mh +Wyspy Marshalla mh +Ilhas Marshall mh +Ilhas Marshall mh +Insulele Marshall mh +Маршалловы острова mh +Ibirwa bya Marishali mh +Marshallsullot mh +Maršálove ostrovy mh +Marshallovi otoki mh +Маршалова острва mh +Maršalova ostrva mh +Marshallöarna mh +மார்ஷல் தீவுகள் mh +Ҷазираи Маршал mh +หมู่เกาะมาแชล mh +Marşal Adaları mh +Marşal Utrawları mh +Маршальські острови mh +Маршалл Ороллари mh +Iyes Marshall mh +马绍群岛 mh +馬紹爾群島 mh +Macedonia mk +Makedoniese mk +مقدونيا mk +Makedonya mk +Македонія mk +Македония mk +ম্যাসিডোনিয়া mk +Makedonia mk +Makedonija mk +Macedònia mk +Makedonie mk +Makedonien mk +Makedonien mk +Σλαβομακεδονία mk +Makedonujo mk +Makedoonia mk +Mazedonia mk +مقدونیه mk +Makedonia mk +Macédoine mk +Macedonië mk +An Mhacadóin (IPIM) mk +Macedónia mk +מקדוניה mk +मकदूनिया mk +Makedonija mk +Macedónia mk +Masedonia mk +Makedónía mk +マケドニア mk +ម៉ាសេដន mk +마케도니아 mk +ມາເຊໂດເນີຍ mk +Makedonija mk +Maķedonija mk +Македонија mk +Макидон mk +Maċedonja mk +Makedonia mk +Makedonien mk +Macedonië mk +Makedonia mk +Macedònian mk +ਮੈਕਡੋਨੀਆ mk +Macedónia mk +Macedônia mk +Македония mk +Masedoniya mk +Makedonia mk +Macedónsky mk +Makedonija mk +Македонија mk +Makedonija mk +I-Macedonia mk +Makedonien mk +மாசிடோ னியா mk +Мақдуниё mk +มาเซโดเนีย mk +Makedonya mk +Makedonia mk +Македонія mk +Македония mk +Masedonia mk +Macedoneye mk +马其顿 mk +馬其頓 mk +Mali ml +مالي ml +Малі ml +Мали ml +মালি ml +Μαλί ml +Malio ml +مالی ml +Mailí ml +מאלי ml +माली ml +Malí ml +マリ ml +ម៉ាលី ml +말리 ml +ຈົດຫມາຍ ml +Мали ml +Мали ml +ਮਾਲੀ ml +Мали ml +Мали ml +மாலி ml +Молӣ ml +มาลี ml +Малі ml +Мали ml +马里 ml +馬利 ml +Myanmar mm +ميانمار mm +М'янма mm +Мианмар mm +মিয়ানমার mm +Mjanmar mm +Mianmar mm +Burma mm +Burma (Myanmar) mm +Μιανμάρ mm +Mjanmao mm +Birmania mm +میانمار mm +Maenmar mm +מינמר mm +म्यनमार mm +Mianmar mm +Mjanmar mm +ミャンマー mm +មីយ៉ាន់ម៉ា mm +미얀마 mm +ຕົວຮງກພີື້ນທີ່ທຳງານ - K mm +Mjanma mm +Мијанмар mm +Мянмар mm +Mjanmar mm +Myanmar (Birma) mm +ਮਿਆਂਮਾਰ mm +Mianmar mm +Мьянма (Бирма) mm +Mjanmar mm +Мијанмар mm +Mijanmar mm +மயன்மார் mm +Миёнмор mm +เมียนมาร์ mm +Mianmar mm +М'янма mm +Мянмар mm +Miến Điện mm +Birmaneye mm +缅甸 mm +緬甸 mm +Mongolia mn +Mongolië mn +منغوليا mn +Манголія mn +Монголия mn +মোঙ্গোলিয়া mn +Mongoli mn +Mongolija mn +Mongòlia mn +Mongolsko mn +Mongoliet mn +Mongolei mn +Μογγολία mn +Mongolio mn +Mongoolia mn +مغولستان mn +Mongolie mn +Mongolië mn +An Mhongóil mn +Mongólia mn +מונגוליה mn +मंगोलिया mn +Mongolija mn +Mongólia mn +Mongólía mn +モンゴル mn +ម៉ុងហ្គោលី mn +몽골 mn +ລອກອິນ mn +Mongolija mn +Mongolija mn +Монголија mn +МОНГОЛ mn +Mongolja mn +Mongolei mn +Mongolië mn +ਮੰਗੋਲੀਆ mn +Mongólia mn +Mongólia mn +Монголия mn +Mongoliya mn +Mongolsko mn +Mongolija mn +Монголија mn +Mongolija mn +Mongoliet mn +மாங்கோலியா mn +Муғулистон mn +มองโกเลีย mn +Moğolistan mn +Moğolstan mn +Монголія mn +Муғилистон mn +Mông cổ mn +Mongoleye mn +蒙古 mn +蒙古 mn +Macau SAR(China) mo +Macau SAR (China) mo +Макао (Китай) mo +মাকাউ SAR(চীন) mo +Makav SAR(Sina) mo +Macau SAR(Xina) mo +Macau SAR (Čína) mo +Macau SAR(Kina) mo +Macao SAR (China) mo +Μακάο SAR (Κίνα) mo +Macau mo +Macau SAR(Txina) mo +Makao SAR(Kiina) mo +Macao SAR (Chine) mo +Macao SAR(An tSín) mo +מקאו SAR (סין) mo +Makaó (Kína) mo +Makaó (sjálfstjórnarhérað í Kína) mo +Macau SAR(Cina) mo +マカオ(中国) mo +ម៉ាកាវ (ចិន) mo +Macau SAR(Kinija) mo +Макао САР(Кина) mo +Macao SAR (Kina) mo +Macao mo +Macao SAR (Kina) mo +ਮੈਕਿਉ SAR(ਚੀਨ) mo +Makao SAR (Chiny) mo +Macau (China) mo +Macao SAR(China) mo +Макао mo +Makawu SAR (Ubushinwa) mo +Macau SAR (Kiinná) mo +Macau SAR (Kitajska) mo +SAR Macau (Кина) mo +SAR Macau (Kina) mo +Macao (Kina) mo +Macau SAR(சீனா) mo +มาเก๊า mo +Makau (Çin) mo +Macau SAR(Китай) mo +Макау (Хитой) mo +中国澳门特别行政区 mo +澳門 SAR(中國) mo +Martinique mq +مارتينيك mq +Мартыніка mq +Мартиника mq +মার্টিনিক্ mq +Martinik mq +Martinik mq +Martinica mq +Martinik mq +Martin?c mq +Μαρτινίκα mq +Martiniko mq +Martinica mq +Martinika mq +مارتینیک mq +Martainíc mq +Martinica mq +מרטיניק mq +मार्टीनीक mq +Martiník mq +Martinica mq +フランス海外県マルチニーク mq +ម៉ារទីនីគ mq +마르티니크 mq +ເມົາລິ mq +Martinika mq +Martinika mq +Мартиник mq +Мартиники mq +Martinik mq +ਮਾਰਟੀਨਿਕਿਉ mq +Martynika mq +Martinica mq +Martinica mq +Martinica mq +Мартиника mq +Maritinike mq +Martinik mq +Мартиник mq +Martinik mq +மார்தினிக்யு mq +Мартиник mq +มาทินิค mq +Martinik mq +Martinik mq +Мартініка mq +Мартиника mq +Martinike mq +马提尼克 mq +馬提尼克 mq +Mauritania mr +Mauritanië mr +موريتانيا mr +Маўрытанія mr +Мавритания mr +মরিটানিয়া mr +Maouritani mr +Mauritanija mr +Mauritània mr +Mauretánie mr +Mawritania mr +Mauretanien mr +Mauretanien mr +Μαυριτανία mr +Maŭritanujo mr +Mauritaania mr +موراتانی mr +Mauritanie mr +Mauritanië mr +An Mháratáin mr +Mauritánia mr +מאוריטניה mr +मारीतानिया mr +Mauritanija mr +Mauritánia mr +Máritanía mr +モーリタニア mr +ម៉ូរីតានី mr +모리타니 mr +ລິທົວເນີຍ mr +Mauritanija mr +Mauritānija mr +Мавританија mr +Мауритани mr +Mawritanja mr +Mauretanien mr +Mauritanië mr +ਮਾਉਰੀਟਨਿਆ mr +Mauretania mr +Mauritânia mr +Mauritânia mr +Мавритания mr +Moritaniya mr +Mavretanija mr +Мауританија mr +Mauritanija mr +Mauretanien mr +மௌரிடானியா mr +Мавритонӣ mr +มอริทาเนีย mr +Mauritanya mr +Мавританія mr +Мавритания mr +Moritanreye mr +毛里塔尼亚 mr +茅利塔尼亞 mr +Montserrat ms +مونتسيرات ms +Монсерат ms +মন্টসেরাট ms +Monsera ms +Μοντσεράτ ms +Moncerato ms +مونسرات ms +Montsarat ms +מונטסרט ms +मॉटसेरट ms +Monserrat ms +英領モントセラト ms +ម៉ុងសេរ៉ា ms +몬트세라트 ms +ຈໍພາບ ms +Monserata ms +Монсерат ms +Монтсеррат ms +ਮੋਨਟਸੀਰਾਟ ms +Монтсеррат ms +Monserati ms +Монсерат ms +Monserat ms +மான்ட்செர்ரட் ms +Мунтесирот ms +มอนต์เซอร์รัท ms +Монтсеррат ms +Монцеррат ms +蒙特塞拉特 ms +蒙的塞拉特 ms +Malta mt +مالطة mt +Мальта mt +Малта mt +মলটা mt +Malt mt +Μάλτα mt +Malto mt +مالت mt +Malte mt +Málta mt +מלטה mt +माल्टा mt +Málta mt +マルタ mt +ម៉ាល់តា mt +몰타 mt +ມອລຕາ mt +Малта mt +Малта mt +ਮਾਲਟਾ mt +Мальта mt +Malita mt +Малта mt +I-Malta mt +மால்டா mt +Молет mt +มอลตา mt +Мальта mt +Малта mt +Male mt +马耳他 mt +馬爾他 mt +Mauritius mu +موريشيوس mu +Маўрыцы mu +Остров Мавриций mu +মরিশাস mu +Mauris mu +Mauricijus mu +Maurici mu +Mauricius mu +Mawrisiws mu +Μαυρίκιος mu +Maŭricio mu +Mauricio mu +Maurizio mu +موریتیس mu +Île Maurice mu +Oileán Mhuirís mu +Maurício mu +מאוריציוס mu +मॉरीशस mu +Mauricijus mu +Máritíus mu +モーリシャス mu +ម៉ូរីទុស mu +모리셔스 mu +ພາທິຊັ້ນ mu +Maurīcija mu +Маврициус mu +Мавритус mu +Mawriju mu +ਮਾਉਰੀਟਿਸ mu +Mauritânia mu +Ilhas Maurício mu +Mauriţius mu +Маврикий mu +Ibirwa bya Morise mu +Maurícius mu +Mavricij mu +Маурицијус mu +Mauricijus mu +மௌரிடியஸ் mu +Мавритӣ mu +มอริเชียส mu +Mauritus mu +Маврікій mu +Маврикий mu +Iye Môrice mu +毛里求斯 mu +毛里求斯 mu +Maldives mv +جزر المالديف mv +Мальдывы mv +Малдивски острови mv +মালদ্বীপ mv +Inizi Maldiv mv +Maldivi mv +Maledivy mv +Ynysoedd y Mald?f mv +Maldiverne mv +Malediven mv +Μαλδίβες mv +Maldivoj mv +Maldivas mv +Maldiivid mv +Maldibak mv +مالدیو mv +Malediivit mv +Malediven mv +Na Maildiví mv +Maldivas mv +מולדבה mv +मालदीव mv +Maldivi mv +Maldív-szigetek mv +Maldíveyjar mv +Maldive mv +モルジブ mv +ម៉ាល់ឌីវ mv +몰디브 mv +ມັລດິສ mv +Maldyvai mv +Maldivu salas mv +Малдиви mv +Малдив mv +Maldivene mv +Malediven mv +Malediven mv +Maldivane mv +ਮਾਲਦੀਵ mv +Malediwy mv +Maldivas mv +Maldivas mv +Maldive mv +Мальдивские острова mv +Malidive mv +Maldiivat mv +Maldiv mv +Малдиви mv +Maldivi mv +Maldiverna mv +மால்தீவுகள் mv +Молдивӣ mv +มัลดิฟ mv +Maldivler mv +Maldivlar mv +Мальдіви mv +Малдив Ороллари mv +马尔代夫 mv +馬爾地夫 mv +Malawi mw +مالاوي mw +Малаві mw +Малави mw +মালাওয়ি mw +Malavi mw +Μαλάουι mw +Malavio mw +مالاوی mw +An Mhaláiv mw +Malavi mw +מלאווי mw +मलावी mw +Malavi mw +Malaví mw +マラウイ mw +ម៉ាឡាវី mw +말라위 mw +ມອລຕາ mw +Malavi mw +Малави mw +Малави mw +ਮਾਲਾਵੀ mw +Малави mw +Малави mw +Malavi mw +மலவி mw +Моловӣ mw +มาลาวี mw +Malavi mw +Малаві mw +Малави mw +马拉维 mw +馬拉威 mw +Mexico mx +Meksiko mx +المكسيك mx +Meksika mx +Мэксыка mx +Мексико mx +মেক্সিকো mx +Mec'hiko mx +Meksiko mx +Mèxic mx +Mexiko mx +Mecsico mx +Mexiko mx +Μεξικό mx +Meksiko mx +México mx +Mehhiko mx +Mexiko mx +مکزیک mx +Meksiko mx +Meksiko mx +Mexique mx +Meicsiceo mx +México mx +מקסיקו mx +मेक्सिको mx +Meksiko mx +Mexikó mx +Meksiko mx +Mexíkó mx +Messico mx +メキシコ mx +ម៉ិចស៊ិក mx +멕시코 mx +ເມັກຊີໂກ mx +Meksika mx +Meksika mx +Мексико mx +Мексико mx +Messiku mx +Mexiko mx +Mèxic mx +ਮੈਕਸਿਕੋ mx +Meksyk mx +México mx +México mx +Mexic mx +Мексика mx +Megizike mx +Mexiko mx +Mehika mx +Мексико mx +Meksiko mx +I-Mexico mx +மெக்சிகோ mx +Мексико mx +เม็กซิโก mx +Meksika mx +Meksiko mx +Мексика mx +Мексика mx +Mê hi cô mx +Mecsike mx +墨西哥 mx +墨西哥 mx +Malaysia my +Malysië my +ماليزيا my +Малайзыя my +Малайзия my +মালয়েশিয়া my +Malezia my +Malezija my +Malàsia my +Malajsie my +Maleisia my +Μαλαισία my +Malajzio my +Malasia my +Malaisia my +Malasia my +مالزی my +Malesia my +Malaisie my +Maleisië my +An Mhalaeisia my +Malásia my +מלזיה my +मलेशिया my +Malezija my +Malajzia my +Malasía my +マレーシア my +ម៉ាឡេស៊ី my +말레이시아 my +ມອລຕາ my +Malaizija my +Malaizija my +Малезија my +Малайз my +Malażja my +Maleisië my +ਮਲੇਸ਼ੀਆ my +Malezja my +Malásia my +Malásia my +Malaezia my +Малайзия my +Maleziya my +Malajzia my +Malezija my +Малезија my +Malezija my +மலேசியா my +Малайзӣ my +มาเลเซีย my +Malezya my +Малайзія my +Малайзия my +Malaizeye my +马来西亚 my +馬來西亞 my +Mozambique mz +Mosambiek mz +موزمبيق mz +Мазамбік mz +Мозамбик mz +মোজামবিক mz +Mozambik mz +Mozambik mz +Moçambic mz +Mozambik mz +Mosamb?c mz +Μοζαμβίκη mz +Mozambiko mz +Mosambiik mz +Mozanbike mz +موزامبیک mz +Mosambik mz +Mósaimbíc mz +מוזמביק mz +मोज़ाम्बीक mz +Mozambik mz +Mozambik mz +Mósambík mz +Mozambico mz +モザンビーク mz +ម៉ូហ្សាំប៊ិក mz +모잠비크 mz +ຫນ່ວຍຄວາມຈຳ mz +Mozambikas mz +Mozambika mz +Мозамбик mz +Мозамбайк mz +Możambik mz +Mosambik mz +Mosambik mz +Mosambik mz +ਮੋਜ਼ਾਨਬਿਕਿਉ mz +Mozambik mz +Moçambique mz +Moçambique mz +Mozambic mz +Мозамбик mz +Mosambik mz +Mozambik mz +Mozambik mz +Мозамбик mz +Mozambik mz +Moçambique mz +மோசாம்பிக் mz +Мозамбик mz +โมแซมบิก mz +Mozambik mz +Mozambik mz +Мозамбік mz +Мозамбик mz +Mozambike mz +莫桑比克 mz +莫三比克 mz +Namibia na +Namibië na +ناميبيا na +Намібія na +Намибия na +নামিবিয়া na +Namibi na +Namibija na +Namíbia na +Namíbie na +Ναμίμπια na +Namibio na +Namiibia na +نامیبیا na +Namibie na +Namibië na +An Namaib na +Namíbia na +נמיביה na +नामीबिया na +Namibija na +Namíbia na +Namibía na +ナミビア na +ណាមីប៊ី na +나미비아 na +ຈາໄມກາ na +Namibija na +Namībija na +Намибија na +Намиби na +Namibja na +Namibië na +ਨਾਮੀਬੀਆ na +Namíbia na +Namíbia na +Намибия na +Namibiya na +Namíbia na +Namibija na +Намибија na +Namibija na +நாமிபியா na +Намибиё na +นามิเบีย na +Namibya na +Намібія na +Намибия na +Namibeye na +纳米比亚 na +那米比亞 na +New Caledonia nc +Nuwe Caledonië nc +كاليدونيا الجديدة nc +Новая Каледонія nc +Нова Каледония nc +নিউ ক্যালিডোনিয়া nc +Kaledoni-nevez nc +Nova Kaledonija nc +Nova Caledònia nc +Nová Kaledonie nc +Caledonia Newydd nc +Ny Caledonien nc +Neukaledonien nc +Νέα Καληδονία nc +Nov-Kaledonio nc +Nueva Caledonia nc +Uus-Kaledoonia nc +Kaledonia Berria nc +کالدونیا نو nc +Uusi-Kaledonia nc +Nouvelle Calédonie nc +Nij Caledonië nc +An Nua-Chaladóin nc +Nova Caledónia nc +קלדוניה החדשה nc +न्यू केलेदूनिया nc +Nova Kaledonija nc +Új-Kaledónia nc +Nýja-Kaledónía nc +Nuova Caledonia nc +ニューカレドニア nc +នូវែលកាលេដូនី nc +뉴 칼레도니아 nc +ມາເຊໂດເນີຍ nc +Naujoji Kaledonija nc +Jaunkaledonija nc +Нова Каледонија nc +Шинэ каледони nc +Kaledonja Ġdida nc +Ny-Caledonia nc +Nieg Kaledonien nc +Nieuw Caledonië nc +Ny-Caledonia nc +ਨਵਾਂ ਕਾਲੀਡੋਨਾ nc +Nowa Kaledonia nc +Nova Caledónia nc +Nova Caledônia nc +Noua Caledonie nc +Новая Каледония nc +Kaledoniya nc +Ođđa Kaledonia nc +Nová Kaledónia nc +Nova Kaledonija nc +Нова Каледонија nc +Nova Kaledonija nc +Nya Caledonien nc +நியூ கலடோனியா nc +Каледонияи Нав nc +นิวคาเลโดเนีย nc +Yeni Kaledonya nc +Yaña Kaledonia nc +Нова Каледонія nc +Янги Каледония nc +Nouve Caledonreye nc +新喀里多尼亚 nc +新喀里多尼亞 nc +Niger ne +النيجر ne +Нігер ne +Нигер ne +নাইজের ne +Nijer ne +Níger ne +Νίγηρας ne +Niĝero ne +نیجر ne +Nigeria ne +An Nígir ne +Níxer ne +ניג'ר ne +निगर ne +Níger ne +ニジェール ne +នីហ្សេរ ne +니제르 ne +ຕົວຮງກພື້ນທີ່ທຳງານ ne +Nigēra ne +Нигер ne +Нигер ne +Niġer ne +ਨਿਜੀਰ ne +Nigéria ne +Nigéria ne +Нигер ne +Nijeri ne +Nigéria ne +Нигер ne +நிஜர் ne +Нигерӣ ne +ไนเจอร์ ne +Nijerya ne +Нігер ne +Нигер ne +Nidjer ne +尼日尔 ne +尼日 ne +Norfolk Island nf +Norfolk Eiland nf +جزيرة نورفولك nf +Норфалк nf +Остров Норфолк nf +নরফোক দ্বীপপুঞ্জ nf +Enez Norfolk nf +Norfolk ostrvo nf +Illa Norfolk nf +Ynys Norffolc nf +Norfolk-øerne (Australien) nf +Norfolk-Insel nf +Νήσος Νόρφοκ nf +Norfolkinsulo nf +Isla Norfolk nf +Norfolki saar nf +Norfok Irla nf +جزایر نورفولک nf +Norfolkinsaari nf +Île Norfolk nf +Norfolk Eilân nf +Oileán Norfolc nf +Illa Norfolk nf +איי נורפולק nf +नॉरफाक आइलैंड nf +Otok Norfolk nf +Norfolk-szigetek nf +Norfolkeyja nf +Isola Norfolk nf +オーストラリア領ノーフォーク諸島 nf +កោះ Norfolk nf +노포크 제도 nf +ໂປແລນ nf +Norfolko sala nf +Norfolka nf +Норфолшки Остров nf +Norfolk арлууд nf +Gżira ta' Norfolk nf +Norfolkøya nf +Norfolkinsel nf +Norfolk Eiland nf +Norfolkøya nf +ਨੋਰਫੋਲਕ ਟਾਪੂ nf +Wyspy Norfolk nf +Ilha Norfolk nf +Ilhas Norfolk nf +Insulele Norfolk nf +Остров Норфолк nf +Ikirwa cya Norufolika nf +Norfolksuolu nf +Ostrov Norfolk nf +Otok Norfolk nf +Норфолкшко острво nf +Norfolkško ostrvo nf +Norfolkön nf +நார்போக் தீவு nf +Ҷазираи Нурфолк nf +เกาะนอร์ฟอล์ค nf +Norfolk Adaları nf +Norfolk Utrawları nf +Острів Норфолк nf +Норфолк Ороли nf +Iye di Norfolk nf +诺福克岛 nf +諾福克島 nf +Nigeria ng +Nigerië ng +نيجيريا ng +Нігерыя ng +Нигерия ng +নাইজেরিয়া ng +Nijeria ng +Nigerija ng +Nigèria ng +Nigérie ng +Νιγηρία ng +Niĝerio ng +Nigeeria ng +نیجریه ng +Nigéria ng +An Nigéir ng +Nixéria ng +ניגריה ng +नाइजीरिया ng +Nigerija ng +Nigéria ng +Nígería ng +ナイジェリア ng +នីហ្សេរីយ៉ា ng +나이지리아 ng +ບັນແກເລີຍ ng +Nigerija ng +Nigērija ng +Нигерија ng +Нигери ng +Niġerja ng +ਨੀਜੀਰਿਆ ng +Nigéria ng +Nigéria ng +Нигерия ng +Nigeriya ng +Nigéria ng +Nigerija ng +Нигерија ng +Nigerija ng +நிஜேரியா ng +Нигерӣ ng +ไนจีเรีย ng +Nijerya ng +Нігерія ng +Нигерия ng +Nidjeria ng +尼日利亚 ng +奈及利亞 ng +Nicaragua ni +Nikaragua ni +نيكاراغوا ni +Нікарагуа ni +Никарагуа ni +নিকারাগুয়া ni +Nikwaraga ni +Nikaragva ni +Nikaragua ni +Nicaragwa ni +Νικαράγουα ni +Nikaragvo ni +Nikaraagua ni +Nikaragua ni +نیکاراگویه ni +Nikaragua ni +Nikaragua ni +Nicearagua ni +ניקרגווה ni +निकारागुआ ni +Nikaragva ni +Níkaragva ni +ニカラグア ni +នីការ៉ាហ្គ័រ ni +니카라과 ni +ປາລາກກວຍ ni +Nikaragva ni +Nikaragva ni +Никарагва ni +Никрагуа ni +Nikaragwa ni +ਨਿਕਾਰਗੁਆ ni +Nikaragua ni +Nicarágua ni +Nicarágua ni +Никарагуа ni +Nikaragwa ni +Nikaragua ni +Nikaragva ni +Никарагва ni +Nikaragva ni +I-Nicaragua ni +நிகராகுவே ni +Никарагуа ni +นิคารากัว ni +Nikaragua ni +Nikaragua ni +Нікарагуа ni +Никарагуа ni +Nicaragwa ni +尼加拉瓜 ni +尼加拉瓜 ni +Netherlands nl +Nederland nl +هولندا nl +Hollandiya nl +Галяндыя nl +Холандия nl +হল্যাণ্ড nl +Izelvroioù nl +Nizozemska nl +Holanda nl +Nizozemí nl +Yr Iseldiroedd nl +Holland nl +Niederlande nl +Κάτω Χώρες nl +Nederlando nl +Países Bajos nl +Holland nl +Holanda nl +هلند nl +Alankomaat nl +Háland nl +Pays bas nl +Nederlân nl +An Ísiltír nl +Países Baixos nl +הולנד nl +नीदरलैंड्स nl +Nizozemska nl +Hollandia nl +Belanda nl +Holland nl +Paesi Bassi nl +オランダ nl +ហុល្លង់ nl +네덜란드 nl +ເນເທີແລນ์ nl +Olandija nl +Nīderlande nl +Холандија nl +Недерланд nl +Nederland nl +Nedderlanne nl +Nederland nl +Nederland nl +Holanda nl +ਨੀਂਦਰਲੈਂਡ nl +Holandia nl +Holanda nl +Holanda nl +Olanda nl +Нидерланды nl +Ubuholandi nl +Hollánda nl +Holandsko nl +Nizozemska nl +Холандија nl +Holandija nl +I-Netherlands nl +Nederländerna nl +நெதர்லாந்து nl +Ҳуланд nl +เนเธอร์แลนด์ nl +Hollanda nl +Niderlandlar nl +Голландія nl +Нидерландлар nl +Hà Lan nl +Bas Payis nl +荷兰 nl +荷蘭 nl +Norway no +Noorweë no +النرويج no +Norveç no +Нарвэгія no +Норвегия no +নরওয়ে no +Norvegia no +Norveška no +Noruega no +Norsko no +Norwy no +Norge no +Norwegen no +Νορβηγία no +Norvegio no +Noruega no +Norra no +Norvegia no +نروژ no +Norja no +Norra no +Norvège no +Noorwegen no +An Iorua no +Noruega no +נורבגיה no +नार्वे no +Norveška no +Norvégia no +Norwegia no +Noregur no +Norvegia no +ノルウェー no +ន័រវែស no +노르웨이 no +ນໍເວ no +Norvegija no +Norvēģija no +Норвешка no +Норвеги no +Norveġja no +Norge no +Norwegen no +Noorwegen no +Noreg no +Noruega no +ਨਾਰਵੇ no +Norwegia no +Noruega no +Noruega no +Norvegia no +Норвегия no +Noruveje no +Norga no +Nórsko no +Norveška no +Норвешка no +Norveška no +I-Norway no +Norge no +நார்வே no +Норвегӣ no +นอร์เวย์ no +Norveç no +Норвегія no +Норвегия no +Na uy no +Norvedje no +挪威 no +挪威 no +Nepal np +نيبال np +Нэпал np +Непал np +নেপাল np +Nepál np +Νεπάλ np +Nepalo np +نپال np +Népal np +Neipeal np +נפאל np +नेपाल np +Nepál np +ネパール np +នេប៉ាល់ np +네팔 np +ເວນດາ np +Nepalas np +Nepāla np +Непал np +Непал np +ਨੇਪਾਲ np +Непал np +Nepali np +Непал np +நேபாளம் np +Нипол np +เนปาล np +Непал np +Непал np +尼泊尔 np +尼泊爾 np +Nauru nr +ناورو nr +Науру nr +Науру nr +নাউরু nr +Naurueg nr +Nawrw nr +Ναουρού nr +Naŭro nr +Naurú nr +نائورو nr +Naurusaaret nr +Nárúis nr +נאורו nr +नौरू nr +Naurski nr +Nárú nr +ナウル nr +ណូរូ nr +나우루 nr +ປາລາກກວຍ nr +Науру nr +Науру nr +Nawru nr +ਨਾਉਰੂ nr +Науру nr +Ikinawuru nr +Науру nr +நௌரு nr +Науру nr +นาวรู nr +Науру nr +Науру nr +Nawouro nr +瑙鲁 nr +諾魯 nr +Niue nu +Nieu nu +نيوي nu +Ніўэ nu +Ниуе nu +নিউই nu +Niwe nu +Νιούε nu +Niuo nu +نیئو nu +ניווה nu +नियू nu +ニュージーランド自治領ニウエ nu +នីវ nu +니우에 nu +ເນ໊ຕ nu +Није nu +Ниуе nu +Niwe nu +ਨੀਉਈ nu +Ниуе nu +Ниуе nu +நீயு nu +Ниу nu +นิอุเอ nu +Nive nu +Niu nu +Ніуе nu +Ниуе nu +Niuwé nu +纽埃 nu +紐鄂島 nu +New Zealand nz +Nuwe Seeland nz +نيوزيلاندا nz +Yeni Zellandiya nz +Новая Зэляндыя nz +Нова Зеландия nz +নিউজিল্যাণ্ড nz +Zeland nevez nz +Novi Zeland nz +Nova Zelanda nz +Nový Zéland nz +Seland Newydd nz +Neuseeland nz +Νέα Ζηλανδία nz +Nov-Zelando nz +Nueva Zelanda nz +Uus-Meremaa nz +Zelanda Berria nz +زلاندنو nz +Uusi-Seelanti nz +Nýsæland nz +Nouvelle Zélande nz +Nij Seelân nz +An Nua-Shéalainn nz +Nova Celándia nz +ניו זילנד nz +न्यूजीलैंड nz +Novi Zeland nz +Új-Zéland nz +Selandia Baru nz +Nýja-Sjáland nz +Nuova Zelanda nz +ニュージーランド nz +នូវែលហ្សេឡង់ nz +뉴질랜드 nz +ນີວຊີແລນ nz +Naujoji Zelandija nz +JaunZēlande nz +Нов Зеланд nz +Шинэ зеаланд nz +Nieg Seeland nz +Nieuw Zeeland nz +Navera Zelanda nz +ਨਿਊਜ਼ੀਲੈਂਡ nz +Nowa Zelandia nz +Nova Zelândia nz +Nova Zelândia nz +Noua Zeelandă nz +Новая Зеландия nz +Nuveli Zelande nz +Ođđa Zealánda nz +Nový Zéland nz +Nova Zelandija nz +Нови Зеланд nz +Novi Zeland nz +I-New Zealand nz +Nya Zeeland nz +நியூசிலாந்து nz +Зилонди Нав nz +นิวซีแลนด์ nz +Yeni Zelanda nz +Yaña Zealand nz +Нова Зеландія nz +Янги Зеландия nz +Nouve Zelande nz +新西兰 nz +紐西蘭 nz +Oman om +عُمان om +Аман om +Оман om +ওমান om +Omán om +Ομάν om +Omano om +Omán om +Omaan om +عمان om +Omán om +עומן om +ओमन om +Omán om +Óman om +オマーン om +អូម៉ង់ om +오만 om +ເຍີຍລະມັນ om +Omanas om +Omāna om +Оман om +Оман om +ਓਮਾਨ om +Omã om +Omã om +Оман om +Omani om +Omán om +Оман om +I-Oman om +ஓமன் om +Оман om +โอมาน om +Umman om +Оман om +Уммон om + Oman om +阿曼 om +阿曼 om +Panama pa +بنما pa +Панама pa +Панама pa +পানামা pa +Panamà pa +Παναμάς pa +Panamo pa +Panamá pa +پاناما pa +Panamá pa +פנמה pa +पनामा pa +パナマ pa +ប៉ាណាម៉ា pa +파나마 pa +ປານາມາ pa +Панама pa +Панама pa +ਪੈਨਾਮਾ pa +Panamá pa +Panamá pa +Панама pa +Панама pa +I-Panama pa +பனாமா pa +Панама pa +ปานามา pa +Панама pa +Панама pa +巴拿马 pa +巴拿馬 pa +Peru pe +البيرو pe +Пэру pe +Перу pe +পেরু pe +Perou pe +Perú pe +Periw pe +Περού pe +Peruo pe +Perú pe +Peruu pe +پرو pe +Pérou pe +Peiriú pe +Perú pe +פרו pe +पेरू pe +Perú pe +Perù pe +ペルー pe +ប៉េរូ pe +페루 pe +ເປລູ pe +Перу pe +Перу pe +Pero pe +ਪੇਰੂ pe +Перу pe +Перу pe +I-Peru pe +பெரு pe +Перу pe +เปรู pe +Перу pe +Перу pe +Perou pe +秘鲁 pe +秘魯 pe +French Polynesia pf +Fraans Polynesië pf +بولينيزيا الفرنسية pf +Француская Палінэзія pf +Полинезия pf +ফরাসী পলিনেশিয়া pf +Polinezi galleg pf +Francuska Polinezija pf +Polinèsia francessa pf +Francouzská Polynésie pf +Polynesia Ffrengig pf +Fransk Polynesien pf +Französisch Polynesien pf +Γαλλική Πολυνησία pf +Franca Polinezio pf +Polinesia francesa pf +Prantsuse Polüneesia pf +Polinesia Frantziarra pf +پولونزی فرانسه pf +Ranskan Polynesia pf +Polynésie française pf +Frânsk Polinesië pf +Polainéis na Fraince pf +Polinésia Francesa pf +פולינזיה הצרפתית pf +फ्रेंच पॉलीनेसिया pf +Francuska Polinezija pf +Francia-Polinézia pf +Franska Pólýnesía pf +Polinesia Francese pf +フランス領ポリネシア pf +ប៉ូលីនេស៊ីបារាំង pf +프랑스령 폴리네시아 pf +ຝຣັ່ງເສດ pf +Prancūzų Polinezija pf +Franču Polinēzija pf +Француска Полинезија pf +Франц полинеси pf +Polineżja Franċiża pf +Fransk Polynesia pf +Franzöösch Polynesien pf +Frans Polinesië pf +Fransk Polynesia pf +ਫਰੈਂਚ ਪੋਲੀਂਸੀਆ pf +Polinezja Francuska pf +Polinésia Francesa pf +Polinésia Francesa pf +Polinezia Franceză pf +Французская Полинезия pf +Polinesiya Mfaransa pf +Fránskkalaš Polynesia pf +Francúzska Polynézia pf +Francoska Polinezija pf +Француска Полинезија pf +Francuska Polinezija pf +Franska Polynesien pf +பிரன்சு போலினேசியா pf +Пулинезияи Фаронса pf +ฝรั่งเศสโพลีนีเซีย pf +Fransız Polinezyası pf +Frans Polinesia pf +Французька Полінезія pf +Француз Полинезия pf +Polynesia thuộc Pháp pf +Polinezeye francesse pf +法属波利尼西亚 pf +法屬波利尼西亞 pf +Papua New Guinea pg +بابوا غينيا الجديدة pg +Papua Yeni Gvineya pg +Папуа–Новая Гвінэя pg +Папуа Нова Гвинея pg +পাপুয়া নিউ গিনি pg +Papouazi Gine Nevez pg +Papua Nova Gvineja pg +Papua Nova Guinea pg +Papua - Nová Guinea pg +Papwa Gini Newydd pg +Papua Neu-Guinea pg +Παπούα Νέα Γουινέα pg +Papuo-Nov-Gvineo pg +Papua Nueva Guinea pg +Paapua Uus-Guinea pg +Papua Ginea Berria pg +پاپوا گینه نو pg +Papua-Uusi-Guinea pg +Papouasie-Nouvelle-Guinée pg +Papua Nij Guinea pg +Nua-Ghuine Phapua pg +Papúa Nova Guiné pg +פפואה ניו גיני pg +पापुआ न्यू गियाना pg +Papua Nova Gvineja pg +Pápua Új-Guinea pg +Papúa Nýja-Gínea pg +Papua Nuova Guinea pg +パプアニューギニア pg +ប៉ាពូញូវហ្គីណេ pg +파푸아뉴기니 pg +ເທົາອ່ອນ pg +Papua Naujoji Gvinėja pg +Papua Jaungvineja pg +Папуа Нова Гвинеја pg +Папуа шинэ Гуйнеа pg +Papwa Ginea pg +Papua Ny-Guinea pg +Papua-Niegguinea pg +Papua Ny-Guinea pg +ਪਾਪੂਆ ਨਵਾਂ ਗੂਈਆ pg +Papua Nowa Gwinea pg +Papua Nova Guiné pg +Papua Nova Guiné pg +Papua Noua Guinee pg +Папуа-Новая Гвинея pg +Papuwa Gineya Nshya pg +Papua Ođđa-Guinea pg +Papua Nová Guinea pg +Papua Nova Gvineja pg +Папуа Нова Гвинеја pg +Papua Nova Gvineja pg +Papua Nya Guinea pg +பாப்பா நியூ ஜினியா pg +Папуа Гвинеияи Нав pg +ปาปัวนิวกินี pg +Papua Yeni Gine pg +Papua Yaña Guinea pg +Папуа Нова Гвінея pg +Папуа Янги Гвинея pg +Papouwazeye Nouve Guinêye pg +巴布亚新几内亚 pg +巴布紐幾內亞 pg +Philippines ph +Fillipyne ph +الفلبين ph +Fillipinlər ph +Філіпіны ph +Филипини ph +ফিলিপিনস ph +Filipin ph +Filipini ph +Filipines ph +Filipíny ph +Ynysoedd Y Philipinau ph +Filippinerne ph +Philippinen ph +Φιλιππίνες ph +Filipinoj ph +Filipinas ph +Filipiinid ph +Filipinak ph +فیلیپین ph +Filippiinit ph +Filippijnen ph +Na hOileáin Fhilipíneacha ph +Filipinas ph +פיליפינים ph +फिलिप्पीन्स ph +Filipini ph +Fülöp-szigetek ph +Filippseyjar ph +Filippine ph +フィリピン ph +ហ្វ៊ីលីពីន ph +필리핀 ph +ອາລະປະໂຫຍດ ph +Filipinai ph +Filipīnas ph +Филипини ph +Плиппин ph +Filippini ph +Filippinene ph +Philippinen ph +Filippijnen ph +Filippinane ph +ਫਿਲੀਪੀਨਜ਼ ph +Filipiny ph +Filipinas ph +Filipinas ph +Filipine ph +Филиппины ph +Filipine ph +Filippiinat ph +Filipíny ph +Filipini ph +Филипини ph +Filipini ph +Filippinerna ph +பிலிப்பைன்ஸ் ph +Филипин ph +ฟิลิปปินส์ ph +Filipinler ph +Filippinnär ph +Філіппіни ph +Филиппин ph +Filipenes ph +菲律宾 ph +菲律賓 ph +Pakistan pk +باكستان pk +Пакістан pk +Пакистан pk +পাকিস্তান pk +Paquistà pk +Pákistán pk +Pacistan pk +Πακιστάν pk +Pakistano pk +پاکستان pk +An Phacastáin pk +Paquistán pk +פאקיסטן pk +पाकिस्तान pk +Pakisztán pk +パキスタン pk +ប៉ាគីស្ថាន pk +파키스탄 pk +ລງບ pk +Pakistanas pk +Pakistāna pk +Пакистан pk +Пакистан pk +ਪਾਕਿਸਤਾਨ pk +Paquistão pk +Paquistão pk +Пакистан pk +Pakisitani pk +Пакистан pk +பாகிஸ்தான் pk +Покистон pk +ปากีสถาน pk +Päqstan pk +Пакистан pk +Покистон pk +巴基斯坦 pk +巴基斯坦 pk +Poland pl +بولندا pl +Polşa pl +Польшча pl +Полша pl +পোল্যাণ্ড pl +Polonia pl +Poljska pl +Polònia pl +Polsko pl +Gwlad Pwyl pl +Polen pl +Polen pl +Πολωνία pl +Pollando pl +Polonia pl +Poola pl +Polonia pl +لهستان pl +Puola pl +Pólland pl +Pologne pl +Polen pl +An Pholainn pl +Polónia pl +פולין pl +पोलैंड pl +Poljska pl +Lengyelország pl +Polandia pl +Pólland pl +Polonia pl +ポーランド pl +ប៉ូឡូញ pl +폴란드 pl +ໂປແລນ pl +Lenkija pl +Polija pl +Полска pl +Польш pl +Polonja pl +Polen pl +Polen pl +Polen pl +Polen pl +Polònia pl +ਪੋਲੈਂਡ pl +Polska pl +Polónia pl +Polônia pl +Polonia pl +Польша pl +Polonye pl +Polska pl +Poľsko pl +Poljska pl +Пољска pl +Poljska pl +I-Poland pl +Polen pl +போலாந்து pl +Поландия pl +โปแลนด์ pl +Polonya pl +Polonia, Polşa pl +Польща pl +Полша pl +Pholandi pl +Ba Lan pl +Pologne pl +波兰 pl +波蘭 pl +Saint Pierre and Miquelon pm +St Pierre en Miquelon pm +سانت بيير و ميكيلون pm +Saint Pierre və Miquelon pm +Сэн-П'ер і Мікелон pm +Св. Пиер и Магелан pm +সেন্ট পিয়ের এবং মিকেলন pm +Sant Per ha Mikelon pm +Sveti Pjer i Migelon pm +Saint Pierre i Miquelon pm +Saint Pierre a Miquelon pm +Ynysoedd Sant Pierre a Micwelon pm +Saint Pierre og Miquelon pm +Saint Pierre und Miquelon pm +Σαιν Πιέρ (Άγιος Πέτρος) και Μικελόν pm +Sent-Piero kaj Mikelono pm +Saint Pierre y Miquelon pm +Saint Pierre ja Miquelon pm +Saint Pierre eta Miquelon pm +سنت پیِر و میکولئون pm +Saint-Pierre ja Miquelon pm +Saint-Pierre-et-Miquelon pm +Saint Pierre en Miquelon pm +Peadar Naofa agus Micilín pm +Saint Pierre e Miquelon pm +סאן פייר ומיקלון pm +सेंट पियरे तथा मिक्वेलन pm +Saint Pierre i Miquelon pm +Saint Pierre és Miquelon pm +Sankti Pierre og Miquelon pm +Saint Pierre e Miquelon pm +フランス海外領土サンピエールミクロン諸島 pm +세인트 피에르 미쿠엘론 pm +Senpjēra un Mikelona pm +Свети Пјер и Микелон pm +Сайнт пиерре ба микуелон pm +Saint Pierre u Miquelon pm +Saint-Pierre-et-Miquelon pm +Sankt Pierre un Miquelon pm +Saint Pierre en Miquelon pm +Saint-Pierre-et-Miquelon pm +ਸੇਂਟ ਪੀਈਰੀ ਤੇ ਮਾਕਿਉਲੋਨ pm +Saint Pierre i Miquelon pm +S. Pedro e Miquelão pm +Saint Pierre e Miquelon pm +Saint Pierre şi Miquelon pm +Сен-Пьер и Микелон pm +Mutagatifu Petero na Mikelo pm +Saint-Pierre-et-Miquelon pm +Saint Pierre a Miquelon pm +Sveti Pierre in Miquelon pm +Св. Пјер и Микелон pm +Sv. Pjer i Mikelon pm +Saint Pierre och Miquelon pm +செயின்ட் பியரி மற்றும் மிக்யுலன் pm +Синт Пир Миколеюн pm +เซนต์ปิแอร์ และมิเคอลอน pm +Saint Pierre ve Miquelon pm +Saint Pierre wä Miquelon pm +Сент-П'єр і Мікелон pm +Сент-Пер ва Микелон pm +Sint Pire et Miquelon pm +圣皮埃尔和密克隆 pm +聖皮埃爾島及密克隆島 pm +Pitcairn pn +بيتكايرن pn +Піткэрн pn +Острови Питкерн pn +পিটকেম pn +Pitkern pn +Ynys Pitcairn pn +Πίτκαιρν pn +Pitkarna Insulo pn +پیت کِرن pn +פיטקרן pn +पिटकैर्न pn +英領ピトケアン諸島 pn +핏케언 pn +ລງບ pn +Pitkērna pn +Питкерн pn +Питкайрн pn +ਪੀਟਕਾਰਨ pn +Питкаирн pn +பிட்காய்ன் pn +Питкорин pn +เกาะพิตแคร์น pn +Pitkairn pn +Питкерн pn +皮特开恩 pn +匹特開恩島 pn +Puerto Rico pr +بورتوريكو pr +Puerto Riko pr +Пуэрта Рыка pr +Порто Рико pr +পুয়ের্তো রিকো pr +Porto Rico pr +Portoriko pr +Portoriko pr +Pwerto Rico pr +Πουέρτο Ρίκο pr +Puerto-Riko pr +پورتوریکو pr +Porto Rico pr +Portó Ríce pr +Porto Rico pr +פורטו ריקו pr +प्यूर्टो रिको pr +Portoriko pr +Púertó Ríkó pr +Portorico pr +プエルトリコ pr +ព័រតូរីកូ pr +푸에르토리코 pr +ໂປຣໂຕຄອນ pr +Puerto Rikas pr +Puertoriko pr +Порто Рико pr +Пуерто Рико pr +ਰੂਇਰਟੂ ਰੀਕੋ pr +Porto Rico pr +Porto Rico pr +Пуэрто-Рико pr +Porito Riko pr +Portoriko pr +Порторико pr +Portoriko pr +ப்யுர்டோ ரிகோ pr +Пурто Рико pr +เปอร์โตริโก pr +Porta Riko pr +Puerto Riko pr +Пуерто-Ріко pr +Пуэрто-Рико pr +Porto Rico pr +波多黎各 pr +波多黎各 pr +Palestinian Territory ps +Palesteinse Gebied ps +السلطة الفلسطينية ps +Fələstin Sahəsi ps +Палестынская тэрыторыя ps +Палестина ps +প্যালেস্টিনিয়ান টেরিটরি ps +Palestinska teritorija ps +Territori Palestí ps +Palestinské území ps +Tiriogaeth Palesteina ps +Palæstinensiske selvstyreområder ps +Palästinensisches Gebiet ps +Παλαιστίνη ps +Palestina Teritorio ps +Territorio palestino ps +Palestiina ps +Palestina ps +فلسطین ps +Palestiinalaisalue ps +Palestinensiska økið ps +Territoire palestinien ps +Palestijnsk territorium ps +Críoch na bPalaistíneach ps +Território Palestino ps +השטחים הפלסטיניים ps +फिलीस्तीनी टेरिटरी ps +Palestinski teritorij ps +Palesztin területek ps +Palestína ps +Palestina ps +パレスチナ自治区 ps +ប៉ាលេស្ទីន ps +팔레스타인 자치구 ps +ການພິມຜິດພາດ ps +Palestinos teritorija ps +Palestīniešu treitorija ps +Палестински територии ps +Палестины газар нутаг ps +Palestina ps +Palestinske territorier ps +De palästinensche sülvenregeerte Regioon ps +Palestijns territorium ps +Palestinske territorium ps +Bohwa bja Palestina ps +ਫਲਾਸਤੀਨ ਖੇਤਰ ps +Palestyna ps +Território Palestiniano ps +Território Palestino ps +Teritoriul Palestinian ps +Палестинские территории ps +Igihugu cya Palesitina ps +Palestiinnalaš territoria ps +Palestínske územia ps +Palestinski teritorij ps +Палестина ps +Palestina ps +I-Palestinian Territory ps +Palestina ps +பாலஸ்தீன ஆணையம் ps +Фаластин ps +เขตปกครองปาเลสไตน์ ps +Filistin Bölgesi ps +Fälestin ps +Палестинська територія ps +Фаластин Ерлари ps +Mukano wa maphalesitina ps +Lãnh thổ của Palestine ps +Palestene ps +Umhlaba wePalestina ps +巴勒斯坦地区 ps +巴勒斯坦領地 ps +Indawo yama-Phalesitina ps +Portugal pt +البرتغال pt +Portuqaliya pt +Партугалія pt +Португалия pt +পোর্তুগাল pt +Portugalsko pt +Portiwgal pt +Πορτογαλία pt +Portugalo pt +پرتغال pt +Portugali pt +An Phortaingéil pt +פורטוגל pt +पुर्तगाल pt +Portugália pt +Portúgal pt +Portogallo pt +ポルトガル pt +ព័រទុយហ្គាល់ pt +포르투갈 pt +ໂປຣຕຸເກສ pt +Portugalija pt +Portugāle pt +Португалија pt +Португал pt +Portugall pt +ਪੁਰਤਗਾਲ pt +Portugalia pt +Portugalia pt +Португалия pt +Poritigali pt +Portugalsko pt +Portugalska pt +Португал pt +I-Portugal pt +போர்த்துகல் pt +Пуртуқол pt +โปรตุเกส pt +Portekiz pt +Portugalia pt +Португалія pt +Португалия pt +Bồ Đào Nha pt +葡萄牙 pt +葡萄牙 pt +Palau pw +بالاو pw +Палау pw +Палау pw +পালাউ pw +Palaw pw +Παλάου pw +Palao pw +پالائو pw +פלאו pw +पलाऊ pw +Palá pw +パラオ pw +ប៉ាឡូ pw +팔라우 pw +ມອລຕາ pw +Палау pw +Палау pw +ਪਾਲਾਉ pw +Палау pw +Palawu pw +Палау pw +பலாவ் pw +Палау pw +เกาะพาเลา pw +Палау pw +Палау pw +Palawou pw +帕劳 pw +帛琉 pw +Paraguay py +Paraguaai py +باراغواي py +Paraqvay py +Парагвай py +Парагвай py +প্যারাগুয়ে py +Paragwae py +Paragvaj py +Paraguai py +Paragw?i py +Παραγουάη py +Paragvajo py +Paraguai py +پاراگویه py +Paragua py +Paraguai py +פרגואי py +पैरागुए py +Paragvaj py +Paragvæ py +パラグアイ py +ប៉ារ៉ាហ្គាយ py +파라과이 py +ປາລາກກວຍ py +Paragvajus py +Paragvaja py +Парагвај py +Парагвай py +Paragwaj py +Paraguai py +ਪਾਰਾਗੁਆ py +Paragwaj py +Paraguai py +Paraguai py +Paraguai py +Парагвай py +Paragwe py +Portugalsko py +Paragvaj py +Парагвај py +Paragvaj py +I-Paraguay py +பராகுவே py +Порогвие py +ปารากวัย py +Парагвай py +Парагвай py +Paragway py +巴拉圭 py +巴拉圭 py +Qatar qa +قطر qa +Катар qa +Катар qa +কাতার qa +Kwatar qa +Katar qa +Katar qa +Catar qa +Katar qa +Κατάρ qa +Kataro qa +Katar qa +قطر qa +Katar qa +Catar qa +קטר qa +क़तर qa +Katar qa +Katar qa +Katar qa +カタール qa +កាតារ qa +카타르 qa +ມອລຕາ qa +Kataras qa +Katara qa +Катар qa +Катар qa +Katar qa +ਕਤਰ qa +Katar qa +Катар qa +Katari qa +Katar qa +Katar qa +Катар qa +Katar qa +I-Qatar qa +கதார் qa +Қатар qa +ควาตาร์ qa +Katar qa +Катар qa +Қатар qa +Katar qa +卡塔尔 qa +卡達 qa +Romania ro +Romenië ro +رومانيا ro +Rumıniya ro +Румынія ro +Румъния ro +রুমেনিয়া ro +Roumani ro +Rumunija ro +Rumunsko ro +Rumænien ro +Rumänien ro +Ρουμανία ro +Rumanio ro +Rumanía ro +Rumeenia ro +Errumania ro +رومانی ro +Rumenia ro +Roumanie ro +Roemenië ro +An Rómáin ro +Románia ro +רומניה ro +रोमानिया ro +Rumunjska ro +Románia ro +Rumania ro +Rúmenía ro +ルーマニア ro +រូម៉ានី ro +루마니아 ro +ໂລມາເນີຍ ro +Rumunija ro +Rumānija ro +Романија ro +Румын ro +Rumanija ro +Rumänien ro +Roemenië ro +ਰੋਮਾਨੀਆ ro +Rumunia ro +Roménia ro +Romênia ro +România ro +Румыния ro +Romaniya ro +Románia ro +Rumunsko ro +Romunija ro +Румунија ro +Rumunija ro +I-Romania ro +Rumänien ro +ருமேனியா ro +Руминия ro +โรมาเนีย ro +Romanya ro +Румунія ro +Руминия ro +Roumaneye ro +罗马尼亚 ro +羅馬尼亞 ro +Russia ru +Rusland ru +روسيا ru +Rusiya ru +Расея ru +Русия ru +রাশিয়া ru +Rusia ru +Rusija ru +Rússia ru +Rusko ru +Rwsia ru +Rusland ru +Russland ru +Ρωσία ru +Ruslando ru +Rusia ru +Venemaa ru +Errusia ru +روسیه ru +Venäjä ru +Russland ru +Russie ru +Rusland ru +An Rúis ru +Rúsia ru +רוסיה ru +रुस ru +Rusija ru +Oroszország ru +Rusia ru +Rússland ru +ロシア ru +រូស្ស៊ី ru +러시아 ru +ລັດເຊີຍ ru +Rusija ru +Krievija ru +Русија ru +Орос ru +Russja ru +Russland ru +Russland ru +Rusland ru +Russland ru +ਰੂਸ ru +Rosja ru +Rússia ru +Rússia ru +Rusia ru +Россия ru +Uburusiya ru +Ruošša ru +Rusko ru +Rusija ru +Русија ru +Rusija ru +I-Russia ru +Ryssland ru +ரசியா ru +Руссия ru +รัสเซีย ru +Rusya ru +Urısia, Räsäy ru +Росія ru +Россия ru +Rashia ru +Nga ru +Rûsseye ru +Rashiya ru +俄罗斯 ru +俄羅斯 ru +Rwanda rw +رواندا rw +Ruanda rw +Руанда rw +Руанда rw +রোয়ান্ডা rw +Ruanda rw +Ruanda rw +Ruanda rw +Ρουάντα rw +Ruando rw +Ruanda rw +رواندا rw +Ruanda rw +Ruanda rw +Ruanda rw +רואנדה rw +रवांडा rw +Ruanda rw +Ruanda rw +Rúanda rw +Ruanda rw +ルワンダ rw +រវ៉ាន់ដា rw +르완다 rw +ແພນດ້າ rw +Ruanda rw +Ruanda rw +Руанда rw +Рванда rw +Ruanda rw +ਰਵਾਂਡਾ rw +Ruanda rw +Ruanda rw +Ruanda rw +Ruanda rw +Руанда rw +Ruanda rw +Руанда rw +Ruanda rw +வான்டா rw +Руондо rw +รวันด้า rw +Ruanda rw +Руанда rw +Рванда rw +卢旺达 rw +盧安達 rw +Saudi Arabia sa +Saudi Arabië sa +السعودية sa +Səudi Ərəbistan sa +Саудаўская Арабія sa +Саудитска Арабия sa +সৌদি আরব sa +Arabi Saudiet sa +Saudijska Arabija sa +Aràbia Saurí sa +Saúdská Arábie sa +Sawdi Arabia sa +Saudi Arabien sa +Saudi-Arabien sa +Σαουδική Αραβία sa +Saŭda Arabio sa +Arabia Saudí sa +Saudi Araabia sa +عربستان سعودی sa +Saudi-Arabia sa +Arabie Saoudite sa +Saudi-Arabië sa +An Araib Shádach sa +Arabia Saudita sa +ערב הסעודית sa +सऊदी अरब sa +Saudijska Arabija sa +Szaúd-Arábia sa +Sádi-Arabía sa +Arabia Saudita sa +サウジアラビア sa +អារ៉ាប៊ីសាអ៊ូឌីត sa +사우디 아라비아 sa +ອາລະບິກ sa +Saudo Arabija sa +Saūda Arābija sa +Саудиска Арабија sa +Саудын араб sa +Għarabja Sawdita sa +Saudi-Arabia sa +Saudi Arabien sa +Saudi-Arabië sa +Saudi-Arabia sa +ਸਾਊਦੀ ਅਰਬ sa +Arabia Saudyjska sa +Arábia Saudita sa +Arábia Saudita sa +Arabia Saudită sa +Саудовская Аравия sa +Arabiya Sawudite sa +Saudi Arábia sa +Saudská arábia sa +Saudova Arabija sa +Саудијска Арабија sa +Saudijska Arabija sa +I-Saudi Arabia sa +Saudiarabien sa +சவுதி அரேபியா sa +Арабистони Саудӣ sa +ซาอุดิอาระเบีย sa +Suudi Arabistan sa +Söğüd Ğäräbstan sa +Саудівська Аравія sa +Саудия Арабистони sa +Ẩrập Saudi sa +Arabeye Sawoudite sa +沙特阿拉伯 sa +沙烏地阿拉伯 sa +Solomon Islands sb +Solomon Eilande sb +جزر سليمان sb +Solomon Adaları sb +Саламонавы астравы sb +Соломонови острови sb +সলোমন দ্বীপপুঞ্জ sb +Inizi Salaun sb +Solomonska ostrva sb +Illes Solomon sb +Šalamounovy ostrovy sb +Ynysoedd Solomon sb +Salomon-øerne sb +Salomon-Inseln sb +Νήσοι Σολομώντος sb +Salomonoj sb +Islas Salomón sb +Saalomoni saared sb +Solomon Irlak sb +جزایر سلیمان sb +Solomon-saaret sb +Îles Salomon sb +Solomon Eilannen sb +Oileáin Sholamón sb +Illas Salomón sb +איי שלמה sb +सोलोमन आइलैंड sb +Solomonova otočja sb +Salamon-szigetek sb +Salómonseyjar sb +Isole Salomone sb +ソロモン諸島 sb +កោះសូឡូម៉ូន sb +솔로몬 제도 sb +ສະໂລວະເນີຍ sb +Saliamono salos sb +Solomonu salas sb +Соломонски Острови sb +Соломоны арлууд sb +Gżejjer Solomon sb +Salomonøyene sb +Salomonen sb +Solomon Eilanden sb +Salomonøyane sb +ਸੋਲੋਮੋਨ ਆਈਸਲੈਂਡ sb +Wyspy Salomona sb +Ilhas Salomão sb +Ilhas Salomão sb +Insulele Solomon sb +Соломоновы острова sb +Ibirwa bya Salomo sb +Salomonsullot sb +Šalamúnove ostrovy sb +Solomonovi otoki sb +Соломонова острва sb +Solomonova ostrva sb +Salomonöarna sb +சாலமன் தீவுகள் sb +Ҷазираи Сулаймон sb +หมู่เกาะโซโลมอน sb +Solomon Adaları sb +Solomon Utrawları sb +Соломонові острови sb +Соломон Ороллари sb +Quần đảo Solomon sb +Iyes Salomon sb +所罗门群岛 sb +索羅門群島 sb +Seychelles sc +سيشل sc +Сэйшэлы sc +Сейшелски острови sc +সীচিলিস sc +Sechell sc +Sejšeli sc +Ynysoedd y Seisi?l sc +Seychellerne sc +Seychellen sc +Σεϋχέλλες sc +Sejŝeloj sc +Seišellid sc +سیشل sc +Seychellit sc +Seychellen sc +Na Séiséil sc +Seicheles sc +איי סיישל sc +शेसेल्स sc +Sejšeli sc +Seychelles-eyjar sc +セイシェル sc +សីស្ហែល sc +세이셸 sc +ເຊລ sc +Seišeļu salas sc +Сејшели sc +Сейчеллис sc +Seychellene sc +Seychellen sc +Seychellen sc +Seychellane sc +ਸੀਲਚੀਲੀਸ sc +Seszele sc +Ilhas Seychelles sc +Сейшельские острова sc +Seyishele sc +Seyšellat sc +Sejšeli sc +Сејшели sc +Sejšeli sc +Seychellerna sc +சேசெல்லஸ் sc +Сейшелӣ sc +ซีเชลล์ sc +Seyşeller sc +Seyşellär sc +Сейшельські острови sc +Сейшел Ороллари sc +Seycheles sc +塞舌尔 sc +塞席爾 sc +Sudan sd +السودان sd +Судан sd +Судан sd +সুদান sd +Sondan sd +Sudán sd +Swdan sd +Σουδάν sd +Sudano sd +Sudán sd +Sudaan sd +سودان sd +Sudania sd +Soudan sd +An tSúdáin sd +Sudán sd +סודן sd +सूडान sd +Szudán sd +Súdan sd +スーダン sd +ស៊ូដង់ sd +수단 sd +ຊູດານ sd +Sudanas sd +Sudāna sd +Судан sd +Судан sd +ਸੂਡਾਨ sd +Sudão sd +Sudão sd +Судан sd +Sudani sd +Sudán sd +Судан sd +I-Sudan sd +சூடான் sd +Судон sd +ซูดาน sd +Судан sd +Судан sd +Sudani sd +Soudan sd +苏丹 sd +蘇丹 sd +Sweden se +Swede se +السويد se +İsveç se +Швэцыя se +Швеция se +সুইডেন se +Švedska se +Suècia se +Švédsko se +Sverige se +Schweden se +Σουηδία se +Svedio se +Suecia se +Rootsi se +Suedia se +سوئد se +Ruotsi se +Svøriki se +Suède se +Zweden se +An tSualainn se +Suécia se +שבדיה se +स्वीडन se +Švedska se +Svédország se +Swedia se +Svíþjóð se +Svezia se +スウェーデン se +ស៊ុយអែដ se +스웨덴 se +ສະວີເດນ se +Švedija se +Zviedrija se +Шведска se +Швед se +Svezja se +Sverige se +Zweden se +Sverige se +Suècia se +ਸਵੀਡਨ se +Szwecja se +Suécia se +Suécia se +Suedia se +Швеция se +Suwede se +Ruoŧŧa se +Švédsko se +Švedska se +Шведска se +Švedska se +I-Sweden se +Sverige se +சுவீடன் se +Шведӣ se +สวีเดน se +İsveç se +İswäc, Şwedsia se +Швеція se +Швеция se +Swidene se +Thuỵ Điển se +Suwede se +瑞典 se +瑞典 se +Singapore sg +سنغافورة sg +Sinqapur sg +Сынгапур sg +Сингапур sg +সিঙ্গাপুর sg +Singapour sg +Singapur sg +Singapur sg +Singapur sg +Singap?r sg +Singapur sg +Σινγκαπούρη sg +Singapuro sg +Singapur sg +Singapur sg +سنگاپور sg +Singapour sg +Singeapór sg +Singapur sg +סינגפור sg +सिंगापोर sg +Singapur sg +Szingapúr sg +Singapúr sg +シンガポール sg +សិង្ហបុរី sg +싱가포르 sg +ໂຊນາ sg +Singapūras sg +Singapūra sg +Сингапур sg +Сингафур sg +Singapura sg +Singapor sg +Singapur sg +ਸਿੰਘਾਪੁਰ sg +Singapur sg +Singapura sg +Singapura sg +Сингапур sg +Singapur sg +Singapur sg +Сингапур sg +Singapur sg +சிங்கப்பூர் sg +Сингопур sg +สิงคโปร์ sg +Singapur sg +Singapur sg +Сінгапур sg +Сингапур sg +Singapour sg +新加坡 sg +新加坡 sg +Saint Helena sh +St Helena sh +سانت هيلانة sh +Востраў Сьвятой Алены sh +Св. Елена sh +সেন্ট হেলেনা sh +Sant Lena sh +Sveta Helena sh +Santa Helena sh +Svatá Helena sh +Ynys Santes Helena sh +St. Helena sh +St. Helena sh +Αγία Ελένη sh +Sent-Heleno sh +Santa Helena sh +سنت هلن sh +Sainte-Hélène sh +Sint Helena sh +San Héilin sh +Santa Helena sh +סט. הלנה sh +सेंट हेलेना sh +Sveta Helena sh +Szent Heléna sh +Sankti Helena sh +Sant'Elena sh +英領セントヘレナ島 sh +សង់ហេឡេណា sh +세인트헬레나 sh +ຫົວເລື່ອງ sh +Šv. Elenos sala sh +Sv. Helēnas sala sh +Света Елена sh +Сайнт Хелена sh +St. Helena sh +Sankt Helena sh +St. Helena sh +ਸੇਂਟ ਹੀਲੀਨਆ sh +Święta Helena sh +Santa Helena sh +Santa Helena sh +Sfînta Elena sh +остров Святой Елены sh +Mutagatifu Helena sh +St. Helena sh +Svätá Helena sh +Sveta Helena sh +Света Јелена sh +Sveta Jelena sh +செயின்ட் ஹேலேனா sh +Синт Ҳилин sh +เซนต์เฮเลน่า sh +Острів Святої Єлени sh +Авлиё Елена Ороли sh +Sint Elene sh +圣赫勒拿 sh +聖赫勒拿島 sh +Slovenia si +Slovenië si +سلوفينيا si +Sloveniya si +Славенія si +Словения si +স্লোভেনিয়া si +Sloveni si +Slovenija si +Eslovènia si +Slovinsko si +Slofenia si +Slovenien si +Slowenien si +Σλοβενία si +Slovenio si +Eslovenia si +Sloveenia si +Eslovenia si +اسلوانی si +Slovénie si +Slowenië si +An tSlóivéin si +Eslovénia si +סלובניה si +स्लोवेनिया si +Slovenija si +Szlovénia si +Slóvenía si +スロベニア si +ស្លូវ៉ានី si +슬로베니아 si +ສະໂລວະເນີຍ si +Slovėnija si +Slovēnija si +Словенија si +Слован si +Slovenja si +Slowenien si +Slowenië si +Eslovenia si +ਸਲੋਵੀਨੀਆ si +Słowenia si +Eslovénia si +Eslovênia si +Словения si +Siloveniya si +Slovinsko si +Slovenija si +Словенија si +Slovenija si +I-Slovenia si +Slovenien si +சுலோவினியா si +Услувонӣ si +สโลเวเนีย si +Slovenya si +Словенія si +Словения si +Esloveneye si +斯洛文尼亚 si +斯洛維尼亞 si +Slovakia sk +Slovakië sk +سلوفاكيا sk +Slovakiya sk +Славакія sk +Словакия sk +স্লোভাকিয়া sk +Slovaki sk +Slovačka sk +Eslovàquia sk +Slovensko sk +Slofacia sk +Slovakiet sk +Slowakien sk +Σλοβακία sk +Slovakujo sk +Eslovaquia sk +Slovakkia sk +Eslovakia sk +اسلواکی sk +Slovaquie sk +Slowakije sk +An tSlóvaic sk +Eslováquia sk +סלובקיה sk +स्लोवाकिया sk +Slovačka sk +Szlovákia sk +Slóvakía sk +Slovacchia sk +スロバキア sk +ស្លូវ៉ាគី sk +슬로바키아 sk +ສະໂລວັກ sk +Slovakija sk +Slovākija sk +Словачка sk +Словак sk +Slovakja sk +Slowakei sk +Slowakije sk +ਸਲੋਵਾਕਿਆ sk +Słowacja sk +Eslováquia sk +Eslováquia sk +Slovacia sk +Словакия sk +Silovakiya sk +Slovákia sk +Slovensko sk +Slovaška sk +Словачка sk +Slovačka sk +I-Slovakia sk +Slovakien sk +சுலோவாக்கிய sk +Услувок sk +สโลวาเกีย sk +Slovakya sk +Словакія sk +Словакия sk +Eslovakeye sk +斯洛伐克 sk +斯洛伐克 sk +San Marino sm +سان مارينو sm +Сан-Марына sm +Сан Марино sm +সান মারিনো sm +Σαν Μαρίνο sm +San-Marino sm +سنمارینو sm +Saint-Marin sm +San Mairíne sm +סן מרינו sm +सेन मेरिनो sm +San Marínó sm +サンマリノ sm +សាន់ម៉ារីណូ sm +산마리노 sm +ໂຊນາ sm +San Marinas sm +Sanmarīno sm +Сан Марино sm +Сан Марино sm +ਸਨ ਮਰੀਨੋ sm +São Marino sm +Сан-Марино sm +Mutagatifu Marini sm +Сан Марино sm +சான் மரினோ sm +Сан Морину sm +ซานมาริโน sm +Сан-Маріно sm +Сан-Марино sm +Sint Marin sm +圣马力诺 sm +聖馬力諾 sm +Senegal sn +السنغال sn +Seneqal sn +Сэнэгал sn +Сенегал sn +সেনেগল sn +Σενεγάλη sn +Senegalo sn +سنگال sn +Senegali sn +Sénégal sn +An tSeineagáil sn +סנגל sn +सेनेगल sn +Szenegál sn +セネガル sn +សេនេហ្គាល់ sn +세네갈 sn +ທົ່ວໄປ sn +Senegalas sn +Senegāla sn +Сенегал sn +Сенегал sn +Senegall sn +ਸੈਨੇਗਾਲ sn +Сенегал sn +Senegali sn +Сенегал sn +சீனேகல் sn +Синегол sn +เซนีกัล sn +Сенегал sn +Сенегал sn +Senegål sn +塞内加尔 sn +塞內加爾 sn +Somalia so +Somalië so +صومال so +Somali so +Самалі so +Сомалия so +সোমালিয়া so +Somali so +Somalija so +Somàlia so +Somálsko so +Σομαλία so +Somalio so +Somaalia so +سومالی so +Somalie so +Somalie so +An tSomáil so +Somália so +סומליה so +सोमालिया so +Somalija so +Szomália so +Sómalía so +ソマリア so +សូម៉ាលី so +소말리아 so +ໂລມາເນີຍ so +Somalis so +Somālija so +Сомалија so +Сомали so +Somalija so +Somalien so +Somalie so +ਸੋਮਾਲੀਆ so +Somália so +Somália so +Сомали so +Somaliya so +Somália so +Somálsko so +Somalija so +Сомалија so +Somalija so +I-Somalia so +சோமாலியா so +Сумалӣ so +โซมาเลีย so +Somali so +Сомалі so +Сомали so +Somaleye so +索马里 so +索馬利亞 so +Suriname sr +سورينام sr +Surinam sr +Сурынам sr +Суринам sr +সুরিনাম sr +Surinam sr +Surinam sr +Surinam sr +Swrinam sr +Surinam sr +Σουρινάμ sr +Surinamo sr +Surinam sr +Surinam sr +سورینام sr +Surinam sr +Suranam sr +סורינאם sr +सूरीनाम sr +Surinam sr +Súrínam sr +スリナム sr +ស៊ូរីណាមី sr +수리남 sr +ເຊີເບີຍ sr +Surinamas sr +Surinama sr +Суринам sr +Суринам sr +Surinam sr +Surinam sr +Surinam sr +Surinam sr +ਸੂਰੀਨਾਮੀ sr +Surinam sr +Surinam sr +Суринам sr +Surinamu sr +Surinam sr +Surinam sr +Surinam sr +Суринам sr +Surinam sr +Surinam sr +சுரிநேம் sr +Суринам sr +ซูรีนามิ sr +Surinam sr +Surinam sr +Сурінам sr +Суринам sr +苏里南 sr +蘇利南 sr +Sao Tome and Principe st +Sao Tome en Principe st +ساو تومي و البرنسيب st +Sao Tome və Principe st +Сан-Тамэ і Прынсіпі st +Сао Томе и Принсипи st +সাও টোম এবং প্রিন্সিপ st +Sao Tome ha Principe st +Sao Tome i Principe st +Sao Tome i Principe st +Sao Tome a Principe st +Ynysoedd Sao Tome a Principe st +Sao Tomé og Principe st +Sao Tome und Principe st +Σάο Τομέ και Πρίνσιπε st +Sao-Tomeo kaj Principeo st +Sao Tome y Príncipe st +Sao Tome ja Principe st +Sao Tome eta Principe st +سائوتومه و پرینسیپه st +São Tomé ja Príncipe st +Sao Tomé et Principe st +Sao Tome en Principe st +São Tomé agus Príncipe st +Santo Tomé e Príncipe st +साओ टोम तथा प्रिंसिपी st +Sv. Toma i Princip st +Sao Tome és Principe st +Saó Tóme og Prinsípe st +São Tomé e Príncipe st +サントメプリンシペ st +상투메 프린시페 st +ບໍລິການ st +Santome un Prinsipi st +Сао Томе и Принсипе st +Сао Томэ ба Принцип st +Sao Tome u Principe st +São Tomé og Príncipe st +São Tomé un Príncipe st +Sao Tome en Principe st +São Tomé og Príncipe st +ਸਾਓ ਟੋਮੀ ਤੇ ਪਰੀਸਿਪੀ st +Sao Tome i Principe st +São Tomé and Príncipe st +São Tome e Príncipe st +Sao Tome şi Principe st +Сан-Томе и Принсипи st +Sawo Tome na Purencipe st +São Tomé ja Príncipe st +Sao Tome a Principe st +Sao Tome in Principe st +Св. Тома и Принцип st +Sv. Toma i Princip st +São Tomé och Príncipe st +சயோ டோம் மற்றும் பிரின்ஸிபி st +Синт Том ва Принсип st +ซาวโทม และ พรินซิป st +Sao Tome ve Principe st +Sao Tome wä Principe st +Сан-Томе і Прінсіпі st +Сан-Томе ва Принсипи st +São Tomé et Prince st +圣多美和普林西比 st +聖多美及普林西比 st +El Salvador sv +السلفادور sv +Сальвадор sv +Салвадор sv +এল সালভাডোর sv +Ar Salvador sv +Salvador sv +El Salfador sv +Ελ Σαλβαντόρ sv +Salvadoro sv +Salvador sv +السالوادور sv +Salvador sv +An tSalvadóir sv +O Salvador sv +אל סלבדור sv +अल सल्वाडोर sv +Salvador sv +エルサルバドル sv +អែលសាល់វ៉ាឌ័រ sv +엘살바도르 sv +ເອລຊັນວາດດໍ sv +Salvadoras sv +Salvadora sv +Ел Салвадор sv +Эл Салвадор sv +ਈਲ ਸਾਲਵੇਡੋਰ sv +Salwador sv +Salvador sv +Сальвадор sv +Eli Salivadoro sv +Salvádor sv +Salvador sv +Ел Салвадор sv +I-El Salvador sv +எல் சால்வடோ ர் sv +Ал Салвадур sv +เอลซัลวาดอร์ sv +Ель-Сальвадор sv +Салвадор sv +萨尔瓦多 sv +薩爾瓦多 sv +Syria sy +Sirië sy +سوريا sy +Suriyə sy +Сырыя sy +Сирия sy +সিরিয়া sy +Siri sy +Sirija sy +Síria sy +Sýrie sy +Syrien sy +Syrien sy +Συρία sy +Sirio sy +Siria sy +Süüria sy +Siria sy +سوریه sy +Syyria sy +Syrie sy +Syrië sy +An tSiria sy +Síria sy +סוריה sy +सीरिया sy +Sirija sy +Szíria sy +Sýrland sy +Siria sy +シリア sy +ស៊ីរី sy +시리아 sy +ເຊີເບີຍ sy +Sirija sy +Sīrija sy +Сирија sy +Сири sy +Siria sy +Syrien sy +Syrië sy +ਸੀਰੀਆ sy +Síria sy +Síria sy +Siria sy +Сирия sy +Siriya sy +Sýria sy +Sirija sy +Сирија sy +Sirija sy +I-Syria sy +Syrien sy +சிரியா sy +Сурия sy +ซีเรีย sy +Suriye sy +Süriä sy +Сирія sy +Сурия sy +Sireye sy +叙利亚 sy +敘利亞 sy +Swaziland sz +Swasiland sz +سوازيلاند sz +Svaziland sz +Свазылэнд sz +Свазиленд sz +সোয়াজিল্যাণ্ড sz +Svazilend sz +Neozelàndia sz +Gwlad y Swasi sz +Swasiland sz +Σουαζιλάνδη sz +Svazilando sz +Swazilandia sz +Svaasimaa sz +Swazilandia sz +سووازیلند sz +Swazimaa sz +An tSuasalainn sz +Suacilándia sz +סוואזילנד sz +स्वाजीलैंड sz +Svazilend sz +Szváziföld sz +Svasíland sz +スワジランド sz +ស្វាហ្ស៊ីឡង់ sz +스와질란드 sz +ລາດສະນາຈັກໄທຍ sz +Svazilenda sz +Свазиленд sz +Свациланд sz +Sważilandja sz +Swasiland sz +ਸਵਾਜ਼ੀਲੈਂਡ sz +Suazi sz +Suazilândia sz +Suazilândia sz +Suaziland sz +Свазиленд sz +Swazilande sz +Swazijsko sz +Svazi sz +Свазиленд sz +Svazilend sz +ஸ்வாசிலான்ட் sz +Свозиланд sz +สวาซิแลนด์ sz +Свазіленд sz +Свазиленд sz +Suwazilande sz +斯威士兰 sz +史瓦濟蘭 sz +Turks and Caicos Islands tc +Turks en Caicos Eilande tc +جزر الترك و الكايكوس tc +Türk və Caicos Adaları tc +Астравы Тэркс і Кайкас tc +Острови Търкс и Кайкос tc +টার্কস এবং কাইকোস দ্বীপপুঞ্জ tc +Inizi Turks ha Kaikos tc +Turks i Kaikos ostrva tc +Illes Turks i Caicos tc +Turks a Caicos ostrovy tc +Ynysoedd Twrc a Chaicos tc +Turks- og Caicosøerne tc +Turks- und Caicos-Inseln tc +Νήσοι Τερκς και Κάικος tc +Turkoj kaj Kajkoj tc +Islas Turcos y Caicos tc +Turks ja Caicos tc +Turks eta Caicos Irlak tc +جزایر تورکس و کایکوس tc +Turks- ja Caicos-saaret tc +Îles Turks et Caicos tc +Turks en Caicos Eilânen tc +Na hOileáin Turks agus Caicos tc +Illas Caicos e Turks tc +איי קאיקוס וטורקס tc +तुर्क तथा कैकोस आइलैंड tc +Turks i Caicos otočje tc +Turks- és Caicos-szigetek tc +Turks- og Caicos-eyjar tc +Isole Turks e Caicos tc +英領タークス諸島 カイコス諸島 tc +កោះទួក និង កៃកូស tc +터크스 케이커스 제도 tc +Tērksa un Kaikosa tc +Острови Турк и Каикос tc +Турк ба Кайкогийн арлууд tc +Gżejjer Turks u Caicos tc +Turks- og Caicosøyene tc +Turks- un Caicosinseln tc +Turks en Caicos Eilanden tc +Turks- og Caicosøyane tc +ਤੁਰਕਸ ਤੇ ਕਾਇਕੋਸ ਟਾਪੂ tc +Wyspy Turks i Caicos tc +Ilhas Turks e Caicos tc +Ilhas Caicos e Turca tc +Insulele Turks şi Caicos tc +Острова Теркс и Кайкос tc +Ibirwa bya Turike na Kayikosi tc +Turks- ja Kaikossullot tc +Turks a Caicos ostrovy tc +Otoka Turks in Caicos tc +Турка и Кајкошка острва tc +Turka i Kajkoška ostrva tc +Turks- och Caicosöarna tc +துருக்கிகள் மற்றும் காய்கோஸ் தீவுகள் tc +Ҷазираи Турк ва Койкус tc +เกาะดติร์กและเคคอส tc +Turks ve Caicos Adaları tc +Türks wä Caicos Utrawları tc +Острови Теркс і Кайкос tc +Туркс ва Каикос Ороллари tc +Quần đảo Turks và Caicos tc +Iyes Turks et Caicos tc +特克斯和凯科斯群岛 tc +土克斯和開卡斯群島 tc +Chad td +تشاد td +Çad td +Чад td +Чад td +চ্যাড td +Tchad td +Čad td +Txad td +Čad td +Tsiad td +Tchad td +Tschad td +Τσαντ td +Ĉado td +Tšaad td +Txad td +چاد td +Tchad td +Tsjaad td +Sead td +Chade td +צ'אד td +चाड td +čad td +Csád td +Tsjad td +Ciad td +チャド td +ឆាដ td +차드 td +ເກມໄພ່ td +Čada td +Чад td +Чад td +Ċad td +Tsjad td +Tschad td +Tsjaad td +Tsjad td +ਚਾਂਦ td +Czad td +Chade td +Chade td +Ciad td +Чад td +Cade td +Čad td +Čad td +Čad td +Чад td +Čad td +Tchad td +சாட் td +Чод td +ชาด td +Çad td +Çad td +Чад td +Чад td +Tchad td +乍得 td +查德 td +Togo tg +توغو tg +Тога tg +Того tg +টোগো tg +Τόγκο tg +توگو tg +Tógó tg +טוגו tg +टोगो tg +Tógó tg +トーゴ tg +តូហ្គោ tg +토고 tg +ຂອງເລ່ນສະນຸກ tg +Того tg +Того tg +ਤੋਗੋ tg +Того tg +Того tg +டோகோ tg +Того tg +โตโก tg +Того tg +Того tg +多哥 tg +多哥 tg +Thailand th +تايلاند th +Tayland th +Тайлянд th +Тайланд th +থাইল্যাণ্ড th +Tajland th +Tailàndia th +Thajsko th +Gwlad y Tai th +Ταϊλάνδη th +Tajlando th +Tailandia th +Tai th +Thailandia th +تایلند th +Thaimaa th +Tailand th +Thaïlande th +Thailân th +An Téalainn th +Tailándia th +תאילנד th +थाइलैंड th +Tajland th +Thaiföld th +Taíland th +Tailandia th +タイ th +ថៃ th +태국 th +ລາດສະນາຈັກໄທຍ th +Tailandas th +Taizeme th +Тајланд th +Тайланд th +Tajlandja th +Tailandia th +ਥਾਈਲੈਂਡ th +Tajlandia th +Tailândia th +Tailândia th +Tailanda th +Таиланд th +Tayilande th +Thajsko th +Tajska th +Тајланд th +Tajland th +I-Thailand th +தாய்லாந்து th +Тойлонд th +ราชอาณาจักรไทย th +Tayland th +Tayland th +Таїланд th +Таиланд th +Thái Lan th +Taylande th +泰国 th +泰國 th +Tajikistan tj +طاجيكستان tj +Tacikistan tj +Таджыкістан tj +Таджикистан tj +তাজিকিস্তান tj +Tadjikistan tj +Tadžikistan tj +Tadjikistan tj +Tádžikistán tj +Tajicistan tj +Tadschikistan tj +Τατζικιστάν tj +Taĝikujo tj +Tajikistán tj +Tadžikistan tj +تاجیکستان tj +Tadjikistan tj +An Táidsíceastáin tj +Taxiquistán tj +טג'קיסטן tj +ताजिकिस्तान tj +Tadžikistan tj +Tadzsikisztán tj +Tadsjikistan tj +Tagikistan tj +タジキスタン tj +តាហ្ស៊ីគីស្តង់ tj +타지키스탄 tj +ໃຕ້ຫວັນ tj +Tadžikistanas tj +Tadžikistāna tj +Таџикистан tj +Тажикстан tj +Taġikistan tj +Tadsjikistan tj +Tadschikistan tj +Tadjikistan tj +Tadsjikistan tj +ਤਜ਼ਾਕਸਤਾਨ tj +Tadżykistan tj +Tajiquistão tj +Tajiquistão tj +Таджикистан tj +Tajikisitani tj +Tažikistan tj +Tadžikistan tj +Tadžikistan tj +Таџикистан tj +Tadžikistan tj +Tadzjikistan tj +தஜிகிஸ்தான் tj +Тоҷикистон tj +ธาจีกิสถาน tj +Tacikistan tj +Tajıqstan tj +Таджикистан tj +Тожикистон tj +Tadjikistan tj +塔吉克斯坦 tj +塔吉克 tj +Tokelau tk +توكيلاو tk +Такелау tk +Токело tk +টোকেলো tk +Tokelo tk +Tocelaw tk +Τοκελάου tk +Tokelao tk +توکلائو tk +Na hOileáin Tócala tk +טוקלאו tk +तोकेलाऊ tk +Tókelá tk +ニュージーランド自治領トケラウ tk +តូកេឡូ tk +토켈로 tk +ເບລາລັສ tk +Токелау tk +Токелау tk +Tokelaw tk +ਤੋਕੀਲਾਉ tk +Токелау tk +Tokelawu tk +Токелау tk +டோகேலா tk +Токилау tk +โทเคเลา tk +Tokelauça tk +Токелау tk +Токелау tk +托克劳 tk +托克勞 tk +Turkmenistan tm +تركمانستان tm +Türkmənistan tm +Туркмэністан tm +Туркменистан tm +তুর্কমেনিস্তান tm +Turcmenistan tm +Turkmenistán tm +Twrcmenistan tm +Τουρκμενιστάν tm +Turkmenujo tm +Turkmenistán tm +Türkmenistan tm +ترکمنستان tm +Turkménistan tm +An Tuircméanastáin tm +Turkmenistán tm +טורקמניסטן tm +तुर्कमेनिस्तान tm +Türkmenisztán tm +Túrkmenistan tm +トルクメニスタン tm +ទួគមេនីស្តង់ tm +투르크메니스탄 tm +ຕຸລະກີ tm +Turkmenistāna tm +Туркменистан tm +Туркменстан tm +ਤੁਰਕੇਮਸਤਾਨ tm +Turquemenistão tm +Turcomenistão tm +Turcmenistan tm +Туркменистан tm +Turikimenisitani tm +Туркменистан tm +துர்க்மெனிஸ்தான் tm +Туркманистон tm +เตอร์กเมนิสถาน tm +Türkmenistan tm +Туркменістан tm +Туркманистон tm +Turcmenistan tm +土库曼斯坦 tm +土庫曼 tm +Tunisia tn +Tunisië tn +تونس tn +Tunis tn +Туніс tn +Тунис tn +টিউনিসিয়া tn +Tunizi tn +Tunis tn +Tunísia tn +Tunisko tn +Tiwnisia tn +Tunesien tn +Tunesien tn +Τυνησία tn +Tunizio tn +Túnez tn +Tuneesia tn +تونس tn +Tunesia tn +Tunisie tn +Tunisie tn +An Túinéis tn +Túnez tn +תוניסיה tn +ट्यूनीशिया tn +Tunis tn +Tunézia tn +Túnis tn +チュニジア tn +ទុយនេស៊ី tn +튀니지 tn +ລັດເຊີຍ tn +Tunisas tn +Tunisija tn +Тунис tn +Тунис tn +Tuneżija tn +Tunesien tn +Tunisie tn +ਟੁਨੀਸ਼ੀਆ tn +Tunezja tn +Tunísia tn +Tunísia tn +Тунис tn +Tuniziya tn +Tunisko tn +Tunizija tn +Тунис tn +Tunis tn +I-Tunisia tn +Tunisien tn +துனிசியா tn +Тунис tn +ตูนีเซีย tn +Tunus tn +Туніс tn +Тунис tn +Tunizeye tn +突尼斯 tn +突尼西亞 tn +Tonga to +تونغا to +Tonqa to +Тонга to +Тонга to +টোংগা to +Inizi Tonga to +Τόνγκα to +Tongo to +تونگو to +טונגה to +टोंगा to +トンガ to +តុងហ្គោ to +통가 to +ໂຊນາ to +Тонга to +Тонга to +ਟਾਂਗਾ to +Тонга to +Тонга to +டோங்கா to +Тонго to +ตองก้า to +Тонга to +Тонга to +汤加 to +東加 to +East Timor tp +Oos Timor tp +تيمور الشرقية tp +Şərqi Timor tp +Усходні Тымор tp +Източен Тимор tp +পূর্ব টিমর tp +Timor reter tp +Istočni Timor tp +Timor Est tp +Východní Timor tp +Dwyrain Timor tp +Østtimor tp +Ost-Timor tp +Ανατολικό Τιμόρ tp +Orienta Timoro tp +Timor oriental tp +Ida-Timor tp +Ekialdeko Timor tp +تیمور شرقی tp +Itä-Timor tp +Timor oriental tp +Oost Timor tp +Tíomór Thoir tp +Timor do Leste tp +מזרח טימור tp +पूर्वी तिमोर tp +Istočni Timor tp +Kelet-Timor tp +Austur-Tímor tp +Timor Est tp +東ティモール tp +ទីម័រខាងកើត tp +동티모르 tp +ວັນແລະເວລາ tp +Rytų Timoras tp +Austrumtimora tp +Источен Тимор tp +Зүүн тимор tp +Timor Timur tp +Timor tal-Lvant tp +Øst-Timor tp +Oosttimor tp +Oost Timor tp +Aust-Timor tp +ਪੂਰਬੀ ਤਾਮੋਰ tp +Timor Wschodni tp +Timor Leste tp +Timor Leste tp +Timorul de Est tp +Восточный Тимор tp +Timoro y'Uburasirazuba tp +Nuorta-Timor tp +Východný Timor tp +Vzhodni Timor tp +Источни Тимор tp +Istočni Timor tp +Östtimor tp +கிழக்கு திமார் tp +Тимури Шарқ tp +ติมอร์ตะวันออก tp +Doğu Timur tp +Çığış Timor tp +Східний Тімор tp +Шарқий Тимур tp +Đông Timo tp +Timor Ess tp +东帝汶 tp +東帝汶 tp +Turkey tr +Turkeye tr +تركيا tr +Türkiyə tr +Турцыя tr +Турция tr +তুর্কী tr +Turkia tr +Turska tr +Turquia tr +Turecko tr +Twrci tr +Tyrkiet tr +Türkei tr +Τουρκία tr +Turkujo tr +Turquía tr +Türgi tr +Turkia tr +ترکیه tr +Turkki tr +Turkaland tr +Turquie tr +Turkije tr +An Tuirc tr +Turquia tr +טורקיה tr +तुर्की tr +Turska tr +Törökország tr +Turki tr +Tyrkland tr +Turchia tr +トルコ tr +ទួរគី tr +터키 tr +ຕຸລະກີ tr +Turkija tr +Turcija tr +Турција tr +Турк tr +Turki tr +Turkija tr +Tyrkia tr +Törkei tr +Turkije tr +Tyrkia tr +Turquia tr +ਤੁਰਕੀ tr +Turcja tr +Turquia tr +Turquia tr +Turcia tr +Турция tr +Turukiya tr +Durka tr +Turecko tr +Turčija tr +Турска tr +Turska tr +I-Turkey tr +Turkiet tr +துருக்கி tr +Туркиё tr +ตุรกี tr +Türkiye tr +Törkiä tr +Туреччина tr +Туркия tr +Thổ Nhĩ Kì tr +Turkeye tr +土耳其 tr +土耳其 tr +Trinidad and Tobago tt +Trinidad en Tobago tt +ترينيداد و توباغو tt +Trinidad və Tabaqo tt +Трынідад і Табага tt +Тринидад и Тобаго tt +ত্রিনিদাদ এবং টোবাগো tt +Trinidad ha Tobago tt +Trinidad i Tobago tt +Trinidad i Tobago tt +Trinidad a Tobago tt +Ynysoedd Trinidad a Thobago tt +Trinidad og Tobago tt +Trinidad und Tobago tt +Τρίνινταντ και Τομπάγκο tt +Trinidado kaj Tobago tt +Trinidad y Tobago tt +Trinidad ja Tobago tt +Trinidad eta Tobago tt +ترینیداد و تُباگو tt +Trinidad ja Tobago tt +Trinidad og Tobago tt +Trinidad et Tobago tt +Trinidad en Tobago tt +Oileán na Tríonóide agus Tobága tt +Trinidade e Tobago tt +טרינידד וטובגו tt +ट्रिनिडाड और टोबैगो tt +Trinidad i Tobago tt +Trinidad és Tobago tt +Trinidad dan Tobago tt +Trínidad og Tóbagó tt +Trinidad e Tobago tt +トリニダードトバコ tt +ទ្រីនីដាដ និង តូបាហ្គោ tt +트리니다드 토바고 tt +ຕີນິແດດແລະໂທບາໂກ tt +Trinidadas ir Tobagas tt +Trinidada un Tobago tt +Тринидад и Тобаго tt +Тринида ба Тобаго tt +Trinidad dan Tobago tt +Trinidad u Tobago tt +Trinidad og Tobago tt +Trinidad un Tobago tt +Trinidad en Tobago tt +Trinidad og Tobago tt +Trinidad le Tobago tt +Trinidad e Tobago tt +ਤਰੀਨੀਡਾਡ ਤੇ ਤੋਬਾਗੋ tt +Trinidad i Tobago tt +Trindade e Tobago tt +Trinidad e Tobago tt +Trinidad şi Tobago tt +Тринидад и Тобаго tt +Tirinida na Tobago tt +Trinidad ja Tobago tt +Trinidad a Tobago tt +Trinidad in Tabago tt +Тринидад и Тобаго tt +Trinidad i Tobago tt +I-Trinidad kanye neTobago tt +Trinidad och Tobago tt +ட்ரினிடாட் & டொபாகோ tt +Туриндод ва Тубогу tt +ตรีนิแดดและโทบาโก tt +Trinidad veTabago tt +Trinidad wä Tobago tt +Республіка Трінідад та Тобаго tt +Тринидад ва Тобаго tt +Trinidad na Tobago tt +Trinidad và Tobago tt +Trinité et Tobago tt +Trinidad ne Tobago tt +特立尼达和多巴哥 tt +千里達及托貝哥 tt +Trinidad knaye ne-Tobago tt +Tuvalu tv +توفالو tv +Тувалу tv +Тувалу tv +টুভালু tv +Twfalw tv +Τουβαλού tv +Tuvalo tv +توالو tv +טובאלו tv +तुवालू tv +Túvalú tv +ツバル tv +ទុយវ៉ាលុយ tv +투발루 tv +ຊູລູ tv +Тувалу tv +Тувалу tv +ਤੁਵਾਲੂ tv +Тувалу tv +Тувалу tv +துவலு tv +Тувалу tv +ตูวาลู tv +Tuvaluça tv +Тувалу tv +Тувалу tv +Touvalou tv +图瓦卢 tv +吐瓦魯 tv +Taiwan tw +تايوان tw +Tayvan tw +Тайвань tw +Тайван tw +তাইওয়ান tw +Tajvan tw +Ταϊβάν tw +Tajvano tw +Taiwán tw +تایوان tw +Taivan tw +Taïwan tw +An Téaváin tw +Taiwán tw +טיוואן tw +ताईवान tw +Tajvan tw +Tajvan tw +Taívan tw +台湾 tw +តៃវ៉ាន់ tw +대만 tw +ໃຕ້ຫວັນ tw +Taivanis tw +Taivāna tw +Тајван tw +Тайван tw +Tajwan tw +ਤਾਈਵਾਨ tw +Tajwan tw +Formosa tw +Taivan tw +Тайвань tw +Tayiwani tw +Tajvan tw +Тајван tw +Tajvan tw +I-Taiwan tw +தாய்வான் tw +Тойвон tw +ไต้หวัน tw +Tayvan tw +Taywan tw +Тайвань tw +Тайван tw +Đài Loan tw +中国台湾 tw +台灣 tw +Tanzania, United Republic of tz +Tanzanië, Vereenigde Republiek van tz +جمهورية تنزانيا المتحدة tz +Tanzaniya tz +Злучаная Рэспубліка Танзанія tz +Танзания tz +তানজানিয়া tz +Tanzanija, Ujedinjena Republika tz +Tanzània, República Unida de tz +Tanzánie tz +Tansania, Gweriniaeth Unedig tz +Tanzania tz +Tansania, vereinigte Republik tz +Τανζανία, Ενωμένη δημοκρατία της tz +Tanzanio, Unuiĝinta Respubliko de tz +Tanzania, Republica de tz +Tansaania tz +Tanaziar Errepublika Batua tz +جمهوری متحده تانزانیا tz +Tansanian yhdistäytynyt tasavalta tz +Tanzanie, République unie de tz +Tanzanië, Ferienigd republyk fan tz +An Tansáin tz +República Unida de Tanzánia tz +טנזניה, הרפובליקה המאוחדת של tz +तंजानिया यूनाइटेड रिपब्लिक tz +Ujedinjena Republika Tanzanija tz +Tanzánia tz +Tansanía tz +Tanzania tz +タンザニア,共和国連邦 tz +តង់ហ្សានី tz +탄자니아 합중국 tz +ໂດມິນິກັນ tz +Tanzanijos Respublika tz +Tanzānija tz +Танзанија, Обединета Република tz +Танканы нэгдсэн улс tz +Republik Bersatu Tanzania tz +Tanżania tz +Tanzania tz +Tansania tz +Tanzania, Verenigde republiek van tz +Tanzania tz +ਤਾਨਜ਼ੂਈਆ, ਸੰਯੁਕਤ ਗਣਰਾਜ tz +Zjednoczna Republika Tanzanii tz +República da União da Tanzânia tz +República da Tanzânia tz +Tanzania, Republica Unită tz +Танзания tz +Tanzaniya, Repubulika Yunze Ubumwe ya tz +Tanzania tz +Tanzánia, Spojená republika tz +Tanzanija, Združena republika tz +Танзанија, Уједињена Република tz +Tanzanija, Ujedinjena Republika tz +Förenade republiken Tanzania tz +டான்ஜாநியா, ஐக்கிய குடியரசு tz +Ҷумҳурии Муттаҳидаи Тонзониё tz +สาธารณรัฐแทนซาเนีย tz +Tanzanya tz +Tanzania, Berläşkän Cömhüriätläre tz +Танзанія, об'єднана республіка tz +Танзания Бирлашган Республикаси tz +Tanzania, Cộng hoà thống nhât tz +Tanzaneye tz +坦桑尼亚联合共和国 tz +坦尚尼亞 tz +Ukraine ua +Ukraïne ua +أوكرانيا ua +Ukrayna ua +Украіна ua +Украйна ua +ইউক্রেন ua +Ukraina ua +Ukrajina ua +Ucraïna ua +Ukrajina ua +Wcr?in ua +Ουκρανία ua +Ukrainio ua +Ucrania ua +Ukraina ua +Ukrania ua +اکراین ua +Ukraina ua +Ukraina ua +Oekraïne ua +An Úcráin ua +Ucrania ua +אוקראינה ua +उक्रेन ua +Ukrajina ua +Ukrajna ua +Ukraina ua +Úkraína ua +Ucraina ua +ウクライナ ua +អ៊ុយក្រែន ua +우크라이나 ua +ຍູເຄຣນ ua +Ukraina ua +Ukraina ua +Украина ua +Украйн ua +Ukranja ua +Ukraina ua +Oekraïne ua +Ukraina ua +Ucraina ua +ਯੂਕਰੇਨ ua +Ukraina ua +Ucrânia ua +Ucrânia ua +Ucraina ua +Украина ua +Ukerene ua +Ukraina ua +Ukrajina ua +Ukrajina ua +Украјина ua +Ukrajina ua +I-Ukraine ua +Ukraina ua +உக்ரெய்ன் ua +Украина ua +ยูเครน ua +Ukrayna ua +Ukrain ua +Україна ua +Украина ua +Ukraina ua +Oucrinne ua +乌克兰 ua +烏克蘭 ua +Uganda ug +أوغندا ug +Uqanda ug +Уганда ug +Уганда ug +ইউগাণ্ডা ug +Ouganda ug +Wganda ug +Ουγκάντα ug +Ugando ug +اوگاندا ug +Ouganda ug +אוגנדה ug +उगांडा ug +Úganda ug +ウガンダ ug +អ៊ូហ្គង់ដា ug +우간다 ug +ແພນດ້າ ug +Уганда ug +Уганда ug +ਯੂਗਾਂਡਾ ug +Уганда ug +Уганда ug +உகான்டா ug +Угондо ug +ยูกันดา ug +Уганда ug +Уганда ug +Ouganda ug +乌干达 ug +烏干達 ug +United States of America us +Vereenigde State van Amerika us +الولايات المتحدة الأمريكية us +Amerika Birləşmiş Ştatları us +Злучаныя Штаты Амэрыкі us +САЩ us +মার্কিন যুক্তরাষ্ট্র us +Stadoù-Unanet Amerika us +Sjedinjene Američke Države us +Estats Units d'Amèrica us +Spojené státy americké us +Unol Daleithau America us +USA us +USA us +Ηνωμένες Πολιτείες της Αμερικής us +Usono us +Estados Unidos de América us +Ameerika Ühendriigid us +Ameriketako Estatu Batuak us +ایالات متحدهی آمریکا us +Yhdysvallat us +Sambandsríki Amerika (USA) us +États Unis d'Amérique us +Ferienigde Staten fan Amerika us +Stáit Aontaithe Mheiriceá us +Estados Unidos de América us +ארצות הברית us +संयुक्त राज्य अमेरिका us +Sjedinjene Američke Države us +Amerikai Egyesült Államok us +Amerika Serikat us +Bandaríkin us +Stati Uniti d'America us +アメリカ合衆国 us +សហរដ្ឋអាមេរិក us +미 합중국 us +ສະຫະລັດອາເມລິກາ us +Jungtinės Amerikos Valstijos us +Amerikas Savienotās Valstis us +Соединети Американски Држави us +АНУ us +Amerika Syarikat us +Stati Uniti us +USA us +Vereenigte Staten vun Amerika us +Verenigde Staten van Amerika us +USA us +Estats Units d'Amèrica us +ਸੰਯੁਕਤ ਰਾਜ ਅਮਰੀਕਾ us +Stany Zjednoczone Ameryki us +Estados Unidos da América us +Estados Unidos da América us +Statele Unite ale Americii us +Соединённые Штаты Америки us +Leta Zunze Ubumwe z'Amerika us +Amerihká ovttastuvvan stáhtat us +USA us +Združene države Amerike us +Сједињене америчке државе us +Sjedinjene američke države us +I-United States of America us +Amerikas förenta stater us +ஐக்கிய அமெரிக்கா us +Иёлоти Муттаҳидаи Амрико us +สหรัฐอเมริกา us +Amerika Birleşik Devletleri us +Amerika Quşma Ştatları us +США us +Америка Қўшма Штатлари us +mashango o tangananaho a America us +Hợp chủng quốc Hoa Kỳ us +Estats Unis us +United States ye Melika us +美国 us +美利堅合眾國 us +Uruguay uy +الأوروغواي uy +Uruqvay uy +Уругвай uy +Уругвай uy +উরুগুয়ে uy +Urugvaj uy +Uruguai uy +Wrwgw?i uy +Ουρουγουάη uy +Urugvajo uy +Uruguai uy +اروگویه uy +Uragua uy +Uruguai uy +אורוגואי uy +उरूग्वे uy +Urugvaj uy +Úrúgvæ uy +ウルグアイ uy +អ៊ុយរុយហ្គាយ uy +우루과이 uy +ອຸລຸກກວຍ uy +Urugvajus uy +Urugvaja uy +Уругвај uy +Уругвай uy +Urugwaj uy +Uruguai uy +ਉਰੂਗਵੇ uy +Urugwaj uy +Uruguai uy +Uruguai uy +Uruguai uy +Уругвай uy +Irigwe uy +Uruguaj uy +Urugvaj uy +Уругвај uy +Urugvaj uy +I-Uruguay uy +உருகுவே uy +Уругвай uy +อุรุกวัย uy +Уругвай uy +Уругвай uy +Ourougway uy +乌拉圭 uy +烏拉圭 uy +Uzbekistan uz +أوزبكستان uz +Özbəkistan uz +Узбэкістан uz +Узбекистан uz +উজবেকিস্তান uz +Ouzbekistan uz +Uzbekistán uz +Wsbecist?n uz +Usbekistan uz +Ουζμπεκιστάν uz +Uzbekujo uz +Uzbekistán uz +Usbekistan uz +ازبکستان uz +Ouzbékistan uz +Úisbéiceastáin uz +Uzbekistán uz +אוזבקיסטן uz +उज्बेकिस्तान uz +Üzbegisztán uz +Úsbekistan uz +ウズベキスタン uz +អ៊ូហ្សបេគីស្តង់ uz +우즈베키스탄 uz +ເດນ່ງນ uz +Uzbekistāna uz +Узбекистан uz +Узбекстан uz +Użbekistan uz +Usbekistan uz +Usbekistan uz +Usbekistan uz +ਉਜ਼ੇਬਕਸਤਾਨ uz +Uzbequistão uz +Uzbequistão uz +Узбекистан uz +Uzibekisitani uz +Usbekistan uz +Узбекистан uz +உஸ்பெகிஸ்தான் uz +Ӯзбекистон uz +อุซเบกิสถาน uz +Özbekistan uz +Özbäkstan uz +Узбекистан uz +Ўзбекистон uz +Ouzbekistan uz +乌兹别克斯坦 uz +烏茲別克 uz +Vatican City va +Vatikaan Stad va +مدينة الفاتيكان va +Vatican Şəhəri va +Ватыкан va +Ватикана va +ভ্যাটিকান সিটি va +Ker Vatikan va +Vatikan va +Ciutat del Vaticà va +Vatikán va +Dinas y Fatican va +Vatikanstaten va +Vatikanstadt va +Βατικανό va +Vatikano va +Vaticano va +Vatikan va +Batikano Hiria va +شهر واتیکان va +Vatikaani va +Vatican va +Vaticaanstad va +An Chathaoir Naofa va +Cidade do Vaticano va +הוותיקן va +वेटिकन सिटी va +Vatikan va +Vatikán va +Vatíkanið va +Città del Vaticano va +バチカン市国 va +ក្រុងវ៉ាទីកង់ va +바티칸 시티 va +ລັດເວີຍ va +Vatikāns va +Ватикан va +Ватикан сити va +Vatikan va +Vatikanstaten va +Vatikaan va +Vaticaanstad va +Vatikanstaten va +ਵਾਟੀਕੇਨ ਸਿਟੀ va +Watykan va +Cidade do Vaticano va +Cidade do Vaticano va +Vatican, Oraşul va +Ватикан va +Umujyi wa Vatikani va +Vatikanstáhta va +Vatikán va +Vatikan va +Ватикан va +Vatikan va +Vatikanstaten va +வாடிகன் நகரம் va +Шаҳри Ватикан va +นครรัฐวาติกัน va +Vatikan va +Vatikan va +Ватікан va +Ватикан Шаҳри va +Thành phố Vatican va +Vatican va +梵蒂冈 va +梵諦岡城 va +St. Vincent and the Grenadines vc +St. Vincent en die Grenadene vc +سانت فينسنت و الغرينادين vc +St. Vincent və Grenadines vc +Сэнт-Вінсэнт і Грэнадыны vc +Св. Винсет и Гренадините vc +সেন্ট ভিনসেন্ট ও গ্রেনাডিন vc +S. Visant hag ar Grenadinez vc +Sveti Vincent i Grenadini vc +St. Vincent i les Granadines vc +St. Vincent a Grenadiny vc +Ynysoedd St. Finsent a'r Grenadinau vc +St. Vincent og Grenadinerne vc +St. Vincent und Grenadinen vc +Άγιος Βικέντιος και Γρεναδίνες vc +Sent-Vincento kaj la Grenadinoj vc +San Vicente y las Granadinas vc +St. Vincent ja Grenadiinid vc +St. Vincent eta Grenadines vc +سن وینسن و گرادینس vc +St. Vincent ja Grenadiinit vc +Sankta Vinsent og Grenadinoyggjar vc +St Vincent et les Grenadines vc +St. Vincent en de Grenadines vc +St. Vincent agus Grenadines vc +Santo Vicente e as Granadinas vc +סנט וינסנט והגרנדינים vc +सेंट विंसेंट तथा ग्रेनेडाइन्स vc +St. Vincent és Grenadines vc +St. Vincent dan the Grenadines vc +Sankti Vinsent og Grenadíneyjar vc +Saint Vincent e Grenadines vc +セントヴィンセントグレナディン vc +សង់វាំងសង់ និង ហ្គ្រីណាឌីន vc +세인트 빈센트 그레나딘 vc +ເຊີນວິນແຊນ ແລະເກນາດີນ vc +Šv. Vincentas ir Grenadinai vc +Sentvinsenta un Grenadīnes vc +Св. Винсент и Гренадите vc +St. Винсент ба Гренадин vc +St. Vincent dan Grenadines vc +St. Vinċenz u l-Grenadini vc +St. Vincent og Grenadinene vc +St. Vincent un de Grenadinen vc +St. Vincent en de Grenadines vc +St. Vincent og Grenadinane vc +St. Vincent le Grenadines vc +St. Vincent e les Granadines vc +ਸੇਂਟ ਵੀਨਸੈਂਟ ਤੇ ਗਰੀਨਾਜੀਨਸ vc +St. Vincent i Grenadyny vc +São Vicente e Granadinas vc +São Vicente e Grenadines vc +Sf. Vincent şi Grenadines vc +Сент-Винсент и Гренадины vc +Mutagatifu Visenti na Gerenadine vc +St. Vincent ja the Grenadiinnat vc +St. Vincent a Grenadines vc +Sv. Vincent in Grenadini vc +Св. Винсент и Гренадини vc +Sv. Vinsent i Grenadini vc +I-St. Vincent and the Grenadines vc +St. Vincent och Grenadinerna vc +செயின்ட் வின்சென்ட் மற்றும் க்ரீனாடைன்ஸ் vc +Синт Винсент ва Гренадина vc +เกาะเซนต์วินเซนต์ vc +St. Vincent ve Grenadines vc +Sain Vinsent wä Grenadinnär vc +Сент-Вінсент і Гренадіни vc +Сент-Винсент ва Гренадина vc +St. Vincent na Grenadines vc +St. Vincent và Grenadines vc +St. Vincint et les Grenadines vc +St. Vincent ne Grenadines vc +圣文森特和格林纳丁斯 vc +聖文森及格納那丁 vc +I-St. Vincent kanye ne-Grenadines vc +Venezuela ve +فنزويلا ve +Venesuella ve +Вэнэсуэла ve +Венесуела ve +ভেনেজুয়েলা ve +Venecuela ve +Veneçuela ve +Feneswela ve +Βενεζουέλα ve +Venezuelo ve +Venetsueela ve +ونزویلا ve +Venesuela ve +Vénézuela ve +Veiniséala ve +ונצואלה ve +वेनेजुएला ve +Venecuela ve +Venesúela ve +ベネズェラ ve +វេណេហ្សុ៊យអេឡា ve +베네수엘라 ve +ເວເນຊຸເອລາ ve +Venesuela ve +Venecuēla ve +Венецуела ve +Винессуел ve +Veneżwela ve +ਵੈਂਨਜ਼ੂਏਲਾ ve +Wenezuela ve +Венесуэла ve +Venezuwela ve +Венецуела ve +Venecuela ve +I-Venezuela ve +வெனிசுலா ve +Винизуэлло ve +เวเนซุเอลา ve +Венесуела ve +Венесуэла ve +Venezwela ve +委内瑞拉 ve +委內瑞拉 ve +Virgin Islands, British vg +Virgin Eilande, Brits vg +الجزر العذراء, بريطانيا vg +Virgin Adaları, Britanya vg +Брытанскія Віргінскія астравы vg +Британски Вирджински острови vg +ভার্জিন আইল্যাণ্ডস, ব্রিটিশ vg +Djevičanska ostrva, Britanska vg +Illes Verges, Angleses vg +Ynysoedd yr Wyryf, Prydeinig vg +Britiske jomfruøer vg +Virgin-Inseln, britisch vg +Παρθένοι Νήσοι, Βρετανικές vg +Virgininsuloj, Britaj vg +Islas Vírgenes Británicas vg +Briti Neitsisaared vg +Britaniar Irla Birjinak vg +جزایر ویرجین انگلیسی vg +Brittien Neitsytsaaret vg +Îles Vierges britanniques vg +Virgin Eilannen, Britse vg +Oileáin Bhriotanacha na Maighdean vg +Illas Virxes, Británicas vg +איי הבתולה, בריטי vg +वर्जिन आइलैंड, ब्रिटिश vg +Djevičansko otočje, Britanski vg +Virgin-szigetek (brit) vg +Bresku Jómfrúareyjar vg +Isole Vergini Britanniche vg +英領バージン諸島 vg +កោះស្មោង អង់គ្លេស vg +영국령 버진 제도 vg +Britu Virdžinu salas vg +Девствени Острови, Британски vg +Виржин арлууд, британи vg +Kepulauan Virgin, British vg +Jomfruøyene (Storbritannia) vg +Britsche Jumferninseln vg +Virgin Eilanden, Britse vg +Jomfruøyane (Storbritannia) vg +ਵੀਰਗੀਨ ਟਾਪੂ, ਬਰਤਾਨੀਆ vg +Wyspy Dziewicze (Brytyjskie) vg +Ilhas Virgens, Inglaterra vg +Ilhas Virgens, Inglaterra vg +Insulele Virgine, Anglia vg +Виргинские Британские острова vg +Ibirwa by'Isugi, Nyongereza vg +Panenské Ostrovy, Britské vg +Deviški otoki, Britanski vg +Девичанска острва, Британска vg +Devičanska ostrva, Britanska vg +Brittiska Jungfruöarna vg +விர்ஜின் தீவுகள், பிரிட்டிஷ் vg +Ҷазираи Вирҷиния, Бритониё vg +หมู่เกาะเวอร์จิน, อังกฤษ vg +Virgin Adaları (İngiltere) vg +Virgin Utrawları, Britan vg +Віргінські острови (Британія) vg +Англия Виржин Ороллари vg +Quần đảo Trinh nữ, Vưong quốc Anh vg +Iyes Viedjes, britanikes vg +英属维京群岛 vg +英屬維爾京群島 vg +Virgin Islands, U.S. vi +Virgin Eilande, VSA vi +الجزر العذراء, الولايات المتحدة vi +Virgin Adaları, ABŞ vi +Амэрыканскія Віргінскія астравы vi +Американски Вирджински острови vi +ভার্জিন আইল্যাণ্ডস, মার্কিন যুক্তরাষ্ট্র vi +Djevičanska ostrva, Američka vi +Illes Verges, Americanes vi +Panenské ostrovy, U.S. vi +Ynysoedd yr Wyryf, Americanaidd vi +Jomfruøerne vi +Virgin-Inseln, amerikanisch vi +Παρθένοι Νήσοι, Η.Π.A. vi +Virgininsuloj, Usonaj vi +Islas Vírgenes Americanas vi +USA Neitsisaared vi +Estatu Batuar Irla Birjinak vi +جزایر ویرجین امریکا. vi +USA:n Neitsytsaaret vi +Îles Vierges américaines vi +Virgin Eilannen, U.S. vi +Oileáin na Maighdean S.A.M. vi +Illas Virxes, U.S. vi +איי הבתולה, ארצות־הברית vi +वर्जिन आइलैंड, यू.एस. vi +Djevičansko otočje, SAD vi +Virgin-szigetek (USA) vi +Bandarísku Jómfrúareyjar vi +Isole Vergini Americane vi +米領バージン諸島 vi +កោះស្មោង អាមេរិក vi +미국령 버진 제도 vi +Virdžinu salas, ASV. vi +Девствени Острови, САД vi +Виржин арлууд, АНУ vi +Kepulauan Virgin, U.S. vi +Jomfruøyene (USA) vi +Jumferninseln, U.S. vi +Virgin Eilanden, U.S. vi +Jomfruøyane (USA) vi +ਵੀਰਗੀਨ ਟਾਪੂ, ਅਮਰੀਕਾ vi +Wyspy Dziewicze (USA) vi +Ilhas Virgens, E.U.A. vi +Ilhas Virgens, EUA vi +Insulele Virgine, S.U.A. vi +Виргинские острова (США) vi +Ibirwa by'Isugi, U.S. vi +Panenské Ostrovy, Americké vi +Deviški otoki, ZDA vi +Девичанска острва, САД vi +Devičanska ostrva, SAD vi +Amerikanska Jungfruöarna vi +விர்ஜின் தீவுகள், U.S. vi +Ҷазираи Вирҷиния, Ш.М.А vi +หมู่เกาะเวอร์จิน, สหรัฐอเมริกา vi +Virgin Adaları (ABD) vi +Virgin Utrawları, AQŞ vi +Віргінські острови (США) vi +АҚШ Виржин Ороллари vi +Quần đảo Trinh nữ, Hoa Kỳ vi +Iyes Viedjes, etazunyinnes vi +美属维京群岛 vi +美屬維爾京群島 vi +Vietnam vn +Viëtnam vn +فييتنام vn +Vyetnam vn +Віетнам vn +Виетнам vn +ভিয়েতনাম vn +Vijetnam vn +Panenské ostrovy, U.K. vn +Fiet-nam vn +Βιετνάμ vn +Vjetnamio vn +ویتنام vn +Viëtnam vn +Vítneam vn +וייטנאם vn +विएतनाम vn +Vijetnam vn +Víetnam vn +ベトナム vn +វៀតណាម vn +베트남 vn +ຫວງດນາມ vn +Vietnamas vn +Vjetnama vn +Виетнам vn +Витнам vn +Vjetnam vn +Viëtnam vn +ਵੀਅਤਨਾਮ vn +Wietnam vn +Vietname vn +Vietnã vn +Вьетнам vn +Viyetinamu vn +Вијетнам vn +Vijetnam vn +I-Vietnam vn +வியட்நாம் vn +Ветнам vn +เวียตนาม vn +В'єтнам vn +Ветнам vn +Việt Nam vn +越南 vn +越南 vn +Vanuatu vu +فانواتو vu +Вануату vu +Вануату vu +ভানুয়াটু vu +Fanwatw vu +Βανουάτου vu +Vanuatuo vu +وانواتو vu +Vanuatú vu +ונואטו vu +वनौतू vu +Vanúatú vu +バヌアツ vu +វ៉ានុយអាទុយ vu +바누아투 vu +ຈີນ vu +Вануату vu +Вануату vu +ਵਾਨੁਆਟੂ vu +Vanatu vu +Вануату vu +Vanuwatu vu +Вануату vu +வனடு vu +Вануату vu +แวนัวตู vu +Вануату vu +Вануату vu +瓦努阿图 vu +萬那杜 vu +Wallis and Futuna wf +Wallis en Futuna wf +واليس و فوتونا wf +Vallis və Futuna wf +Ўоліс і Футуна wf +Острови Уолис и Футина wf +ওয়ালিস এবং ফুটুনা wf +Wallis ha Futuna wf +Valis i Futuna wf +Wallis i Futuna wf +Wallis a Futuna wf +Ynysoedd Walis a Ffwtwna wf +Wallis- og Futuna-øerne wf +Wallis und Futuna wf +Βαλίς και Φουτούνα wf +Valiso kaj Futuno wf +Wallis y Futuna wf +Wallis ja Futuna wf +Wallis eta Futuna wf +والیس و فوتونا wf +Wallis ja Futuna wf +Wallis et Futuna wf +Wallis en Futuna wf +Bhailís agus Futúna wf +Wallis e Futuna wf +ואליס ופוטונה wf +वालिस तथा फुतुना wf +Wallis i Futuna wf +Wallis és Futuna wf +Wallis- og Fútúnaeyjar wf +Wallis e Futuna wf +仏領ワリスフツナ諸島 wf +월리스 후투나 제도 wf +ປັກອິນພາບ wf +Volisa salas un Futuna wf +Валис и Футуна wf +Вилямс ба футуна wf +Wallis dan Futuna wf +Wallis u Futuna wf +Wallis og Futuna wf +Wallis un Futuna wf +Wallis en Futuna wf +Wallis og Futuna wf +ਵਾਲਿਸ਼ ਤੇ ਫੂਟੂਨਾ wf +Wallis i Futuna wf +Wallis e Futuna wf +Wallis e Futuna wf +Wallis şi Futuna wf +Острова Уоллис и Футуна wf +Walisi na Futuna wf +Wallis ja Futuna wf +Wallis a Futuna wf +Wallis in Futuna wf +Валис и Футуна wf +Valis i Futuna wf +Wallis och Futuna wf +வாலிஸ் மற்றும் ப்யுடனா wf +Уэлс ва Футуна wf +วอลลิสและฟูทูนา wf +Wallis ve Futuna wf +Wallis wä Futuna wf +Уоллис і Футуна wf +Уоллис ва Футуна Ороллари wf +Wallis và Futuna wf +Wallis et Futuna wf +瓦利斯和富图纳群岛 wf +瓦利斯群島和富圖納群島 wf +Samoa ws +ساموا ws +Самоа ws +Самоа ws +সামোয়া ws +Inizi Samoe ws +Σαμόα ws +Samoo ws +ساموآ ws +Samó ws +סמואה ws +सामोआ ws +Szamoa ws +Samóa ws +サモア ws +សាមូអា ws +사모아 제도 ws +ໂຊນາ ws +Самоа ws +Самолоа ws +ਸਾਮੋਆ ws +Самоа ws +Samowa ws +Самоа ws +சாமோயா ws +Самоа ws +ซามัว ws +Самоа ws +Самоа ws +Samowa ws +萨摩亚群岛 ws +薩摩亞 ws +Yemen ye +اليمن ye +Yəmən ye +Емен ye +Йемен ye +ইয়েমেন ye +Ihlemeñ ye +Jemen ye +Iemen ye +Jemen ye +Yr Iemen ye +Jemen ye +Υεμένη ye +Jemeno ye +Jeemen ye +یمن ye +Jemen ye +Jemen ye +Jemen ye +Éimin ye +Iemen ye +תימן ye +यमन ye +Jemen ye +Jemen ye +Jemen ye +イエメン ye +យេមែន ye +예멘 ye +ເດມອນ ye +Jemenas ye +Jemena ye +Јемен ye +Емен ye +Yaman ye +Jemen ye +Jemen ye +Jemen ye +Jemen ye +Jemen ye +ਯਮਨ ye +Jemen ye +Iémen ye +Йемен ye +Yemeni ye +Jemen ye +Jemen ye +Jemen ye +Јемен ye +Jemen ye +I-Yemen ye +Jemen ye +யேமன் ye +Яман ye +เยเมน ye +Ємен ye +Яман ye +也门 ye +葉門 ye +Serbia and Montenegro yu +Serbië en Montenegro yu +Сърбия и Черна гора yu +সার্বিয়া এবং মন্টেনিগ্রো yu +Serbi ha Montenegro yu +Sèrbia i Montenegro yu +Srbsko a Černá hora yu +Serbien og Montenegro yu +Serbien und Montenegro yu +Σερβία - Μαυροβούνιο yu +Serbia y Montenegro yu +Serbia ja Tšernogooria yu +Serbia eta Montenegro yu +Serbia ja Montenegro yu +Serbie and Monténégro yu +Servië en Montenegro yu +Sérbia e Montenegro yu +Szerbia és Montenegró yu +Serbía og Svartfjallaland yu +Serbia e Montenegro yu +セルビアモンテネグロ yu +សែប៊ី និង ម៉ុងតេណេហ្ក្រូ yu +Serbija ir Juodkalnija yu +Србија и Црна Гора yu +Serbia og Montenegro yu +Serbien un Montenegro yu +Servië en Montenegro yu +Serbia og Montenegro yu +ਸਰਬੀਆ ਅਤੇ ਮਾਂਤਾਂਗਰੋ yu +Serbia i Czarnogóra yu +Sérvia e Montenegro yu +Sérvia e Montenegro yu +Сербия и Черногория yu +Seribiya na Montenegoro yu +Serbia ja Montenegro yu +Srbija in Črna gora yu +Србија и Црна Гора yu +Srbija i Crna Gora yu +Serbien och Montenegro yu +เซอร์เบีย และมอนติเนโกร yu +Sırbistan Karadağ yu +Serbia wä Montenegro yu +Сербія і Чорногорія yu +Сербия ва Монтенегро yu +塞尔维亚和黑山 yu +塞爾維亞和黑山 yu +South Africa za +Suid-Afrika za +جنوب أفريقيا za +Cənubi Afrika za +Паўднёвая Афрыка za +Южна Африка za +দক্ষিণ আফ্রিকা za +Suafrika za +Južna Afrika za +Sudàfrica za +Jižní Afrika za +De Affrica za +Sydafrikanske republik za +Südafrika za +Νότια Αφρική za +Sudafriko za +Sudáfrica za +Lõuna-Aafrika za +Hego Afrika za +آفریقای جنوبی za +Etelä-Afrikka za +Suðurafrika za +Afrique du sud za +Sûd-Afrika za +An Afraic Theas za +África do Sur za +דרום אפריקה za +दक्षिणी अफ्रीका za +Južna Afrika za +Dél-Afrika za +Afrika Selatan za +Suður-Afríka za +Sud Africa za +南アフリカ za +អាហ្វ្រិកខាងត្បូង za +남 아프리카 공화국 za +ແອບພິກາໃຕ້ za +Afrika, Pietų za +Dienvidāfrika za +Јужна Африка za +Өмнөд африк za +Afrika Selatan za +Afrika t'Isfel za +Sør-Afrika za +Söödafrika za +Zuid-Afrika za +Sør-Afrika za +Afrika Borwa za +Sudafrica za +ਦੱਖਣੀ ਅਫਰੀਕਾ za +Afryka Południowa za +África do Sul za +África do Sul za +Africa de Sud za +Южная Африка za +Afurika Yepfo za +Lulli-Afrihká za +Južná Afrika za +Južna Afrika za +Јужна Африка za +Južna Afrika za +I-South Africa za +Sydafrika za +தென் ஆப்ரிக்கா za +Африқои Ҷанубӣ za +แอฟริกาใต้ za +Güney Afrika za +Könyaq Afrika za +Південна Африка za +Жанубий Африка za +Afurika tshipembe za +Nam Phi za +Nonne Afrike za +Mzantsi Afrika za +南非 za +南非 za +Emzantsi Afrika za +Zambia zm +Zambië zm +زامبيا zm +Zambiya zm +Замбія zm +Замбия zm +জামবিয়া zm +Zambi zm +Zàmbia zm +Zambie zm +Sambia zm +Sambia zm +Ζάμπια zm +Zambio zm +Sambia zm +زامبیا zm +Sambia zm +Zambie zm +An tSaimbia zm +Zámbia zm +זמביה zm +ज़ाम्बिया zm +Zambija zm +Sambía zm +ザンビア zm +ហ្សាំប៊ី zm +잠비아 zm +ຈາໄມກາ້ zm +Zambija zm +Замбија zm +Замби zm +Żambia zm +Sambia zm +ਜੈਂਬੀਆ zm +Zâmbia zm +Zâmbia zm +Замбия zm +Zambiya zm +Zambija zm +Замбија zm +Zambija zm +ஜாம்பியா zm +Зомбиё zm +แซมเบีย zm +Замбія zm +Замбия zm +Zambeye zm +赞比亚 zm +尚比亞 zm +Zimbabwe zw +زيمبابوي zw +Zimbabve zw +Зымбабвэ zw +Зимбабве zw +জিম্বাবোয়ে zw +Zimbabve zw +Simbabwe zw +Simbabwe zw +Ζιμπάμπουε zw +Zimbabvo zw +زیمبابوه zw +An tSiombáib zw +Zimbabué zw +זימבבווה zw +जिम्बाबवे zw +Zimbabve zw +Simbabve zw +ジンバブエ zw +ហ្ស៊ីមបាបវ៉េ zw +짐바브웨 zw +ລິຊາ zw +Zimbabve zw +Зимбабве zw +Замбабив zw +Żimbabwe zw +Simbabwe zw +ਜਿੰਬਾਬਵੇਂ zw +Zimbabue zw +Зимбабве zw +Zimbabve zw +Зимбабве zw +Zimbabve zw +ஜிம்பாபே zw +Зимбобве zw +ซิมบับเว zw +Зімбабве zw +Зимбабве zw +Zimbabwè zw +津巴布韦 zw +辛巴威 zw +Czech Republic cz diff --git a/tdeabc/distributionlist.cpp b/tdeabc/distributionlist.cpp new file mode 100644 index 000000000..e811c4d65 --- /dev/null +++ b/tdeabc/distributionlist.cpp @@ -0,0 +1,298 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqapplication.h> +#include <tqpair.h> +#include <tqvaluelist.h> + +#include <ksimpleconfig.h> +#include <kstandarddirs.h> +#include <kdebug.h> + +#include "distributionlist.h" + +using namespace TDEABC; + +DistributionList::DistributionList( DistributionListManager *manager, + const TQString &name ) : + mManager( manager ), mName( name ) +{ + mManager->insert( this ); +} + +DistributionList::~DistributionList() +{ + mManager->remove( this ); +} + +void DistributionList::setName( const TQString &name ) +{ + mName = name; +} + +TQString DistributionList::name() const +{ + return mName; +} + +void DistributionList::insertEntry( const Addressee &a, const TQString &email ) +{ + Entry e( a, email ); + + TQValueList<Entry>::Iterator it; + for( it = mEntries.begin(); it != mEntries.end(); ++it ) { + if ( (*it).addressee.uid() == a.uid() ) { + /** + We have to check if both email addresses contains no data, + a simple 'email1 == email2' wont work here + */ + if ( ( (*it).email.isNull() && email.isEmpty() ) || + ( (*it).email.isEmpty() && email.isNull() ) || + ( (*it).email == email ) ) { + *it = e; + return; + } + } + } + mEntries.append( e ); +} + +void DistributionList::removeEntry( const Addressee &a, const TQString &email ) +{ + TQValueList<Entry>::Iterator it; + for( it = mEntries.begin(); it != mEntries.end(); ++it ) { + if ( (*it).addressee.uid() == a.uid() && (*it).email == email ) { + mEntries.remove( it ); + return; + } + } +} + +TQStringList DistributionList::emails() const +{ + TQStringList emails; + + Entry::List::ConstIterator it; + for( it = mEntries.begin(); it != mEntries.end(); ++it ) { + Addressee a = (*it).addressee; + TQString email = (*it).email.isEmpty() ? a.fullEmail() : + a.fullEmail( (*it).email ); + + if ( !email.isEmpty() ) { + emails.append( email ); + } + } + + return emails; +} + +DistributionList::Entry::List DistributionList::entries() const +{ + return mEntries; +} + +typedef TQValueList< QPair<TQString, TQString> > MissingEntryList; + +class DistributionListManager::DistributionListManagerPrivate +{ + public: + AddressBook *mAddressBook; + TQMap< TQString, MissingEntryList > mMissingEntries; +}; + +DistributionListManager::DistributionListManager( AddressBook *ab ) + : d( new DistributionListManagerPrivate ) +{ + d->mAddressBook = ab; + mLists.setAutoDelete( true ); +} + +DistributionListManager::~DistributionListManager() +{ + mLists.clear(); + + delete d; + d = 0; +} + +DistributionList *DistributionListManager::list( const TQString &name ) +{ + DistributionList *list; + for( list = mLists.first(); list; list = mLists.next() ) { + if ( list->name() == name ) return list; + } + + return 0; +} + +void DistributionListManager::insert( DistributionList *l ) +{ + if ( !l ) + return; + + DistributionList *list; + for( list = mLists.first(); list; list = mLists.next() ) { + if ( list->name() == l->name() ) { + mLists.remove( list ); + break; + } + } + mLists.append( l ); +} + +void DistributionListManager::remove( DistributionList *l ) +{ + if ( !l ) + return; + + DistributionList *list; + for( list = mLists.first(); list; list = mLists.next() ) { + if ( list->name() == l->name() ) { + mLists.remove( list ); + return; + } + } +} + +TQStringList DistributionListManager::listNames() +{ + TQStringList names; + + DistributionList *list; + for( list = mLists.first(); list; list = mLists.next() ) { + names.append( list->name() ); + } + + return names; +} + +bool DistributionListManager::load() +{ + KSimpleConfig cfg( locateLocal( "data", "tdeabc/distlists" ) ); + + TQMap<TQString,TQString> entryMap = cfg.entryMap( "DistributionLists" ); + cfg.setGroup( "DistributionLists" ); + + // clear old lists + mLists.clear(); + d->mMissingEntries.clear(); + + TQMap<TQString,TQString>::ConstIterator it; + for( it = entryMap.constBegin(); it != entryMap.constEnd(); ++it ) { + TQString name = it.key(); + TQStringList value = cfg.readListEntry( name ); + + kdDebug(5700) << "DLM::load(): " << name << ": " << value.join(",") << endl; + + DistributionList *list = new DistributionList( this, name ); + + MissingEntryList missingEntries; + TQStringList::ConstIterator entryIt = value.constBegin(); + while( entryIt != value.constEnd() ) { + TQString id = *entryIt++; + TQString email = *entryIt; + + kdDebug(5700) << "----- Entry " << id << endl; + + Addressee a = d->mAddressBook->findByUid( id ); + if ( !a.isEmpty() ) { + list->insertEntry( a, email ); + } else { + missingEntries.append( qMakePair( id, email ) ); + } + + if ( entryIt == value.end() ) + break; + ++entryIt; + } + + d->mMissingEntries.insert( name, missingEntries ); + } + + return true; +} + +bool DistributionListManager::save() +{ + kdDebug(5700) << "DistListManager::save()" << endl; + + KSimpleConfig cfg( locateLocal( "data", "tdeabc/distlists" ) ); + + cfg.deleteGroup( "DistributionLists" ); + cfg.setGroup( "DistributionLists" ); + + DistributionList *list; + for( list = mLists.first(); list; list = mLists.next() ) { + kdDebug(5700) << " Saving '" << list->name() << "'" << endl; + + TQStringList value; + const DistributionList::Entry::List entries = list->entries(); + DistributionList::Entry::List::ConstIterator it; + for( it = entries.begin(); it != entries.end(); ++it ) { + value.append( (*it).addressee.uid() ); + value.append( (*it).email ); + } + + if ( d->mMissingEntries.find( list->name() ) != d->mMissingEntries.end() ) { + const MissingEntryList missList = d->mMissingEntries[ list->name() ]; + MissingEntryList::ConstIterator missIt; + for ( missIt = missList.begin(); missIt != missList.end(); ++missIt ) { + value.append( (*missIt).first ); + value.append( (*missIt).second ); + } + } + + cfg.writeEntry( list->name(), value ); + } + + cfg.sync(); + + return true; +} + +DistributionListWatcher* DistributionListWatcher::mSelf = 0; + +DistributionListWatcher::DistributionListWatcher() + : TQObject( tqApp, "DistributionListWatcher" ) +{ + mDirWatch = new KDirWatch; + mDirWatch->addFile( locateLocal( "data", "tdeabc/distlists" ) ); + + connect( mDirWatch, TQT_SIGNAL( dirty( const TQString& ) ), TQT_SIGNAL( changed() ) ); + mDirWatch->startScan(); +} + +DistributionListWatcher::~DistributionListWatcher() +{ + delete mDirWatch; + mDirWatch = 0; +} + +DistributionListWatcher *DistributionListWatcher::self() +{ + kdWarning( !tqApp ) << "No TQApplication object available, you'll get a memleak!" << endl; + + if ( !mSelf ) + mSelf = new DistributionListWatcher(); + + return mSelf; +} + +#include "distributionlist.moc" diff --git a/tdeabc/distributionlist.h b/tdeabc/distributionlist.h new file mode 100644 index 000000000..0c2bdf0bd --- /dev/null +++ b/tdeabc/distributionlist.h @@ -0,0 +1,217 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_DISTRIBUTIONLIST_H +#define KABC_DISTRIBUTIONLIST_H + +#include <kdirwatch.h> + +#include "addressbook.h" + +namespace TDEABC { + +class DistributionListManager; + +/** + @short Distribution list of email addresses + + This class represents a list of email addresses. Each email address is + associated with an address book entry. If the address book entry changes, the + entry in the distribution list is automatically updated. +*/ +class KABC_EXPORT DistributionList +{ + public: + /** + @short Distribution List Entry + + This class represents an entry of a distribution list. It consists of an + addressee and an email address. If the email address is null, the + preferred email address of the addressee is used. + */ + struct Entry + { + typedef TQValueList<Entry> List; + + Entry() {} + Entry( const Addressee &_addressee, const TQString &_email ) : + addressee( _addressee ), email( _email ) {} + + Addressee addressee; + TQString email; + }; + + /** + Create distribution list object. + + @param manager Managing object of this list. + @param name Name of this list. + */ + DistributionList( DistributionListManager *manager, const TQString &name ); + + /** + Destructor. + */ + ~DistributionList(); + + /** + Set name of this list. The name is used as key by the + DistributinListManager. + */ + void setName( const TQString & ); + + /** + Get name of this list. + */ + TQString name() const; + + /** + Insert an entry into this distribution list. If the entry already exists + nothing happens. + */ + void insertEntry( const Addressee &, const TQString &email=TQString::null ); + + /** + Remove an entry from this distribution list. If the entry doesn't exist + nothing happens. + */ + void removeEntry( const Addressee &, const TQString &email=TQString::null ); + + /** + Return list of email addresses, which belong to this distributon list. + These addresses can be directly used by e.g. a mail client. + */ + TQStringList emails() const; + + /** + Return list of entries belonging to this distribution list. This function + is mainly useful for a distribution list editor. + */ + Entry::List entries() const; + + private: + DistributionListManager *mManager; + TQString mName; + + Entry::List mEntries; +}; + +/** + @short Manager of distribution lists + + This class represents a collection of distribution lists, which are associated + with a given address book. +*/ +class KABC_EXPORT DistributionListManager +{ + public: + /** + Create manager for given address book. + */ + DistributionListManager( AddressBook * ); + + /** + Destructor. + */ + ~DistributionListManager(); + + /** + Return distribution list with given name. + */ + DistributionList *list( const TQString &name ); // KDE4: add bool caseSensitive = true + + /** + Insert distribution list. If a list with this name already exists, nothing + happens. The passed object is deleted by the manager. + */ + void insert( DistributionList * ); + + /** + Remove distribution list. If a list with this name doesn't exist, nothing + happens. + */ + void remove( DistributionList * ); + + /** + Return names of all distribution lists managed by this manager. + */ + TQStringList listNames(); + + /** + Load distribution lists form disk. + */ + bool load(); + + /** + Save distribution lists to disk. + */ + bool save(); + + private: + class DistributionListManagerPrivate; + DistributionListManagerPrivate *d; + + TQPtrList<DistributionList> mLists; +}; + +/** + @short Watchdog for distribution lists + + This class provides a changed() signal that i emitted when the + distribution lists has changed in some way. + + Exapmle: + + \code + TDEABC::DistributionListWatcher *watchdog = TDEABC::DistributionListWatcher::self() + + connect( watchdog, TQT_SIGNAL( changed() ), TQT_SLOT( doSomething() ) ); + \endcode +*/ + +class KABC_EXPORT DistributionListWatcher : public TQObject +{ + Q_OBJECT + + public: + /** + * Returns the watcher object. + */ + static DistributionListWatcher *self(); + + signals: + /** + * This signal is emmitted whenever the distribution lists has + * changed (if a list was added or removed, when a list was + * renamed or the entries of the list changed). + */ + void changed(); + + protected: + DistributionListWatcher(); + ~DistributionListWatcher(); + + private: + static DistributionListWatcher* mSelf; + KDirWatch *mDirWatch; +}; + +} +#endif diff --git a/tdeabc/distributionlistdialog.cpp b/tdeabc/distributionlistdialog.cpp new file mode 100644 index 000000000..c440fcb4c --- /dev/null +++ b/tdeabc/distributionlistdialog.cpp @@ -0,0 +1,399 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlistview.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqpushbutton.h> +#include <tqcombobox.h> +#include <kinputdialog.h> +#include <tqbuttongroup.h> +#include <tqradiobutton.h> + +#include <tdelocale.h> +#include <kdebug.h> +#include <tdemessagebox.h> + +#include "addressbook.h" +#include "addresseedialog.h" +#include "distributionlist.h" + +#include "distributionlistdialog.h" +#include "distributionlistdialog.moc" + +using namespace TDEABC; + +DistributionListDialog::DistributionListDialog( AddressBook *addressBook, TQWidget *parent) + : KDialogBase( parent, "", true, i18n("Configure Distribution Lists"), Ok, Ok, true) +{ + mEditor = new DistributionListEditorWidget( addressBook, this ); + setMainWidget( mEditor ); + + connect( this, TQT_SIGNAL( okClicked() ), mEditor, TQT_SLOT( save() ) ); +} + +DistributionListDialog::~DistributionListDialog() +{ +} + +// TODO KDE4: Add d-pointer to EmailSelector, make sEmailMap a member variable +static TQMap<TQWidget*,TQString> *sEmailMap = 0; + +EmailSelector::EmailSelector( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ) : + KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, + parent ) +{ + if (!sEmailMap) + sEmailMap = new TQMap<TQWidget*,TQString>(); + TQFrame *topFrame = plainPage(); + TQBoxLayout *topLayout = new TQVBoxLayout( topFrame ); + + mButtonGroup = new TQButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"), + topFrame ); + topLayout->addWidget( mButtonGroup ); + + TQStringList::ConstIterator it; + for( it = emails.begin(); it != emails.end(); ++it ) { + TQRadioButton *button = new TQRadioButton( *it, mButtonGroup ); + sEmailMap->insert( button, *it ); + if ( (*it) == current ) { + mButtonGroup->setButton(mButtonGroup->id(button)); + } + } +} + +TQString EmailSelector::selected() +{ + TQButton *button = mButtonGroup->selected(); + if ( button ) return (*sEmailMap)[button]; + return TQString::null; +} + +TQString EmailSelector::getEmail( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ) +{ + EmailSelector *dlg = new EmailSelector( emails, current, parent ); + dlg->exec(); + + TQString result = dlg->selected(); + + delete dlg; + + return result; +} + +class EntryItem : public TQListViewItem +{ + public: + EntryItem( TQListView *parent, const Addressee &addressee, + const TQString &email=TQString::null ) : + TQListViewItem( parent ), + mAddressee( addressee ), + mEmail( email ) + { + setText( 0, addressee.realName() ); + if( email.isEmpty() ) { + setText( 1, addressee.preferredEmail() ); + setText( 2, i18n("Yes") ); + } else { + setText( 1, email ); + setText( 2, i18n("No") ); + } + } + + Addressee addressee() const + { + return mAddressee; + } + + TQString email() const + { + return mEmail; + } + + private: + Addressee mAddressee; + TQString mEmail; +}; + +DistributionListEditorWidget::DistributionListEditorWidget( AddressBook *addressBook, TQWidget *parent) : + TQWidget( parent ), + mAddressBook( addressBook ) +{ + kdDebug(5700) << "DistributionListEditor()" << endl; + + TQBoxLayout *topLayout = new TQVBoxLayout( this ); + topLayout->setSpacing( KDialog::spacingHint() ); + + TQBoxLayout *nameLayout = new TQHBoxLayout( topLayout) ; + + mNameCombo = new TQComboBox( this ); + nameLayout->addWidget( mNameCombo ); + connect( mNameCombo, TQT_SIGNAL( activated( int ) ), TQT_SLOT( updateEntryView() ) ); + + mNewButton = new TQPushButton( i18n("New List..."), this ); + nameLayout->addWidget( mNewButton ); + connect( mNewButton, TQT_SIGNAL( clicked() ), TQT_SLOT( newList() ) ); + + mEditButton = new TQPushButton( i18n("Rename List..."), this ); + nameLayout->addWidget( mEditButton ); + connect( mEditButton, TQT_SIGNAL( clicked() ), TQT_SLOT( editList() ) ); + + mRemoveButton = new TQPushButton( i18n("Remove List"), this ); + nameLayout->addWidget( mRemoveButton ); + connect( mRemoveButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeList() ) ); + + TQGridLayout *gridLayout = new TQGridLayout( topLayout, 3, 3 ); + gridLayout->setColStretch(1, 1); + + TQLabel *listLabel = new TQLabel( i18n("Available addresses:"), this ); + gridLayout->addWidget( listLabel, 0, 0 ); + + mListLabel = new TQLabel( this ); + gridLayout->addMultiCellWidget( mListLabel, 0, 0, 1, 2 ); + + mAddresseeView = new TQListView( this ); + mAddresseeView->addColumn( i18n("Name") ); + mAddresseeView->addColumn( i18n("Preferred Email") ); + mAddresseeView->setAllColumnsShowFocus( true ); + gridLayout->addWidget( mAddresseeView, 1, 0 ); + connect( mAddresseeView, TQT_SIGNAL( selectionChanged() ), + TQT_SLOT( slotSelectionAddresseeViewChanged() ) ); + connect( mAddresseeView, TQT_SIGNAL( doubleClicked( TQListViewItem * ) ), + TQT_SLOT( addEntry() ) ); + + mAddEntryButton = new TQPushButton( i18n("Add Entry"), this ); + mAddEntryButton->setEnabled(false); + gridLayout->addWidget( mAddEntryButton, 2, 0 ); + connect( mAddEntryButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addEntry() ) ); + + mEntryView = new TQListView( this ); + mEntryView->addColumn( i18n("Name") ); + mEntryView->addColumn( i18n("Email") ); + mEntryView->addColumn( i18n("Use Preferred") ); + mEntryView->setEnabled(false); + mEntryView->setAllColumnsShowFocus( true ); + gridLayout->addMultiCellWidget( mEntryView, 1, 1, 1, 2 ); + connect( mEntryView, TQT_SIGNAL( selectionChanged() ), + TQT_SLOT( slotSelectionEntryViewChanged() ) ); + + mChangeEmailButton = new TQPushButton( i18n("Change Email..."), this ); + gridLayout->addWidget( mChangeEmailButton, 2, 1 ); + connect( mChangeEmailButton, TQT_SIGNAL( clicked() ), TQT_SLOT( changeEmail() ) ); + + mRemoveEntryButton = new TQPushButton( i18n("Remove Entry"), this ); + gridLayout->addWidget( mRemoveEntryButton, 2, 2 ); + connect( mRemoveEntryButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeEntry() ) ); + + mManager = new DistributionListManager( mAddressBook ); + mManager->load(); + + updateAddresseeView(); + updateNameCombo(); +} + +DistributionListEditorWidget::~DistributionListEditorWidget() +{ + kdDebug(5700) << "~DistributionListEditor()" << endl; + + delete mManager; +} + +void DistributionListEditorWidget::save() +{ + mManager->save(); +} + +void DistributionListEditorWidget::slotSelectionEntryViewChanged() +{ + EntryItem *entryItem = static_cast<EntryItem *>( mEntryView->selectedItem() ); + bool state=entryItem; + + mChangeEmailButton->setEnabled(state); + mRemoveEntryButton->setEnabled(state); +} + +void DistributionListEditorWidget::newList() +{ + bool ok; + TQString name = KInputDialog::getText( i18n( "New Distribution List" ), + i18n( "Please enter &name:" ), TQString::null, &ok ); + if (!ok) return; + + new DistributionList( mManager, name ); + + mNameCombo->clear(); + mNameCombo->insertStringList( mManager->listNames() ); + mNameCombo->setCurrentItem( mNameCombo->count() - 1 ); + + updateEntryView(); + slotSelectionAddresseeViewChanged(); +} + +void DistributionListEditorWidget::editList() +{ + TQString oldName = mNameCombo->currentText(); + bool ok; + TQString name = KInputDialog::getText( i18n( "Distribution List" ), + i18n( "Please change &name:" ), oldName, &ok ); + if (!ok) return; + + DistributionList *list = mManager->list( oldName ); + list->setName( name ); + + mNameCombo->clear(); + mNameCombo->insertStringList( mManager->listNames() ); + mNameCombo->setCurrentItem( mNameCombo->count() - 1 ); + + updateEntryView(); + slotSelectionAddresseeViewChanged(); +} + +void DistributionListEditorWidget::removeList() +{ + int result = KMessageBox::warningContinueCancel( this, + i18n("Delete distribution list '%1'?") .arg( mNameCombo->currentText() ), + TQString::null, KStdGuiItem::del() ); + + if ( result != KMessageBox::Continue ) return; + + mManager->remove( mManager->list( mNameCombo->currentText() ) ); + mNameCombo->removeItem( mNameCombo->currentItem() ); + + updateEntryView(); + slotSelectionAddresseeViewChanged(); +} + +void DistributionListEditorWidget::addEntry() +{ + AddresseeItem *addresseeItem = + static_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); + + if( !addresseeItem ) { + kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl; + return; + } + + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) { + kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl; + return; + } + + list->insertEntry( addresseeItem->addressee() ); + updateEntryView(); + slotSelectionAddresseeViewChanged(); +} + +void DistributionListEditorWidget::removeEntry() +{ + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) return; + + EntryItem *entryItem = + static_cast<EntryItem *>( mEntryView->selectedItem() ); + if ( !entryItem ) return; + + list->removeEntry( entryItem->addressee(), entryItem->email() ); + delete entryItem; +} + +void DistributionListEditorWidget::changeEmail() +{ + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) return; + + EntryItem *entryItem = + static_cast<EntryItem *>( mEntryView->selectedItem() ); + if ( !entryItem ) return; + + TQString email = EmailSelector::getEmail( entryItem->addressee().emails(), + entryItem->email(), this ); + list->removeEntry( entryItem->addressee(), entryItem->email() ); + list->insertEntry( entryItem->addressee(), email ); + + updateEntryView(); +} + +void DistributionListEditorWidget::updateEntryView() +{ + if ( mNameCombo->currentText().isEmpty() ) { + mListLabel->setText( i18n("Selected addressees:") ); + } else { + mListLabel->setText( i18n("Selected addresses in '%1':") + .arg( mNameCombo->currentText() ) ); + } + + mEntryView->clear(); + + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) { + mEditButton->setEnabled(false); + mRemoveButton->setEnabled(false); + mChangeEmailButton->setEnabled(false); + mRemoveEntryButton->setEnabled(false); + mAddresseeView->setEnabled(false); + mEntryView->setEnabled(false); + return; + } else { + mEditButton->setEnabled(true); + mRemoveButton->setEnabled(true); + mAddresseeView->setEnabled(true); + mEntryView->setEnabled(true); + } + + DistributionList::Entry::List entries = list->entries(); + DistributionList::Entry::List::ConstIterator it; + for( it = entries.begin(); it != entries.end(); ++it ) { + new EntryItem( mEntryView, (*it).addressee, (*it).email ); + } + + EntryItem *entryItem = static_cast<EntryItem *>( mEntryView->selectedItem() ); + bool state=entryItem; + + mChangeEmailButton->setEnabled(state); + mRemoveEntryButton->setEnabled(state); +} + +void DistributionListEditorWidget::updateAddresseeView() +{ + mAddresseeView->clear(); + + AddressBook::Iterator it; + for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + new AddresseeItem( mAddresseeView, *it ); + } +} + +void DistributionListEditorWidget::updateNameCombo() +{ + mNameCombo->insertStringList( mManager->listNames() ); + + updateEntryView(); +} + +void DistributionListEditorWidget::slotSelectionAddresseeViewChanged() +{ + AddresseeItem *addresseeItem = + static_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); + bool state=addresseeItem; + mAddEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty()); +} diff --git a/tdeabc/distributionlistdialog.h b/tdeabc/distributionlistdialog.h new file mode 100644 index 000000000..d4286a54b --- /dev/null +++ b/tdeabc/distributionlistdialog.h @@ -0,0 +1,139 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_DISTRIBUTIONLISTDIALOG_H +#define KABC_DISTRIBUTIONLISTDIALOG_H + +#include <tqwidget.h> + +#include <kdialogbase.h> + +class TQListView; +class TQComboBox; +class TQButtonGroup; + +namespace TDEABC { + +class AddressBook; +class DistributionListEditorWidget; +class DistributionListManager; + +/** + @short Frontend to create distribution lists + + Creating a new DistributionListDialog does automatically + load all addressees and distribution lists from the config + files. The changes will be saved when clicking the 'OK' + button. + + Example: + + \code + TDEABC::DistributionListDialog *dlg = new + TDEABC::DistributionListDialog( TDEABC::StdAddressBook::self(), this ); + + dlg->exec(); + \endcode +*/ +class KABC_EXPORT DistributionListDialog : public KDialogBase +{ + Q_OBJECT + + public: + /** + Constructor. + + @param ab The addressbook, the addressees should be used from + @param parent The parent widget + */ + DistributionListDialog( AddressBook *ab, TQWidget *parent ); + + /** + Destructor. + */ + virtual ~DistributionListDialog(); + + private: + DistributionListEditorWidget *mEditor; + + struct Data; + Data *d; +}; + +/** + @short Helper class +*/ +class KABC_EXPORT EmailSelector : public KDialogBase +{ + public: + EmailSelector( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ); + + TQString selected(); + + static TQString getEmail( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ); + + private: + TQButtonGroup *mButtonGroup; +}; + +/** + @short Helper class +*/ +class KABC_EXPORT DistributionListEditorWidget : public TQWidget +{ + Q_OBJECT + + public: + DistributionListEditorWidget( AddressBook *, TQWidget *parent ); + virtual ~DistributionListEditorWidget(); + + private slots: + void newList(); + void editList(); + void removeList(); + void addEntry(); + void removeEntry(); + void changeEmail(); + void updateEntryView(); + void updateAddresseeView(); + void updateNameCombo(); + void slotSelectionEntryViewChanged(); + void slotSelectionAddresseeViewChanged(); + void save(); + + private: + TQComboBox *mNameCombo; + TQLabel *mListLabel; + TQListView *mEntryView; + TQListView *mAddresseeView; + + AddressBook *mAddressBook; + DistributionListManager *mManager; + TQPushButton *mNewButton, *mEditButton, *mRemoveButton; + TQPushButton *mChangeEmailButton, *mRemoveEntryButton, *mAddEntryButton; + + struct Data; + Data *d; +}; + +} +#endif diff --git a/tdeabc/distributionlisteditor.cpp b/tdeabc/distributionlisteditor.cpp new file mode 100644 index 000000000..76fd35568 --- /dev/null +++ b/tdeabc/distributionlisteditor.cpp @@ -0,0 +1,310 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlistview.h> +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqcombobox.h> +#include <tqbuttongroup.h> +#include <tqradiobutton.h> + +#include <kinputdialog.h> +#include <tdelocale.h> +#include <kdebug.h> + +#include "addressbook.h" +#include "addresseedialog.h" +#include "distributionlist.h" + +#include "distributionlisteditor.h" +#include "distributionlisteditor.moc" + +using namespace TDEABC; + +EmailSelectDialog::EmailSelectDialog( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ) : + KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, + parent ) +{ + TQFrame *topFrame = plainPage(); + TQBoxLayout *topLayout = new TQVBoxLayout( topFrame ); + + mButtonGroup = new TQButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"), + topFrame ); + mButtonGroup->setRadioButtonExclusive( true ); + topLayout->addWidget( mButtonGroup ); + + TQStringList::ConstIterator it; + for( it = emails.begin(); it != emails.end(); ++it ) { + TQRadioButton *button = new TQRadioButton( *it, mButtonGroup ); + if ( (*it) == current ) { + button->setDown( true ); + } + } +} + +TQString EmailSelectDialog::selected() +{ + TQButton *button = mButtonGroup->selected(); + if ( button ) return button->text(); + return TQString::null; +} + +TQString EmailSelectDialog::getEmail( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ) +{ + EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent ); + dlg->exec(); + + TQString result = dlg->selected(); + + delete dlg; + + return result; +} + +class EditEntryItem : public TQListViewItem +{ + public: + EditEntryItem( TQListView *parent, const Addressee &addressee, + const TQString &email=TQString::null ) : + TQListViewItem( parent ), + mAddressee( addressee ), + mEmail( email ) + { + setText( 0, addressee.realName() ); + if( email.isEmpty() ) { + setText( 1, addressee.preferredEmail() ); + setText( 2, i18n("Yes") ); + } else { + setText( 1, email ); + setText( 2, i18n("No") ); + } + } + + Addressee addressee() const + { + return mAddressee; + } + + TQString email() const + { + return mEmail; + } + + private: + Addressee mAddressee; + TQString mEmail; +}; + +DistributionListEditor::DistributionListEditor( AddressBook *addressBook, TQWidget *parent) : + TQWidget( parent ), + mAddressBook( addressBook ) +{ + kdDebug(5700) << "DistributionListEditor()" << endl; + + TQBoxLayout *topLayout = new TQVBoxLayout( this ); + topLayout->setMargin( KDialog::marginHint() ); + topLayout->setSpacing( KDialog::spacingHint() ); + + TQBoxLayout *nameLayout = new TQHBoxLayout( topLayout) ; + + mNameCombo = new TQComboBox( this ); + nameLayout->addWidget( mNameCombo ); + connect( mNameCombo, TQT_SIGNAL( activated( int ) ), TQT_SLOT( updateEntryView() ) ); + + newButton = new TQPushButton( i18n("New List"), this ); + nameLayout->addWidget( newButton ); + connect( newButton, TQT_SIGNAL( clicked() ), TQT_SLOT( newList() ) ); + + removeButton = new TQPushButton( i18n("Remove List"), this ); + nameLayout->addWidget( removeButton ); + connect( removeButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeList() ) ); + + mEntryView = new TQListView( this ); + mEntryView->addColumn( i18n("Name") ); + mEntryView->addColumn( i18n("Email") ); + mEntryView->addColumn( i18n("Use Preferred") ); + topLayout->addWidget( mEntryView ); + connect(mEntryView,TQT_SIGNAL(selectionChanged ()),this, TQT_SLOT(slotSelectionEntryViewChanged())); + + changeEmailButton = new TQPushButton( i18n("Change Email"), this ); + topLayout->addWidget( changeEmailButton ); + connect( changeEmailButton, TQT_SIGNAL( clicked() ), TQT_SLOT( changeEmail() ) ); + + removeEntryButton = new TQPushButton( i18n("Remove Entry"), this ); + topLayout->addWidget( removeEntryButton ); + connect( removeEntryButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeEntry() ) ); + + addEntryButton = new TQPushButton( i18n("Add Entry"), this ); + topLayout->addWidget( addEntryButton ); + connect( addEntryButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addEntry() ) ); + + mAddresseeView = new TQListView( this ); + mAddresseeView->addColumn( i18n("Name") ); + mAddresseeView->addColumn( i18n("Preferred Email") ); + topLayout->addWidget( mAddresseeView ); + + + connect(mAddresseeView,TQT_SIGNAL(selectionChanged ()),this, TQT_SLOT(slotSelectionAddresseeViewChanged())); + + mManager = new DistributionListManager( mAddressBook ); + mManager->load(); + + updateAddresseeView(); + updateNameCombo(); + removeButton->setEnabled(!mManager->listNames().isEmpty()); +} + +DistributionListEditor::~DistributionListEditor() +{ + kdDebug(5700) << "~DistributionListEditor()" << endl; + + mManager->save(); + delete mManager; +} + +void DistributionListEditor::slotSelectionEntryViewChanged() +{ + EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); + bool state = (entryItem != 0L); + + changeEmailButton->setEnabled(state); + removeEntryButton->setEnabled(state); +} + +void DistributionListEditor::newList() +{ + bool ok = false; + TQString name = KInputDialog::getText( i18n("New Distribution List"), + i18n("Please enter name:"), + TQString::null, &ok, this ); + if ( !ok ) + return; + + new DistributionList( mManager, name ); + + mNameCombo->insertItem( name ); + removeButton->setEnabled(true); + updateEntryView(); +} + +void DistributionListEditor::removeList() +{ + mManager->remove( mManager->list( mNameCombo->currentText() ) ); + mNameCombo->removeItem( mNameCombo->currentItem() ); + removeButton->setEnabled(!mManager->listNames().isEmpty()); + addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty()); + updateEntryView(); +} + +void DistributionListEditor::addEntry() +{ + AddresseeItem *addresseeItem = + dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); + + if( !addresseeItem ) { + kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl; + return; + } + + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) { + kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl; + return; + } + + list->insertEntry( addresseeItem->addressee() ); + updateEntryView(); + slotSelectionAddresseeViewChanged(); +} + +void DistributionListEditor::removeEntry() +{ + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) return; + + EditEntryItem *entryItem = + dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); + if ( !entryItem ) return; + + list->removeEntry( entryItem->addressee(), entryItem->email() ); + delete entryItem; +} + +void DistributionListEditor::changeEmail() +{ + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) return; + + EditEntryItem *entryItem = + dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); + if ( !entryItem ) return; + + TQString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(), + entryItem->email(), this ); + list->removeEntry( entryItem->addressee(), entryItem->email() ); + list->insertEntry( entryItem->addressee(), email ); + + updateEntryView(); +} + +void DistributionListEditor::updateEntryView() +{ + DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) return; + + mEntryView->clear(); + DistributionList::Entry::List entries = list->entries(); + DistributionList::Entry::List::ConstIterator it; + for( it = entries.begin(); it != entries.end(); ++it ) { + new EditEntryItem( mEntryView, (*it).addressee, (*it).email ); + } + EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); + bool state = (entryItem != 0L); + + changeEmailButton->setEnabled(state); + removeEntryButton->setEnabled(state); +} + +void DistributionListEditor::updateAddresseeView() +{ + mAddresseeView->clear(); + + AddressBook::Iterator it; + for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + new AddresseeItem( mAddresseeView, *it ); + } +} + +void DistributionListEditor::updateNameCombo() +{ + mNameCombo->insertStringList( mManager->listNames() ); + + updateEntryView(); +} + +void DistributionListEditor::slotSelectionAddresseeViewChanged() +{ + AddresseeItem *addresseeItem = + dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); + bool state = (addresseeItem != 0L); + addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty()); +} diff --git a/tdeabc/distributionlisteditor.h b/tdeabc/distributionlisteditor.h new file mode 100644 index 000000000..6da6495f8 --- /dev/null +++ b/tdeabc/distributionlisteditor.h @@ -0,0 +1,86 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_DISTRIBUTIONLISTEDITOR_H +#define KABC_DISTRIBUTIONLISTEDITOR_H + +#include <tqwidget.h> + +#include <kdialogbase.h> + +class TQListView; +class TQComboBox; +class TQButtonGroup; + +namespace TDEABC { + +class AddressBook; +class DistributionListManager; + +class KABC_EXPORT EmailSelectDialog : public KDialogBase +{ + public: + EmailSelectDialog( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ); + + TQString selected(); + + static TQString getEmail( const TQStringList &emails, const TQString ¤t, + TQWidget *parent ); + + private: + TQButtonGroup *mButtonGroup; +}; + +/** + @obsolete +*/ +class DistributionListEditor : public TQWidget +{ + Q_OBJECT + public: + DistributionListEditor( AddressBook *, TQWidget *parent ); + virtual ~DistributionListEditor(); + + private slots: + void newList(); + void removeList(); + void addEntry(); + void removeEntry(); + void changeEmail(); + void updateEntryView(); + void updateAddresseeView(); + void updateNameCombo(); + void slotSelectionEntryViewChanged(); + void slotSelectionAddresseeViewChanged(); + + private: + TQComboBox *mNameCombo; + TQListView *mEntryView; + TQListView *mAddresseeView; + + AddressBook *mAddressBook; + DistributionListManager *mManager; + TQPushButton *newButton, *removeButton; + TQPushButton *changeEmailButton,*removeEntryButton,*addEntryButton; +}; + +} + +#endif diff --git a/tdeabc/errorhandler.cpp b/tdeabc/errorhandler.cpp new file mode 100644 index 000000000..3208b84c9 --- /dev/null +++ b/tdeabc/errorhandler.cpp @@ -0,0 +1,55 @@ +/* + This file is part of libkabc. + + Copyright (c) 2002 Tobias Koenig <[email protected]> + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <tdelocale.h> +#include <tdemessagebox.h> + +#include <tqapplication.h> + +#include "errorhandler.h" + +using namespace TDEABC; + +void ConsoleErrorHandler::error( const TQString &msg ) +{ + // no debug area is ok here + kdError() << msg << endl; +} + + +void GUIErrorHandler::error( const TQString &msg ) +{ + KMessageBox::error( 0, msg, i18n( "Error in libkabc" ) ); +} + + +GuiErrorHandler::GuiErrorHandler( TQWidget *parent ) + : mParent( parent ) +{ +} + +void GuiErrorHandler::error( const TQString &msg ) +{ + if (tqApp) + KMessageBox::error( mParent, msg ); +} diff --git a/tdeabc/errorhandler.h b/tdeabc/errorhandler.h new file mode 100644 index 000000000..d3d3f253d --- /dev/null +++ b/tdeabc/errorhandler.h @@ -0,0 +1,95 @@ +/* + This file is part of libkabc. + + Copyright (c) 2002 Tobias Koenig <[email protected]> + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_ERRORHANDLER_H +#define KABC_ERRORHANDLER_H + +#include <tqstring.h> + +#include <tdelibs_export.h> + +class TQWidget; + +namespace TDEABC { + +/** + Abstract class that provides displaying of error messages. + We need this to make libkabc gui independent on the one side + and provide user friendly error messages on the other side. + Use @p ConsoleErrorHandler or @p GuiErrorHandler in your + application or provide your own ErrorHandler. +*/ +class KABC_EXPORT ErrorHandler +{ + public: + /** + Show error message. + */ + virtual void error( const TQString &msg ) = 0; +}; + +/** + This class prints the error messages to stderr via kdError(). +*/ +class KABC_EXPORT ConsoleErrorHandler : public ErrorHandler +{ + public: + virtual void error( const TQString &msg ); +}; + +/** + This class shows messages boxes for every + error message. + + \deprecated Use GuiErrorHandler instead. +*/ +class KABC_EXPORT GUIErrorHandler : public ErrorHandler +{ + public: + virtual void error( const TQString &msg ); +}; + +/** + This class shows messages boxes for every + error message. +*/ +class KABC_EXPORT GuiErrorHandler : public ErrorHandler +{ + public: + /** + Create error handler. + + \param parent Widget which is used as parent for the error dialogs. + */ + GuiErrorHandler( TQWidget *parent ); + + virtual void error( const TQString &msg ); + + private: + TQWidget *mParent; + + class Private; + Private *d; +}; + +} + +#endif diff --git a/tdeabc/field.h b/tdeabc/field.h new file mode 100644 index 000000000..08322ecf5 --- /dev/null +++ b/tdeabc/field.h @@ -0,0 +1,176 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_FIELD_H +#define KABC_FIELD_H + +#include <tqstring.h> +#include <tqvaluelist.h> + +#include "addressee.h" + +class TDEConfig; + +namespace TDEABC { + +class KABC_EXPORT Field +{ + class FieldImpl; + friend class FieldImpl; + +public: + typedef TQValueList<Field *> List; + + /** + * @li @p All - + * @li @p Frequent - + * @li @p Address - + * @li @p Email - + * @li @p Personal - + * @li @p Organization - + * @li @p CustomCategory - + */ + enum FieldCategory + { + All = 0x0, + Frequent = 0x01, + Address = 0x02, + Email = 0x04, + Personal = 0x08, + Organization = 0x10, + CustomCategory = 0x20 + }; + + /** + * Returns the translated label for this field. + */ + virtual TQString label(); + + /** + * Returns the ored categories the field belongs to. + */ + virtual int category(); + + /** + * Returns the translated label for field category. + */ + static TQString categoryLabel( int category ); + + /** + * Returns a string representation of the value the field has in the given + * Addressee. Returns TQString::null, if it is not possible to convert the + * value to a string. + */ + virtual TQString value( const TDEABC::Addressee & ); + + /** + * Sets the value of the field in the given Addressee. Returns true on success + * or false, if the given string couldn't be converted to a valid value. + */ + virtual bool setValue( TDEABC::Addressee &, const TQString & ); + + /** + * Returns a string, that can be used for sorting. + */ + TQString sortKey( const TDEABC::Addressee & ); + + /** + * Returns, if the field is a user-defined field. + */ + virtual bool isCustom(); + + /** + * Returns, if the field is equal with @a field. + */ + virtual bool equals( Field *field ); + + /** + * Returns a list of all fields. + */ + static Field::List allFields(); + + /** + * Returns a list of the default fields. + */ + static Field::List defaultFields(); + + /** + * Creates a custom field. + * + * @param label The label for this field + * @param category The category of this field + * @param key Unique key for this field + * @param app Unique app name for this field + */ + static Field *createCustomField( const TQString &label, int category, + const TQString &key, const TQString &app ); + + /** + * Delete all fields from list. + */ + static void deleteFields(); + + /** + * Save the field settings to a config file. + * + * @param cfg The config file object + * @param identifier The unique identifier + * @param fields The list of the fields + */ + static void saveFields( TDEConfig *cfg, const TQString &identifier, + const Field::List &fields ); + /** + * This is the same as above, with the difference, that + * the list is stored in TDEGlobal::config() in group "KABCFields". + */ + static void saveFields( const TQString &identifier, + const Field::List &fields ); + + /** + * Load the field settings from a config file. + * + * @param cfg The config file object + * @param identifier The unique identifier + */ + static Field::List restoreFields( TDEConfig *cfg, const TQString &identifier ); + + /** + * This is the same as above, with the difference, that + * the list is loaded from TDEGlobal::config() from group "KABCFields". + */ + static Field::List restoreFields( const TQString &identifier ); + +protected: + static void createField( int id, int category = 0 ); + static void createDefaultField( int id, int category = 0 ); + +private: + Field( FieldImpl * ); + virtual ~Field(); + + FieldImpl *mImpl; + + static Field::List mAllFields; + static Field::List mDefaultFields; + static Field::List mCustomFields; +}; + +} +#endif diff --git a/tdeabc/format.h b/tdeabc/format.h new file mode 100644 index 000000000..77c2edcc5 --- /dev/null +++ b/tdeabc/format.h @@ -0,0 +1,49 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_FORMAT_H +#define KABC_FORMAT_H + +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +class AddressBook; + +/** + @deprecated use FormatPlugin instead +*/ +class KABC_EXPORT_DEPRECATED Format +{ + public: + /** + Load addressbook from file. + */ + virtual bool load( AddressBook *, const TQString &fileName ) = 0; + /** + Save addressbook to file. + */ + virtual bool save( AddressBook *, const TQString &fileName ) = 0; +}; + +} + +#endif diff --git a/tdeabc/formatfactory.cpp b/tdeabc/formatfactory.cpp new file mode 100644 index 000000000..4839acc4d --- /dev/null +++ b/tdeabc/formatfactory.cpp @@ -0,0 +1,168 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <tdelocale.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> +#include <kstaticdeleter.h> + +#include <tqfile.h> + +#include "vcardformatplugin.h" + +#include "formatfactory.h" + +using namespace TDEABC; + +FormatFactory *FormatFactory::mSelf = 0; +static KStaticDeleter<FormatFactory> factoryDeleter; + +FormatFactory *FormatFactory::self() +{ + kdDebug(5700) << "FormatFactory::self()" << endl; + + if ( !mSelf ) + factoryDeleter.setObject( mSelf, new FormatFactory ); + + return mSelf; +} + +FormatFactory::FormatFactory() +{ + mFormatList.setAutoDelete( true ); + + // dummy entry for default format + FormatInfo *info = new FormatInfo; + info->library = "<NoLibrary>"; + info->nameLabel = i18n( "vCard" ); + info->descriptionLabel = i18n( "vCard Format" ); + mFormatList.insert( "vcard", info ); + + const TQStringList list = TDEGlobal::dirs()->findAllResources( "data" ,"tdeabc/formats/*.desktop", true, true ); + for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) + { + KSimpleConfig config( *it, true ); + + if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) + continue; + + info = new FormatInfo; + + config.setGroup( "Plugin" ); + TQString type = config.readEntry( "Type" ); + info->library = config.readEntry( "X-TDE-Library" ); + + config.setGroup( "Misc" ); + info->nameLabel = config.readEntry( "Name" ); + info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); + + mFormatList.insert( type, info ); + } +} + +FormatFactory::~FormatFactory() +{ + mFormatList.clear(); +} + +TQStringList FormatFactory::formats() +{ + TQStringList retval; + + // make sure 'vcard' is the first entry + retval << "vcard"; + + TQDictIterator<FormatInfo> it( mFormatList ); + for ( ; it.current(); ++it ) + if ( it.currentKey() != "vcard" ) + retval << it.currentKey(); + + return retval; +} + +FormatInfo *FormatFactory::info( const TQString &type ) +{ + if ( type.isEmpty() ) + return 0; + else + return mFormatList[ type ]; +} + +FormatPlugin *FormatFactory::format( const TQString& type ) +{ + FormatPlugin *format = 0; + + if ( type.isEmpty() ) + return 0; + + if ( type == "vcard" ) { + format = new VCardFormatPlugin; + format->setType( type ); + format->setNameLabel( i18n( "vCard" ) ); + format->setDescriptionLabel( i18n( "vCard Format" ) ); + return format; + } + + FormatInfo *fi = mFormatList[ type ]; + if (!fi) + return 0; + TQString libName = fi->library; + + KLibrary *library = openLibrary( libName ); + if ( !library ) + return 0; + + void *format_func = library->symbol( "format" ); + + if ( format_func ) { + format = ((FormatPlugin* (*)())format_func)(); + format->setType( type ); + format->setNameLabel( fi->nameLabel ); + format->setDescriptionLabel( fi->descriptionLabel ); + } else { + kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl; + return 0; + } + + return format; +} + + +KLibrary *FormatFactory::openLibrary( const TQString& libName ) +{ + KLibrary *library = 0; + + TQString path = KLibLoader::findLibrary( TQFile::encodeName( libName ) ); + + if ( path.isEmpty() ) { + kdDebug( 5700 ) << "No format plugin library was found!" << endl; + return 0; + } + + library = KLibLoader::self()->library( TQFile::encodeName( path ) ); + + if ( !library ) { + kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl; + return 0; + } + + return library; +} diff --git a/tdeabc/formatfactory.h b/tdeabc/formatfactory.h new file mode 100644 index 000000000..0994fe109 --- /dev/null +++ b/tdeabc/formatfactory.h @@ -0,0 +1,101 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_FORMATFACTORY_H +#define KABC_FORMATFACTORY_H + +#include <tqdict.h> +#include <tqstring.h> + +#include <tdeconfig.h> +#include <klibloader.h> + +#include "formatplugin.h" + +namespace TDEABC { + +struct FormatInfo +{ + TQString library; + TQString nameLabel; + TQString descriptionLabel; +}; + +/** + * Class for loading format plugins. + * + * Example: + * + * \code + * TDEABC::FormatFactory *factory = TDEABC::FormatFactory::self(); + * + * TQStringList list = factory->formats(); + * TQStringList::Iterator it; + * for ( it = list.begin(); it != list.end(); ++it ) { + * TDEABC::FormatPlugin *format = factory->format( (*it) ); + * // do something with format + * } + * \endcode + */ +class KABC_EXPORT FormatFactory +{ + public: + + /** + Destructor. + */ + ~FormatFactory(); + + /** + * Returns the global format factory. + */ + static FormatFactory *self(); + + /** + * Returns a pointer to a format object or a null pointer + * if format type doesn't exist. + * + * @param type The type of the format, returned by formats() + */ + FormatPlugin *format( const TQString &type ); + + /** + * Returns a list of all available format types. + */ + TQStringList formats(); + + /** + * Returns the info structure for a special type. + */ + FormatInfo *info( const TQString &type ); + + protected: + FormatFactory(); + + private: + KLibrary *openLibrary( const TQString& libName ); + + static FormatFactory *mSelf; + + TQDict<FormatInfo> mFormatList; +}; + +} +#endif diff --git a/tdeabc/formatplugin.h b/tdeabc/formatplugin.h new file mode 100644 index 000000000..c6fb59858 --- /dev/null +++ b/tdeabc/formatplugin.h @@ -0,0 +1,73 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_FORMATPLUGIN_H +#define KABC_FORMATPLUGIN_H + +#include <tqfile.h> + +#include "plugin.h" +#include "resource.h" + +namespace TDEABC { + +class AddressBook; +class Addressee; + +/** + * @short Base class for address book formats. + * + * This class provides an abstract interface for ResourceFile and + * ResourceDir formats. + * + * @internal + */ +class KABC_EXPORT FormatPlugin : public Plugin +{ +public: + + /** + * Load single addressee from file. + */ + virtual bool load( Addressee &, TQFile *file ) = 0; + + /** + * Load whole addressbook from file. + */ + virtual bool loadAll( AddressBook *, Resource *, TQFile *file ) = 0; + + /** + * Save a single Addressee to file. + */ + virtual void save( const Addressee &, TQFile *file ) = 0; + + /** + * Save whole addressbook to file. + */ + virtual void saveAll( AddressBook *, Resource *, TQFile *file ) = 0; + + /** + * Checks if given file contains the right format + */ + virtual bool checkFormat( TQFile *file ) const = 0; +}; + +} +#endif diff --git a/tdeabc/formats/CMakeLists.txt b/tdeabc/formats/CMakeLists.txt new file mode 100644 index 000000000..48fddc70c --- /dev/null +++ b/tdeabc/formats/CMakeLists.txt @@ -0,0 +1,47 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_BINARY_DIR}/tdeabc + ${CMAKE_SOURCE_DIR}/tdeabc + + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES binary.desktop DESTINATION ${DATA_INSTALL_DIR}/tdeabc/formats ) + + +##### tdeabcformat_binary ######################### + +set( target tdeabcformat_binary ) + +set( ${target}_SRCS + binaryformat.cpp +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdeabc-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeabc/formats/Makefile.am b/tdeabc/formats/Makefile.am new file mode 100644 index 000000000..e96ff8203 --- /dev/null +++ b/tdeabc/formats/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = -I$(top_srcdir)/tdeabc -I$(top_builddir)/tdeabc $(all_includes) + +kde_module_LTLIBRARIES = tdeabcformat_binary.la + +tdeabcformat_binary_la_SOURCES = binaryformat.cpp +tdeabcformat_binary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \ + -no-undefined +tdeabcformat_binary_la_LIBADD = $(LIB_TDEABC) $(LIB_QT) $(LIB_TDECORE) +tdeabcformat_binary_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + +# these are the headers for your project +noinst_HEADERS = binaryformat.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabcformat_binary.pot + +linkdir = $(kde_datadir)/tdeabc/formats +link_DATA = binary.desktop +EXTRA_DIST = $(link_DATA) diff --git a/tdeabc/formats/binary.desktop b/tdeabc/formats/binary.desktop new file mode 100644 index 000000000..5441ac23a --- /dev/null +++ b/tdeabc/formats/binary.desktop @@ -0,0 +1,89 @@ +[Misc] +Name=Binary +Name[af]=Binêre +Name[ar]=ثنائي +Name[az]=İcraçı +Name[be]=Двайковы +Name[bg]=Двоичен +Name[bn]=বাইনারি +Name[br]=Binarel +Name[bs]=Binarno +Name[ca]=Binari +Name[cs]=Binární +Name[csb]=Binarny +Name[cy]=Deuaidd +Name[da]=Binær +Name[de]=Binär +Name[el]=Δυαδικό +Name[eo]=Duuma +Name[es]=Binario +Name[et]=Binaar +Name[eu]=Bitarra +Name[fa]=دوگانی +Name[fi]=Binääri +Name[fr]=Binaire +Name[fy]=Binêr +Name[ga]=Dénártha +Name[gl]=Binário +Name[he]=בינרית +Name[hi]=द्विचर +Name[hr]=Binarno +Name[hsb]=Binarny +Name[hu]=Bináris +Name[id]=Biner +Name[is]=Tvíunda +Name[it]=Binario +Name[ja]=バイナリ +Name[ka]=ორობითი +Name[kk]=Бинарлық +Name[km]=គោលពីរ +Name[ko]=바이너리 +Name[lb]=Binär +Name[lt]=Dvejetainis +Name[lv]=Binārs +Name[mk]=Бинарен +Name[mn]=Бинар +Name[ms]=Binari +Name[mt]=Binarju +Name[nb]=Binær +Name[nds]=Bineer +Name[ne]=बाइनरी +Name[nl]=Binair +Name[nn]=Binær +Name[nso]=Tselapedi +Name[pa]=ਬਾਈਨਰੀ +Name[pl]=Binarny +Name[pt]=Binário +Name[pt_BR]=Binário +Name[ro]=Binar +Name[ru]=Двоичный +Name[rw]=Nyabibiri +Name[se]=Binára +Name[sk]=Binárny +Name[sl]=Dvojiško +Name[sq]=Binarë +Name[sr]=Бинарни +Name[sr@Latn]=Binarni +Name[ss]=Lokuhamab ngakubili +Name[sv]=Binär +Name[ta]=இருமம் +Name[te]=ద్వియాశం +Name[tg]=Дутартиба +Name[th]=ไบนารี +Name[tr]=İkili +Name[tt]=Binar +Name[uk]=Двійковий +Name[uz]=Binar +Name[uz@cyrillic]=Бинар +Name[ven]=Zwivhili +Name[vi]=Nhị phân +Name[wa]=Binaire +Name[xh]=Ephindwe kabini +Name[zh_CN]=二进制 +Name[zh_HK]=二進位 +Name[zh_TW]=二進位 +Name[zu]=Okuhambisana ngambili + +[Plugin] +Type=binary +X-TDE-Library=tdeabcformat_binary diff --git a/tdeabc/formats/binaryformat.cpp b/tdeabc/formats/binaryformat.cpp new file mode 100644 index 000000000..15dbec8a8 --- /dev/null +++ b/tdeabc/formats/binaryformat.cpp @@ -0,0 +1,221 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqdatastream.h> +#include <tqimage.h> + +#include <kdebug.h> +#include <tdelocale.h> +#include <kstandarddirs.h> + +#include "addressbook.h" +#include "addressee.h" +#include "picture.h" +#include "sound.h" + +#include "binaryformat.h" + +#define BINARY_FORMAT_VERSION 1 + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT FormatPlugin *format() + { + return new BinaryFormat; + } +} + +bool BinaryFormat::load( Addressee &addressee, TQFile *file ) +{ + kdDebug(5700) << "BinaryFormat::load()" << endl; + TQDataStream stream( file ); + + if ( !checkHeader( stream ) ) + return false; + + loadAddressee( addressee, stream ); + + return true; +} + +bool BinaryFormat::loadAll( AddressBook*, Resource *resource, TQFile *file ) +{ + kdDebug(5700) << "BinaryFormat::loadAll()" << endl; + + TQDataStream stream( file ); + + if ( !checkHeader( stream ) ) + return false; + + TQ_UINT32 entries; + + stream >> entries; + + for ( uint i = 0; i < entries; ++i ) { + Addressee addressee; + loadAddressee( addressee, stream ); + addressee.setResource( resource ); + addressee.setChanged( false ); + resource->insertAddressee( addressee ); + } + + return true; +} + +void BinaryFormat::save( const Addressee &addressee, TQFile *file ) +{ + kdDebug(5700) << "BinaryFormat::save()" << endl; + + TQDataStream stream( file ); + + writeHeader( stream ); + + TQ_UINT32 entries = 1; + stream << entries; + saveAddressee( addressee, stream ); +} + +void BinaryFormat::saveAll( AddressBook*, Resource *resource, TQFile *file ) +{ + kdDebug(5700) << "BinaryFormat::saveAll()" << endl; + + TQ_UINT32 counter = 0; + TQDataStream stream( file ); + + writeHeader( stream ); + // set dummy number of entries + stream << counter; + + Resource::Iterator it; + for ( it = resource->begin(); it != resource->end(); ++it ) { + saveAddressee( (*it), stream ); + counter++; + (*it).setChanged( false ); + } + + // set real number of entries + stream.device()->at( 2 * sizeof( TQ_UINT32 ) ); + stream << counter; +} + +bool BinaryFormat::checkFormat( TQFile *file ) const +{ + kdDebug(5700) << "BinaryFormat::checkFormat()" << endl; + + TQDataStream stream( file ); + + return checkHeader( stream ); +} + +bool BinaryFormat::checkHeader( TQDataStream &stream ) const +{ + TQ_UINT32 magic, version; + + stream >> magic >> version; + + TQFile *file = dynamic_cast<TQFile*>( stream.device() ); + + if ( !file ) { + kdError() << i18n("Not a file?") << endl; + return false; + } + + if ( magic != 0x2e93e ) { + kdError() << TQString(i18n("File '%1' is not binary format.").arg( file->name() )) << endl; + return false; + } + + if ( version != BINARY_FORMAT_VERSION ) { + kdError() << TQString(i18n("File '%1' is the wrong version.").arg( file->name() )) << endl; + return false; + } + + return true; +} + +void BinaryFormat::writeHeader( TQDataStream &stream ) +{ + TQ_UINT32 magic, version; + + magic = 0x2e93e; + version = BINARY_FORMAT_VERSION; + + stream << magic << version; +} + +void BinaryFormat::loadAddressee( Addressee &addressee, TQDataStream &stream ) +{ + stream >> addressee; +/* + // load pictures + Picture photo = addressee.photo(); + Picture logo = addressee.logo(); + + if ( photo.isIntern() ) { + TQImage img; + if ( !img.load( locateLocal( "data", "tdeabc/photos/" ) + addressee.uid() ) ) + kdDebug(5700) << "No photo available for '" << addressee.uid() << "'." << endl; + + addressee.setPhoto( img ); + } + + if ( logo.isIntern() ) { + TQImage img; + if ( !img.load( locateLocal( "data", "tdeabc/logos/" ) + addressee.uid() ) ) + kdDebug(5700) << "No logo available for '" << addressee.uid() << "'." << endl; + + addressee.setLogo( img ); + } + + // load sound + // TODO: load sound data from file +*/ +} + +void BinaryFormat::saveAddressee( const Addressee &addressee, TQDataStream &stream ) +{ + stream << addressee; +/* + // load pictures + Picture photo = addressee.photo(); + Picture logo = addressee.logo(); + + if ( photo.isIntern() ) { + TQImage img = photo.data(); + TQString fileName = locateLocal( "data", "tdeabc/photos/" ) + addressee.uid(); + + if ( !img.save( fileName, "PNG" ) ) + kdDebug(5700) << "Unable to save photo for '" << addressee.uid() << "'." << endl; + } + + if ( logo.isIntern() ) { + TQImage img = logo.data(); + TQString fileName = locateLocal( "data", "tdeabc/logos/" ) + addressee.uid(); + + if ( !img.save( fileName, "PNG" ) ) + kdDebug(5700) << "Unable to save logo for '" << addressee.uid() << "'." << endl; + } + + // save sound + // TODO: save the sound data to file +*/ +} diff --git a/tdeabc/formats/binaryformat.h b/tdeabc/formats/binaryformat.h new file mode 100644 index 000000000..faf6c8e5a --- /dev/null +++ b/tdeabc/formats/binaryformat.h @@ -0,0 +1,69 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_BINARYFORMAT_H +#define KABC_BINARYFORMAT_H + +#include "formatplugin.h" + +namespace TDEABC { + +class AddressBook; +class Addressee; + +/** + @short binary file format for addressbook entries. +*/ +class BinaryFormat : public FormatPlugin +{ +public: + /** + * Load single addressee from file. + */ + bool load( Addressee &, TQFile *file ); + + /** + * Load whole addressee from file. + */ + bool loadAll( AddressBook *, Resource *, TQFile *file ); + + /** + * Save single addressee to file. + */ + void save( const Addressee &, TQFile *file ); + + /** + * Save all addressees to file. + */ + void saveAll( AddressBook *, Resource *, TQFile *file ); + + /** + * Check for valid format of a file. + */ + bool checkFormat( TQFile *file ) const; + +private: + void loadAddressee( Addressee &, TQDataStream & ); + void saveAddressee( const Addressee &, TQDataStream & ); + bool checkHeader( TQDataStream & ) const; + void writeHeader( TQDataStream & ); +}; + +} +#endif diff --git a/tdeabc/geo.cpp b/tdeabc/geo.cpp new file mode 100644 index 000000000..9883595a4 --- /dev/null +++ b/tdeabc/geo.cpp @@ -0,0 +1,109 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqdatastream.h> + +#include "geo.h" + +using namespace TDEABC; + +Geo::Geo() + : mLatitude( 91 ), mLongitude( 181 ), mValidLat( false ), mValidLong( false ) +{ +} + +Geo::Geo( float latitude, float longitude ) +{ + setLatitude( latitude ); + setLongitude( longitude ); +} + +void Geo::setLatitude( float latitude ) +{ + if ( latitude >= -90 && latitude <= 90 ) { + mLatitude = latitude; + mValidLat = true; + } else { + mLatitude = 91; + mValidLat = false; + } +} + +float Geo::latitude() const +{ + return mLatitude; +} + +void Geo::setLongitude( float longitude) +{ + if ( longitude >= -180 && longitude <= 180 ) { + mLongitude = longitude; + mValidLong = true; + } else { + mLongitude = 181; + mValidLong = false; + } +} + +float Geo::longitude() const +{ + return mLongitude; +} + +bool Geo::isValid() const +{ + return mValidLat && mValidLong; +} + +bool Geo::operator==( const Geo &g ) const +{ + if ( !g.isValid() && !isValid() ) return true; + if ( !g.isValid() || !isValid() ) return false; + if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return true; + return false; +} + +bool Geo::operator!=( const Geo &g ) const +{ + if ( !g.isValid() && !isValid() ) return false; + if ( !g.isValid() || !isValid() ) return true; + if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return false; + return true; +} + +TQString Geo::asString() const +{ + return "(" + TQString::number(mLatitude) + "," + TQString::number(mLongitude) + ")"; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Geo &geo ) +{ + return s << (float)geo.mLatitude << (float)geo.mLongitude; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Geo &geo ) +{ + s >> geo.mLatitude >> geo.mLongitude; + + geo.mValidLat = true; + geo.mValidLong = true; + + return s; +} diff --git a/tdeabc/geo.h b/tdeabc/geo.h new file mode 100644 index 000000000..55cf18680 --- /dev/null +++ b/tdeabc/geo.h @@ -0,0 +1,101 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_GEO_H +#define KABC_GEO_H + +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** + @short Geographic position + + This class represents a geographic position. +*/ +class KABC_EXPORT Geo +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Geo & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Geo & ); + + public: + /** + Construct invalid geographics position object. + */ + Geo(); + + /** + Construct geographics position object. + + @param latitude Geographical latitude + @param longitude Geographical longitude + */ + Geo( float latitude, float longitude ); + + /** + Sets the latitude. + */ + void setLatitude( float ); + + /** + Returns the latitude. + */ + float latitude() const; + + /** + Sets the longitude. + */ + void setLongitude( float ); + + /** + Returns the longitude. + */ + float longitude() const; + + /** + Returns, if this object contains a valid geographical position. + */ + bool isValid() const; + + bool operator==( const Geo & ) const; + bool operator!=( const Geo & ) const; + + /** + Returns string representation of geographical position. + */ + TQString asString() const; + + private: + float mLatitude; + float mLongitude; + + bool mValid; + bool mValidLat; + bool mValidLong; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Geo & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Geo & ); + +} + +#endif diff --git a/tdeabc/key.cpp b/tdeabc/key.cpp new file mode 100644 index 000000000..d4456f516 --- /dev/null +++ b/tdeabc/key.cpp @@ -0,0 +1,153 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdeapplication.h> +#include <tdelocale.h> + +#include "key.h" + +using namespace TDEABC; + +Key::Key( const TQString &text, int type ) + : mTextData( text ), mIsBinary( false ), mType( type ) +{ + mId = TDEApplication::randomString(8); +} + +Key::~Key() +{ +} + +bool Key::operator==( const Key &k ) const +{ + if ( mIsBinary != k.mIsBinary ) return false; + if ( mIsBinary ) + if ( mBinaryData != k.mBinaryData ) return false; + else + if ( mTextData != k.mTextData ) return false; + if ( mType != k.mType ) return false; + if ( mCustomTypeString != k.mCustomTypeString ) return false; + + return true; +} + +bool Key::operator!=( const Key &k ) const +{ + return !( k == *this ); +} + +void Key::setId( const TQString &id ) +{ + mId = id; +} + +TQString Key::id() const +{ + return mId; +} + +void Key::setBinaryData( const TQByteArray &binary ) +{ + mBinaryData = binary; + mIsBinary = true; +} + +TQByteArray Key::binaryData() const +{ + return mBinaryData; +} + +void Key::setTextData( const TQString &text ) +{ + mTextData = text; + mIsBinary = false; +} + +TQString Key::textData() const +{ + return mTextData; +} + +bool Key::isBinary() const +{ + return mIsBinary; +} + +void Key::setType( int type ) +{ + mType = type; +} + +void Key::setCustomTypeString( const TQString &custom ) +{ + mCustomTypeString = custom; +} + +int Key::type() const +{ + return mType; +} + +TQString Key::customTypeString() const +{ + return mCustomTypeString; +} + +Key::TypeList Key::typeList() +{ + TypeList list; + list << X509; + list << PGP; + list << Custom; + + return list; +} + +TQString Key::typeLabel( int type ) +{ + switch ( type ) { + case X509: + return i18n( "X509" ); + break; + case PGP: + return i18n( "PGP" ); + break; + case Custom: + return i18n( "Custom" ); + break; + default: + return i18n( "Unknown type" ); + break; + } +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Key &key ) +{ + return s << key.mId << key.mIsBinary << key.mTextData << key.mBinaryData << + key.mCustomTypeString << key.mType; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Key &key ) +{ + s >> key.mId >> key.mIsBinary >> key.mTextData >> key.mBinaryData >> + key.mCustomTypeString >> key.mType; + + return s; +} diff --git a/tdeabc/key.h b/tdeabc/key.h new file mode 100644 index 000000000..94d1a28b3 --- /dev/null +++ b/tdeabc/key.h @@ -0,0 +1,150 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_KEY_H +#define KABC_KEY_H + +#include <tqvaluelist.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** + * @short A class to store an encryption key. + */ +class KABC_EXPORT Key +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Key & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Key & ); + +public: + typedef TQValueList<Key> List; + typedef TQValueList<int> TypeList; + + /** + * Key types + * + * @li X509 - X509 key + * @li PGP - Pretty Good Privacy key + * @li Custom - Custom or IANA conform key + */ + enum Types { + X509, + PGP, + Custom + }; + + /** + * Constructor. + * + * @param text The text data. + * @param type The key type, see Types. + */ + Key( const TQString &text = TQString::null, int type = PGP ); + + /** + * Destructor. + */ + ~Key(); + + bool operator==( const Key & ) const; + bool operator!=( const Key & ) const; + + /** + * Sets the unique identifier. + */ + void setId( const TQString &id ); + + /** + * Returns the unique identifier. + */ + TQString id() const; + + /** + * Sets binary data. + */ + void setBinaryData( const TQByteArray &binary ); + + /** + * Returns the binary data. + */ + TQByteArray binaryData() const; + + /** + * Sets text data. + */ + void setTextData( const TQString &text ); + + /** + * Returns the text data. + */ + TQString textData() const; + + /** + * Returns whether the key contains binary or text data. + */ + bool isBinary() const; + + /** + * Sets the type, see Type. + */ + void setType( int type ); + + /** + * Sets custom type string. + */ + void setCustomTypeString( const TQString &custom ); + + /** + * Returns the type, see Type. + */ + int type() const; + + /** + * Returns the custom type string. + */ + TQString customTypeString() const; + + /** + * Returns a list of all available key types. + */ + static TypeList typeList(); + + /** + * Returns a translated label for a given key type. + */ + static TQString typeLabel( int type ); + +private: + TQByteArray mBinaryData; + TQString mId; + TQString mTextData; + TQString mCustomTypeString; + + int mIsBinary; + int mType; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Key & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Key & ); + +} +#endif diff --git a/tdeabc/ldapclient.cpp b/tdeabc/ldapclient.cpp new file mode 100644 index 000000000..31256f46f --- /dev/null +++ b/tdeabc/ldapclient.cpp @@ -0,0 +1,427 @@ +/* kldapclient.cpp - LDAP access + * Copyright (C) 2002 Klarälvdalens Datakonsult AB + * + * Author: Steffen Hansen <[email protected]> + * + * Ported to KABC by Daniel Molkentin <[email protected]> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + + +#include <tqfile.h> +#include <tqimage.h> +#include <tqlabel.h> +#include <tqpixmap.h> +#include <tqtextstream.h> +#include <tqurl.h> + +#include <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <kmdcodec.h> +#include <kprotocolinfo.h> + +#include "ldapclient.h" +#include "ldif.h" +#include "ldapurl.h" + +using namespace TDEABC; + +class LdapClient::LdapClientPrivate{ +public: + TQString bindDN; + TQString pwdBindDN; + LDIF ldif; +}; + +TQString LdapObject::toString() const +{ + TQString result = TQString::fromLatin1( "\ndn: %1\n" ).arg( dn ); + for ( LdapAttrMap::ConstIterator it = attrs.begin(); it != attrs.end(); ++it ) { + TQString attr = it.key(); + for ( LdapAttrValue::ConstIterator it2 = (*it).begin(); it2 != (*it).end(); ++it2 ) { + result += TQString::fromUtf8( LDIF::assembleLine( attr, *it2, 76 ) ) + "\n"; + } + } + + return result; +} + +void LdapObject::clear() +{ + dn = TQString::null; + attrs.clear(); +} + +void LdapObject::assign( const LdapObject& that ) +{ + if ( &that != this ) { + dn = that.dn; + attrs = that.attrs; + client = that.client; + } +} + +LdapClient::LdapClient( TQObject* parent, const char* name ) + : TQObject( parent, name ), mJob( 0 ), mActive( false ) +{ + d = new LdapClientPrivate; +} + +LdapClient::~LdapClient() +{ + cancelQuery(); + delete d; d = 0; +} + +void LdapClient::setHost( const TQString& host ) +{ + mHost = host; +} + +void LdapClient::setPort( const TQString& port ) +{ + mPort = port; +} + +void LdapClient::setBase( const TQString& base ) +{ + mBase = base; +} + +void LdapClient::setBindDN( const TQString& bindDN ) +{ + d->bindDN = bindDN; +} + +void LdapClient::setPwdBindDN( const TQString& pwdBindDN ) +{ + d->pwdBindDN = pwdBindDN; +} + +void LdapClient::setAttrs( const TQStringList& attrs ) +{ + mAttrs = attrs; +} + +void LdapClient::startQuery( const TQString& filter ) +{ + cancelQuery(); + LDAPUrl url; + + url.setProtocol( "ldap" ); + url.setUser( d->bindDN ); + url.setPass( d->pwdBindDN ); + url.setHost( mHost ); + url.setPort( mPort.toUInt() ); + url.setDn( mBase ); + url.setAttributes( mAttrs ); + url.setScope( mScope == "one" ? LDAPUrl::One : LDAPUrl::Sub ); + url.setFilter( "("+filter+")" ); + + kdDebug(5700) << "Doing query: " << url.prettyURL() << endl; + + startParseLDIF(); + mActive = true; + mJob = TDEIO::get( url, false, false ); + connect( mJob, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), + this, TQT_SLOT( slotData( TDEIO::Job*, const TQByteArray& ) ) ); + connect( mJob, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ), + this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) ); + connect( mJob, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( slotDone() ) ); +} + +void LdapClient::cancelQuery() +{ + if ( mJob ) { + mJob->kill(); + mJob = 0; + } + + mActive = false; +} + +void LdapClient::slotData( TDEIO::Job*, const TQByteArray& data ) +{ +#ifndef NDEBUG // don't create the QString +// TQString str( data ); +// kdDebug(5700) << "LdapClient: Got \"" << str << "\"\n"; +#endif + parseLDIF( data ); +} + +void LdapClient::slotInfoMessage( TDEIO::Job*, const TQString & ) +{ + //tqDebug("Job said \"%s\"", info.latin1()); +} + +void LdapClient::slotDone() +{ + endParseLDIF(); + mActive = false; +#if 0 + for ( TQValueList<LdapObject>::Iterator it = mObjects.begin(); it != mObjects.end(); ++it ) { + tqDebug( (*it).toString().latin1() ); + } +#endif + int err = mJob->error(); + if ( err && err != TDEIO::ERR_USER_CANCELED ) { + emit error( TDEIO::buildErrorString( err, TQString("%1:%2").arg( mHost ).arg( mPort ) ) ); + } + emit done(); +} + +void LdapClient::startParseLDIF() +{ + mCurrentObject.clear(); + mLastAttrName = 0; + mLastAttrValue = 0; + mIsBase64 = false; + d->ldif.startParsing(); +} + +void LdapClient::endParseLDIF() +{ +} + +void LdapClient::parseLDIF( const TQByteArray& data ) +{ + if ( data.size() ) { + d->ldif.setLDIF( data ); + } else { + d->ldif.endLDIF(); + } + + LDIF::ParseVal ret; + TQString name; + do { + ret = d->ldif.nextItem(); + switch ( ret ) { + case LDIF::Item: + { + name = d->ldif.attr(); + // Must make a copy! TQByteArray is explicitely shared + TQByteArray value = d->ldif.val().copy(); + mCurrentObject.attrs[ name ].append( value ); + break; + } + case LDIF::EndEntry: + mCurrentObject.dn = d->ldif.dn(); + mCurrentObject.client = this; + emit result( mCurrentObject ); + mCurrentObject.clear(); + break; + default: + break; + } + } while ( ret != LDIF::MoreData ); +} + +TQString LdapClient::bindDN() const +{ + return d->bindDN; +} + +TQString LdapClient::pwdBindDN() const +{ + return d->pwdBindDN; +} + +LdapSearch::LdapSearch() + : mActiveClients( 0 ), mNoLDAPLookup( false ) +{ + if ( !KProtocolInfo::isKnownProtocol( KURL("ldap://localhost") ) ) { + mNoLDAPLookup = true; + return; + } + + // stolen from KAddressBook + TDEConfig config( "kabldaprc", true ); + config.setGroup( "LDAP" ); + int numHosts = config.readUnsignedNumEntry( "NumSelectedHosts"); + if ( !numHosts ) { + mNoLDAPLookup = true; + return; + } else { + for ( int j = 0; j < numHosts; j++ ) { + LdapClient* ldapClient = new LdapClient( this ); + + TQString host = config.readEntry( TQString( "SelectedHost%1" ).arg( j ), "" ).stripWhiteSpace(); + if ( !host.isEmpty() ) + ldapClient->setHost( host ); + + TQString port = TQString::number( config.readUnsignedNumEntry( TQString( "SelectedPort%1" ).arg( j ) ) ); + if ( !port.isEmpty() ) + ldapClient->setPort( port ); + + TQString base = config.readEntry( TQString( "SelectedBase%1" ).arg( j ), "" ).stripWhiteSpace(); + if ( !base.isEmpty() ) + ldapClient->setBase( base ); + + TQString bindDN = config.readEntry( TQString( "SelectedBind%1" ).arg( j ) ).stripWhiteSpace(); + if ( !bindDN.isEmpty() ) + ldapClient->setBindDN( bindDN ); + + TQString pwdBindDN = config.readEntry( TQString( "SelectedPwdBind%1" ).arg( j ) ); + if ( !pwdBindDN.isEmpty() ) + ldapClient->setPwdBindDN( pwdBindDN ); + + TQStringList attrs; + attrs << "cn" << "mail" << "givenname" << "sn"; + ldapClient->setAttrs( attrs ); + + connect( ldapClient, TQT_SIGNAL( result( const TDEABC::LdapObject& ) ), + this, TQT_SLOT( slotLDAPResult( const TDEABC::LdapObject& ) ) ); + connect( ldapClient, TQT_SIGNAL( done() ), + this, TQT_SLOT( slotLDAPDone() ) ); + connect( ldapClient, TQT_SIGNAL( error( const TQString& ) ), + this, TQT_SLOT( slotLDAPError( const TQString& ) ) ); + + mClients.append( ldapClient ); + } + } + + connect( &mDataTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotDataTimer() ) ); +} + +void LdapSearch::startSearch( const TQString& txt ) +{ + if ( mNoLDAPLookup ) + return; + + cancelSearch(); + + int pos = txt.find( '\"' ); + if( pos >= 0 ) + { + ++pos; + int pos2 = txt.find( '\"', pos ); + if( pos2 >= 0 ) + mSearchText = txt.mid( pos , pos2 - pos ); + else + mSearchText = txt.mid( pos ); + } else + mSearchText = txt; + + TQString filter = TQString( "|(cn=%1*)(mail=%2*)(givenName=%3*)(sn=%4*)" ) + .arg( mSearchText ).arg( mSearchText ).arg( mSearchText ).arg( mSearchText ); + + TQValueList< LdapClient* >::Iterator it; + for ( it = mClients.begin(); it != mClients.end(); ++it ) { + (*it)->startQuery( filter ); + ++mActiveClients; + } +} + +void LdapSearch::cancelSearch() +{ + TQValueList< LdapClient* >::Iterator it; + for ( it = mClients.begin(); it != mClients.end(); ++it ) + (*it)->cancelQuery(); + + mActiveClients = 0; + mResults.clear(); +} + +void LdapSearch::slotLDAPResult( const TDEABC::LdapObject& obj ) +{ + mResults.append( obj ); + if ( !mDataTimer.isActive() ) + mDataTimer.start( 500, true ); +} + +void LdapSearch::slotLDAPError( const TQString& ) +{ + slotLDAPDone(); +} + +void LdapSearch::slotLDAPDone() +{ + if ( --mActiveClients > 0 ) + return; + + finish(); +} + +void LdapSearch::slotDataTimer() +{ + TQStringList lst; + LdapResultList reslist; + makeSearchData( lst, reslist ); + if ( !lst.isEmpty() ) + emit searchData( lst ); + if ( !reslist.isEmpty() ) + emit searchData( reslist ); +} + +void LdapSearch::finish() +{ + mDataTimer.stop(); + + slotDataTimer(); // emit final bunch of data + emit searchDone(); +} + +void LdapSearch::makeSearchData( TQStringList& ret, LdapResultList& resList ) +{ + TQString search_text_upper = mSearchText.upper(); + + TQValueList< TDEABC::LdapObject >::ConstIterator it1; + for ( it1 = mResults.begin(); it1 != mResults.end(); ++it1 ) { + TQString name, mail, givenname, sn; + + LdapAttrMap::ConstIterator it2; + for ( it2 = (*it1).attrs.begin(); it2 != (*it1).attrs.end(); ++it2 ) { + TQString tmp = TQString::fromUtf8( (*it2).first(), (*it2).first().size() ); + if ( it2.key() == "cn" ) + name = tmp; // TODO loop? + else if( it2.key() == "mail" ) + mail = tmp; + else if( it2.key() == "givenName" ) + givenname = tmp; + else if( it2.key() == "sn" ) + sn = tmp; + } + + if( mail.isEmpty()) + continue; // nothing, bad entry + else if ( name.isEmpty() ) + ret.append( mail ); + else { + kdDebug(5700) << "<" << name << "><" << mail << ">" << endl; + ret.append( TQString( "%1 <%2>" ).arg( name ).arg( mail ) ); + } + + LdapResult sr; + sr.clientNumber = mClients.findIndex( (*it1).client ); + sr.name = name; + sr.email = mail; + resList.append( sr ); + } + + mResults.clear(); +} + +bool LdapSearch::isAvailable() const +{ + return !mNoLDAPLookup; +} + + + +#include "ldapclient.moc" diff --git a/tdeabc/ldapclient.h b/tdeabc/ldapclient.h new file mode 100644 index 000000000..a4a5747a6 --- /dev/null +++ b/tdeabc/ldapclient.h @@ -0,0 +1,248 @@ +/* kldapclient.h - LDAP access + * Copyright (C) 2002 Klarälvdalens Datakonsult AB + * + * Author: Steffen Hansen <[email protected]> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#ifndef KABC_LDAPCLIENT_H +#define KABC_LDAPCLIENT_H + + +#include <tqobject.h> +#include <tqstring.h> +#include <tqcstring.h> +#include <tqstringlist.h> +#include <tqmemarray.h> +#include <tqguardedptr.h> +#include <tqtimer.h> + +#include <tdeio/job.h> + +namespace TDEABC { + +class LdapClient; +typedef TQValueList<TQByteArray> LdapAttrValue; +typedef TQMap<TQString,LdapAttrValue > LdapAttrMap; + +/** + * This class is internal. Binary compatibiliy might be broken any time + * without notification. Do not use it. + * + * We mean it! + * + */ +class KABC_EXPORT LdapObject +{ + public: + LdapObject() + : dn( TQString::null ), client( 0 ) {} + explicit LdapObject( const TQString& _dn, LdapClient* _cl ) : dn( _dn ), client( _cl ) {} + LdapObject( const LdapObject& that ) { assign( that ); } + + LdapObject& operator=( const LdapObject& that ) + { + assign( that ); + return *this; + } + + TQString toString() const; + + void clear(); + + TQString dn; + LdapAttrMap attrs; + LdapClient* client; + + protected: + void assign( const LdapObject& that ); + + private: + //class LdapObjectPrivate* d; +}; + +/** + * This class is internal. Binary compatibiliy might be broken any time + * without notification. Do not use it. + * + * We mean it! + * + */ +class KABC_EXPORT LdapClient : public TQObject +{ + Q_OBJECT + + public: + LdapClient( TQObject* parent = 0, const char* name = 0 ); + virtual ~LdapClient(); + + /*! returns true if there is a query running */ + bool isActive() const { return mActive; } + + signals: + /*! Emitted when the query is done */ + void done(); + + /*! Emitted in case of error */ + void error( const TQString& ); + + /*! Emitted once for each object returned + * from the query + */ + void result( const TDEABC::LdapObject& ); + + public slots: + /*! + * Set the name or IP of the LDAP server + */ + void setHost( const TQString& host ); + TQString host() const { return mHost; } + + /*! + * Set the port of the LDAP server + * if using a nonstandard port + */ + void setPort( const TQString& port ); + TQString port() const { return mPort; } + + /*! + * Set the base DN + */ + void setBase( const TQString& base ); + TQString base() const { return mBase; } + + /*! + * Set the bind DN + */ + void setBindDN( const TQString& bindDN ); + TQString bindDN() const; + + /*! + * Set the bind password DN + */ + void setPwdBindDN( const TQString& pwdBindDN ); + TQString pwdBindDN() const; + + /*! Set the attributes that should be + * returned, or an empty list if + * all attributes are wanted + */ + void setAttrs( const TQStringList& attrs ); + TQStringList attrs() const { return mAttrs; } + + void setScope( const TQString scope ) { mScope = scope; } + + /*! + * Start the query with filter filter + */ + void startQuery( const TQString& filter ); + + /*! + * Abort a running query + */ + void cancelQuery(); + + protected slots: + void slotData( TDEIO::Job*, const TQByteArray &data ); + void slotInfoMessage( TDEIO::Job*, const TQString &info ); + void slotDone(); + + protected: + void startParseLDIF(); + void parseLDIF( const TQByteArray& data ); + void endParseLDIF(); + + TQString mHost; + TQString mPort; + TQString mBase; + TQString mScope; + TQStringList mAttrs; + + TQGuardedPtr<TDEIO::SimpleJob> mJob; + bool mActive; + + LdapObject mCurrentObject; + TQCString mBuf; + TQCString mLastAttrName; + TQCString mLastAttrValue; + bool mIsBase64; + + private: + class LdapClientPrivate; + LdapClientPrivate* d; +}; + +/** + * Structure describing one result returned by a LDAP query + */ +struct LdapResult { + TQString name; ///< full name + TQString email; ///< email + int clientNumber; ///< for sorting +}; +typedef TQValueList<LdapResult> LdapResultList; + + +/** + * This class is internal. Binary compatibiliy might be broken any time + * without notification. Do not use it. + * + * We mean it! + * + */ +class KABC_EXPORT LdapSearch : public TQObject +{ + Q_OBJECT + + public: + LdapSearch(); + + void startSearch( const TQString& txt ); + void cancelSearch(); + bool isAvailable() const; + + signals: + /// Results, assembled as "Full Name <email>" + /// (This signal can be emitted many times) + void searchData( const TQStringList& ); + /// Another form for the results, with separate fields + /// (This signal can be emitted many times) + void searchData( const TDEABC::LdapResultList& ); + void searchDone(); + + private slots: + void slotLDAPResult( const TDEABC::LdapObject& ); + void slotLDAPError( const TQString& ); + void slotLDAPDone(); + void slotDataTimer(); + + private: + void finish(); + void makeSearchData( TQStringList& ret, LdapResultList& resList ); + TQValueList< LdapClient* > mClients; + TQString mSearchText; + TQTimer mDataTimer; + int mActiveClients; + bool mNoLDAPLookup; + TQValueList< LdapObject > mResults; + + private: + class LdapSearchPrivate* d; +}; + +} +#endif // KABC_LDAPCLIENT_H diff --git a/tdeabc/ldapconfigwidget.cpp b/tdeabc/ldapconfigwidget.cpp new file mode 100644 index 000000000..6e339cb2c --- /dev/null +++ b/tdeabc/ldapconfigwidget.cpp @@ -0,0 +1,626 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#include <tqapplication.h> + +#include <tqobjectlist.h> +#include <tqcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqspinbox.h> +#include <tqvgroupbox.h> +#include <tqhbuttongroup.h> +#include <tqradiobutton.h> + +#include <tdemessagebox.h> +#include <tdeaccelmanager.h> +#include <kdialogbase.h> +#include <tdelocale.h> +#include <klineedit.h> +#include <kcombobox.h> +#include <kprogress.h> + +#include <kdebug.h> + +#include "ldapconfigwidget.h" +#include "ldapconfigwidget.moc" + +using namespace TDEABC; + +LdapConfigWidget::LdapConfigWidget( TQWidget* parent, + const char* name, WFlags fl ) : TQWidget( parent, name, fl ) +{ + mProg = 0; + mFlags = 0; + mainLayout = new TQGridLayout( this, 12, 4, 0, + KDialog::spacingHint() ); +} + +LdapConfigWidget::LdapConfigWidget( int flags, TQWidget* parent, + const char* name, WFlags fl ) : TQWidget( parent, name, fl ) +{ + mFlags = flags; + mProg = 0; + mainLayout = new TQGridLayout( this, 12, 4, 0, + KDialog::spacingHint() ); + initWidget(); +} + +LdapConfigWidget::~LdapConfigWidget() +{ +} + +void LdapConfigWidget::initWidget() +{ + TQLabel *label; + + mUser = mPassword = mHost = mDn = mBindDN = mRealm = mFilter = 0; + mPort = mVer = mTimeLimit = mSizeLimit = 0; + mAnonymous = mSimple = mSASL = mSecNO = mSecTLS = mSecSSL = 0; + mEditButton = mQueryMech = 0; + mMech = 0; + int row = 0; + int col; + + if ( mFlags & W_USER ) { + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this, "kcfg_ldapuser" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mUser, row, row, 1, 3 ); + row++; + } + + if ( mFlags & W_BINDDN ) { + label = new TQLabel( i18n( "Bind DN:" ), this ); + mBindDN = new KLineEdit( this, "kcfg_ldapbinddn" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mBindDN, row, row, 1, 3 ); + row++; + } + + if ( mFlags & W_REALM ) { + label = new TQLabel( i18n( "Realm:" ), this ); + mRealm = new KLineEdit( this, "kcfg_ldaprealm" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mRealm, row, row, 1, 3 ); + row++; + } + + if ( mFlags & W_PASS ) { + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this, "kcfg_ldappassword" ); + mPassword->setEchoMode( KLineEdit::Password ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mPassword, row, row, 1, 3 ); + row++; + } + + if ( mFlags & W_HOST ) { + label = new TQLabel( i18n( "Host:" ), this ); + mHost = new KLineEdit( this, "kcfg_ldaphost" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mHost, row, row, 1, 3 ); + row++; + } + + col = 0; + if ( mFlags & W_PORT ) { + label = new TQLabel( i18n( "Port:" ), this ); + mPort = new TQSpinBox( 0, 65535, 1, this, "kcfg_ldapport" ); + mPort->setSizePolicy( TQSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Preferred ) ); + mPort->setValue( 389 ); + + mainLayout->addWidget( label, row, col ); + mainLayout->addWidget( mPort, row, col+1 ); + col += 2; + } + + if ( mFlags & W_VER ) { + label = new TQLabel( i18n( "LDAP version:" ), this ); + mVer = new TQSpinBox( 2, 3, 1, this, "kcfg_ldapver" ); + mVer->setSizePolicy( TQSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Preferred ) ); + mVer->setValue( 3 ); + mainLayout->addWidget( label, row, col ); + mainLayout->addWidget( mVer, row, col+1 ); + } + if ( mFlags & ( W_PORT | W_VER ) ) row++; + + col = 0; + if ( mFlags & W_SIZELIMIT ) { + label = new TQLabel( i18n( "Size limit:" ), this ); + mSizeLimit = new TQSpinBox( 0, 9999999, 1, this, "kcfg_ldapsizelimit" ); + mSizeLimit->setSizePolicy( TQSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Preferred ) ); + mSizeLimit->setValue( 0 ); + mSizeLimit->setSpecialValueText( i18n("Default") ); + mainLayout->addWidget( label, row, col ); + mainLayout->addWidget( mSizeLimit, row, col+1 ); + col += 2; + } + + if ( mFlags & W_TIMELIMIT ) { + label = new TQLabel( i18n( "Time limit:" ), this ); + mTimeLimit = new TQSpinBox( 0, 9999999, 1, this, "kcfg_ldaptimelimit" ); + mTimeLimit->setSizePolicy( TQSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Preferred ) ); + mTimeLimit->setValue( 0 ); + mTimeLimit->setSuffix( i18n(" sec") ); + mTimeLimit->setSpecialValueText( i18n("Default") ); + mainLayout->addWidget( label, row, col ); + mainLayout->addWidget( mTimeLimit, row, col+1 ); + } + if ( mFlags & ( W_SIZELIMIT | W_TIMELIMIT ) ) row++; + + if ( mFlags & W_DN ) { + label = new TQLabel( i18n( "Distinguished Name", "DN:" ), this ); + mDn = new KLineEdit( this, "kcfg_ldapdn" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mDn, row, row, 1, 1 ); + //without host query doesn't make sense + if ( mHost ) { + TQPushButton *dnquery = new TQPushButton( i18n( "Query Server" ), this ); + connect( dnquery, TQT_SIGNAL( clicked() ), TQT_SLOT( mQueryDNClicked() ) ); + mainLayout->addMultiCellWidget( dnquery, row, row, 2, 3 ); + } + row++; + } + + if ( mFlags & W_FILTER ) { + label = new TQLabel( i18n( "Filter:" ), this ); + mFilter = new KLineEdit( this, "kcfg_ldapfilter" ); + + mainLayout->addWidget( label, row, 0 ); + mainLayout->addMultiCellWidget( mFilter, row, row, 1, 3 ); + row++; + } + + if ( mFlags & W_SECBOX ) { + TQHButtonGroup *btgroup = new TQHButtonGroup( i18n( "Security" ), this ); + mSecNO = new TQRadioButton( i18n( "No" ), btgroup, "kcfg_ldapnosec" ); + mSecTLS = new TQRadioButton( i18n( "TLS" ), btgroup, "kcfg_ldaptls" ); + mSecSSL = new TQRadioButton( i18n( "SSL" ), btgroup, "kcfg_ldapssl" ); + mainLayout->addMultiCellWidget( btgroup, row, row, 0, 3 ); + + connect( mSecNO, TQT_SIGNAL( clicked() ), TQT_SLOT( setLDAPPort() ) ); + connect( mSecTLS, TQT_SIGNAL( clicked() ), TQT_SLOT( setLDAPPort() ) ); + connect( mSecSSL, TQT_SIGNAL( clicked() ), TQT_SLOT( setLDAPSPort( ) ) ); + + mSecNO->setChecked( true ); + row++; + } + + if ( mFlags & W_AUTHBOX ) { + + TQButtonGroup *authbox = + new TQButtonGroup( 3, Qt::Horizontal, i18n( "Authentication" ), this ); + + mAnonymous = new TQRadioButton( i18n( "Anonymous" ), authbox, "kcfg_ldapanon" ); + mSimple = new TQRadioButton( i18n( "Simple" ), authbox, "kcfg_ldapsimple" ); + mSASL = new TQRadioButton( i18n( "SASL" ), authbox, "kcfg_ldapsasl" ); + + label = new TQLabel( i18n( "SASL mechanism:" ), authbox ); + mMech = new KComboBox( false, authbox, "kcfg_ldapsaslmech" ); + mMech->setEditable( true ); + mMech->insertItem( "DIGEST-MD5" ); + mMech->insertItem( "GSSAPI" ); + mMech->insertItem( "PLAIN" ); + + //without host query doesn't make sense + if ( mHost ) { + mQueryMech = new TQPushButton( i18n( "Query Server" ), authbox ); + connect( mQueryMech, TQT_SIGNAL( clicked() ), TQT_SLOT( mQueryMechClicked() ) ); + } + + mainLayout->addMultiCellWidget( authbox, row, row+1, 0, 3 ); + + connect( mAnonymous, TQT_SIGNAL( stateChanged(int) ), TQT_SLOT( setAnonymous(int) ) ); + connect( mSimple, TQT_SIGNAL( stateChanged(int) ), TQT_SLOT( setSimple(int) ) ); + connect( mSASL, TQT_SIGNAL( stateChanged(int) ), TQT_SLOT( setSASL(int) ) ); + + mAnonymous->setChecked( true ); + } + +} + +void LdapConfigWidget::loadData( TDEIO::Job*, const TQByteArray& d ) +{ + LDIF::ParseVal ret; + + if ( d.size() ) { + mLdif.setLDIF( d ); + } else { + mLdif.endLDIF(); + } + do { + ret = mLdif.nextItem(); + if ( ret == LDIF::Item && mLdif.attr().lower() == mAttr ) { + mProg->progressBar()->advance( 1 ); + mQResult.push_back( TQString::fromUtf8( mLdif.val(), mLdif.val().size() ) ); + } + } while ( ret != LDIF::MoreData ); +} + +void LdapConfigWidget::loadResult( TDEIO::Job* job) +{ + int error = job->error(); + if ( error && error != TDEIO::ERR_USER_CANCELED ) + mErrorMsg = job->errorString(); + else + mErrorMsg = ""; + + mCancelled = false; + mProg->close(); +} + +void LdapConfigWidget::sendQuery() +{ + LDAPUrl _url; + + mQResult.clear(); + mCancelled = true; + + _url.setProtocol( ( mSecSSL && mSecSSL->isChecked() ) ? "ldaps" : "ldap" ); + if ( mHost ) _url.setHost( mHost->text() ); + if ( mPort ) _url.setPort( mPort->value() ); + _url.setDn( "" ); + _url.setAttributes( mAttr ); + _url.setScope( LDAPUrl::Base ); + if ( mVer ) _url.setExtension( "x-ver", TQString::number( mVer->value() ) ); + if ( mSecTLS && mSecTLS->isChecked() ) _url.setExtension( "x-tls", "" ); + + kdDebug(5700) << "sendQuery url: " << _url.prettyURL() << endl; + mLdif.startParsing(); + TDEIO::Job *job = TDEIO::get( _url, true, false ); + job->addMetaData("no-auth-prompt","true"); + connect( job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), + this, TQT_SLOT( loadData( TDEIO::Job*, const TQByteArray& ) ) ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( loadResult( TDEIO::Job* ) ) ); + + if ( mProg == NULL ) + mProg = new KProgressDialog( this, 0, i18n("LDAP Query"), _url.prettyURL(), true ); + else + mProg->setLabel( _url.prettyURL() ); + mProg->progressBar()->setValue( 0 ); + mProg->progressBar()->setTotalSteps( 1 ); + mProg->exec(); + if ( mCancelled ) { + kdDebug(5700) << "query cancelled!" << endl; + job->kill( true ); + } else { + if ( !mErrorMsg.isEmpty() ) KMessageBox::error( this, mErrorMsg ); + } +} + +void LdapConfigWidget::mQueryMechClicked() +{ + mAttr = "supportedsaslmechanisms"; + sendQuery(); + if ( !mQResult.isEmpty() ) { + mQResult.sort(); + mMech->clear(); + mMech->insertStringList( mQResult ); + } +} + +void LdapConfigWidget::mQueryDNClicked() +{ + mAttr = "namingcontexts"; + sendQuery(); + if ( !mQResult.isEmpty() ) mDn->setText( mQResult.first() ); +} + +void LdapConfigWidget::setAnonymous( int state ) +{ + if ( state == TQButton::Off ) return; + if ( mUser ) mUser->setEnabled(false); + if ( mPassword ) mPassword->setEnabled(false); + if ( mBindDN ) mBindDN->setEnabled(false); + if ( mRealm ) mRealm->setEnabled(false); + if ( mMech ) mMech->setEnabled(false); + if ( mQueryMech ) mQueryMech->setEnabled(false); +} + +void LdapConfigWidget::setSimple( int state ) +{ + if ( state == TQButton::Off ) return; + if ( mUser ) mUser->setEnabled(true); + if ( mPassword ) mPassword->setEnabled(true); + if ( mBindDN ) mBindDN->setEnabled(false); + if ( mRealm ) mRealm->setEnabled(false); + if ( mMech ) mMech->setEnabled(false); + if ( mQueryMech ) mQueryMech->setEnabled(false); +} + +void LdapConfigWidget::setSASL( int state ) +{ + if ( state == TQButton::Off ) return; + if ( mUser ) mUser->setEnabled(true); + if ( mPassword ) mPassword->setEnabled(true); + if ( mBindDN ) mBindDN->setEnabled(true); + if ( mRealm ) mRealm->setEnabled(true); + if ( mMech ) mMech->setEnabled(true); + if ( mQueryMech ) mQueryMech->setEnabled(true); +} + +void LdapConfigWidget::setLDAPPort() +{ + mPort->setValue( 389 ); +} + +void LdapConfigWidget::setLDAPSPort() +{ + mPort->setValue( 636 ); +} + + +LDAPUrl LdapConfigWidget::url() const +{ + LDAPUrl _url; + if ( mSecSSL && mSecSSL->isChecked() ) + _url.setProtocol( "ldaps" ); + else + _url.setProtocol( "ldap" ); + + if ( mUser ) _url.setUser( mUser->text() ); + if ( mPassword ) _url.setPass( mPassword->text() ); + if ( mHost ) _url.setHost( mHost->text() ); + if ( mPort ) _url.setPort( mPort->value() ); + if ( mDn ) _url.setDn( mDn->text() ); + if ( mVer ) _url.setExtension( "x-ver", TQString::number( mVer->value() ) ); + if ( mSizeLimit && mSizeLimit->value() != 0 ) + _url.setExtension( "x-sizelimit", TQString::number( mSizeLimit->value() ) ); + if ( mTimeLimit && mTimeLimit->value() != 0 ) + _url.setExtension( "x-timelimit", TQString::number( mTimeLimit->value() ) ); + if ( mSecTLS && mSecTLS->isChecked() ) _url.setExtension( "x-tls","" ); + if ( mFilter && !mFilter->text().isEmpty() ) + _url.setFilter( mFilter->text() ); + if ( mSASL && mSASL->isChecked() ) { + _url.setExtension( "x-sasl", "" ); + _url.setExtension( "x-mech", mMech->currentText() ); + if ( mBindDN && !mBindDN->text().isEmpty() ) + _url.setExtension( "bindname", mBindDN->text() ); + if ( mRealm && !mRealm->text().isEmpty() ) + _url.setExtension( "x-realm", mRealm->text() ); + } + return ( _url ); +} + +void LdapConfigWidget::setUser( const TQString &user ) +{ + if ( mUser ) mUser->setText( user ); +} + +TQString LdapConfigWidget::user() const +{ + return ( mUser ? mUser->text() : TQString::null ); +} + +void LdapConfigWidget::setPassword( const TQString &password ) +{ + if ( mPassword ) mPassword->setText( password ); +} + +TQString LdapConfigWidget::password() const +{ + return ( mPassword ? mPassword->text() : TQString::null ); +} + +void LdapConfigWidget::setBindDN( const TQString &binddn ) +{ + if ( mBindDN ) mBindDN->setText( binddn ); +} + +TQString LdapConfigWidget::bindDN() const +{ + return ( mBindDN ? mBindDN->text() : TQString::null ); +} + +void LdapConfigWidget::setRealm( const TQString &realm ) +{ + if ( mRealm ) mRealm->setText( realm ); +} + +TQString LdapConfigWidget::realm() const +{ + return ( mRealm ? mRealm->text() : TQString::null ); +} + +void LdapConfigWidget::setHost( const TQString &host ) +{ + if ( mHost ) mHost->setText( host ); +} + +TQString LdapConfigWidget::host() const +{ + return ( mHost ? mHost->text() : TQString::null ); +} + +void LdapConfigWidget::setPort( int port ) +{ + if ( mPort ) mPort->setValue( port ); +} + +int LdapConfigWidget::port() const +{ + return ( mPort ? mPort->value() : 389 ); +} + +void LdapConfigWidget::setVer( int ver ) +{ + if ( mVer ) mVer->setValue( ver ); +} + +int LdapConfigWidget::ver() const +{ + return ( mVer ? mVer->value() : 3 ); +} + +void LdapConfigWidget::setDn( const TQString &dn ) +{ + if ( mDn ) mDn->setText( dn ); +} + +TQString LdapConfigWidget::dn() const +{ + return ( mDn ? mDn->text() : TQString::null ); +} + +void LdapConfigWidget::setFilter( const TQString &filter ) +{ + if ( mFilter ) mFilter->setText( filter ); +} + +TQString LdapConfigWidget::filter() const +{ + return ( mFilter ? mFilter->text() : TQString::null ); +} + +void LdapConfigWidget::setMech( const TQString &mech ) +{ + if ( mMech == 0 ) return; + if ( !mech.isEmpty() ) { + int i = 0; + while ( i < mMech->count() ) { + if ( mMech->text( i ) == mech ) break; + i++; + } + if ( i == mMech->count() ) mMech->insertItem( mech ); + mMech->setCurrentItem( i ); + } +} + +TQString LdapConfigWidget::mech() const +{ + return ( mMech ? mMech->currentText() : TQString::null ); +} + +void LdapConfigWidget::setSecNO( bool b ) +{ + if ( mSecNO ) mSecNO->setChecked( b ); +} + +bool LdapConfigWidget::isSecNO() const +{ + return ( mSecNO ? mSecNO->isChecked() : true ); +} + +void LdapConfigWidget::setSecTLS( bool b ) +{ + if ( mSecTLS ) mSecTLS->setChecked( b ); +} + +bool LdapConfigWidget::isSecTLS() const +{ + return ( mSecTLS ? mSecTLS->isChecked() : false ); +} + +void LdapConfigWidget::setSecSSL( bool b ) +{ + if ( mSecSSL ) mSecSSL->setChecked( b ); +} + +bool LdapConfigWidget::isSecSSL() const +{ + return ( mSecSSL ? mSecSSL->isChecked() : false ); +} + +void LdapConfigWidget::setAuthAnon( bool b ) +{ + if ( mAnonymous ) mAnonymous->setChecked( b ); +} + +bool LdapConfigWidget::isAuthAnon() const +{ + return ( mAnonymous ? mAnonymous->isChecked() : true ); +} + +void LdapConfigWidget::setAuthSimple( bool b ) +{ + if ( mSimple ) mSimple->setChecked( b ); +} + +bool LdapConfigWidget::isAuthSimple() const +{ + return ( mSimple ? mSimple->isChecked() : false ); +} + +void LdapConfigWidget::setAuthSASL( bool b ) +{ + if ( mSASL ) mSASL->setChecked( b ); +} + +bool LdapConfigWidget::isAuthSASL() const +{ + return ( mSASL ? mSASL->isChecked() : false ); +} + +void LdapConfigWidget::setSizeLimit( int sizelimit ) +{ + if ( mSizeLimit ) mSizeLimit->setValue( sizelimit ); +} + +int LdapConfigWidget::sizeLimit() const +{ + return ( mSizeLimit ? mSizeLimit->value() : 0 ); +} + +void LdapConfigWidget::setTimeLimit( int timelimit ) +{ + if ( mTimeLimit ) mTimeLimit->setValue( timelimit ); +} + +int LdapConfigWidget::timeLimit() const +{ + return ( mTimeLimit ? mTimeLimit->value() : 0 ); +} + +int LdapConfigWidget::flags() const +{ + return mFlags; +} + +void LdapConfigWidget::setFlags( int flags ) +{ + mFlags = flags; + + // First delete all the child widgets. + // FIXME: I hope it's correct + const TQObjectList ch = childrenListObject(); + TQObjectList ch2 = ch; + TQObject *obj; + TQWidget *widget; + + obj = ch2.first(); + while ( obj != 0 ) { + widget = dynamic_cast<TQWidget*> (obj); + if ( widget && TQT_BASE_OBJECT(widget->parent()) == TQT_BASE_OBJECT(this) ) { + mainLayout->remove( widget ); + delete ( widget ); + } + obj = ch2.next(); + } + // Re-create child widgets according to the new flags + initWidget(); +} diff --git a/tdeabc/ldapconfigwidget.h b/tdeabc/ldapconfigwidget.h new file mode 100644 index 000000000..662534fd6 --- /dev/null +++ b/tdeabc/ldapconfigwidget.h @@ -0,0 +1,300 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef LDAPCONFIGWIDGET_H +#define LDAPCONFIGWIDGET_H + +#include <tqwidget.h> +#include <tqmap.h> +#include <tqstring.h> + +#include <tdeabc/ldapurl.h> +#include <tdeabc/ldif.h> +#include <tdeio/job.h> + +class TQGridLayout; +class TQSpinBox; +class TQPushButton; +class TQCheckBox; +class TQRadioButton; +class KComboBox; +class KLineEdit; +class KProgressDialog; + +namespace TDEABC { + + /** + @short LDAP Configuration widget + + This class can be used to query the user for LDAP connection parameters. + It's TDEConfigXT compatible, using widget names starting with kcfg_ + */ + + class KABC_EXPORT LdapConfigWidget : public TQWidget + { + Q_OBJECT + + TQ_PROPERTY( LCW_Flags flags READ flagsProp WRITE setFlagsProp ) + TQ_PROPERTY( TQString user READ user WRITE setUser ) + TQ_PROPERTY( TQString password READ password WRITE setPassword ) + TQ_PROPERTY( TQString bindDN READ bindDN WRITE setBindDN ) + TQ_PROPERTY( TQString realm READ realm WRITE setRealm ) + TQ_PROPERTY( TQString host READ host WRITE setHost ) + TQ_PROPERTY( int port READ port WRITE setPort ) + TQ_PROPERTY( int ver READ ver WRITE setVer ) + TQ_PROPERTY( TQString dn READ dn WRITE setDn ) + TQ_PROPERTY( TQString filter READ filter WRITE setFilter ) + TQ_PROPERTY( TQString mech READ mech WRITE setMech ) + TQ_PROPERTY( bool secNO READ isSecNO WRITE setSecNO ) + TQ_PROPERTY( bool secSSL READ isSecSSL WRITE setSecSSL ) + TQ_PROPERTY( bool secTLS READ isSecSSL WRITE setSecTLS ) + TQ_PROPERTY( bool authAnon READ isAuthAnon WRITE setAuthAnon ) + TQ_PROPERTY( bool authSimple READ isAuthSimple WRITE setAuthSimple ) + TQ_PROPERTY( bool authSASL READ isAuthSASL WRITE setAuthSASL ) + TQ_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit ) + TQ_PROPERTY( int timeLimit READ timeLimit WRITE setTimeLimit ) + TQ_SETS ( LCW_Flags ) + + public: + + enum LCW_Flags { + W_USER = 0x1, + W_PASS = 0x2, + W_BINDDN = 0x4, + W_REALM = 0x8, + W_HOST = 0x10, + W_PORT = 0x20, + W_VER = 0x40, + W_DN = 0x80, + W_FILTER = 0x100, + W_SECBOX = 0x400, + W_AUTHBOX = 0x800, + W_TIMELIMIT = 0x1000, + W_SIZELIMIT = 0x2000, + W_ALL = 0xFFFFFFF + }; + + /** Constructs an empty configuration widget. + * You need to call setFlags() after this. + */ + LdapConfigWidget( TQWidget* parent = 0, + const char* name = 0, WFlags fl = 0 ); + /** Constructs a configuration widget */ + LdapConfigWidget( int flags, TQWidget* parent = 0, + const char* name = 0, WFlags fl = 0 ); + /** Destructs a configuration widget */ + virtual ~LdapConfigWidget(); + + /** Sets the user name. Kconfig widget name: kcfg_ldapuser */ + void setUser( const TQString &user ); + /** Gets the user name. Kconfig widget name: kcfg_ldapuser */ + TQString user() const; + + /** Sets the password. Kconfig widget name: kcfg_ldappassword */ + void setPassword( const TQString &password ); + /** Gets the password. Kconfig widget name: kcfg_ldappassword */ + TQString password() const; + + /** + * Sets the bind dn. Useful for SASL proxy auth. + * Kconfig widget name: kcfg_ldapbinddn + */ + void setBindDN( const TQString &binddn ); + /** Gets the bind dn. Kconfig widget name: kcfg_ldapbinddn*/ + TQString bindDN() const; + + /** Sets the SASL realm. Kconfig widget name: kcfg_ldaprealm */ + void setRealm( const TQString &realm ); + /** Gets the SASL realm. Kconfig widget name: kcfg_ldaprealm */ + TQString realm() const; + + /** Sets the host name. Kconfig widget name: kcfg_ldaphost */ + void setHost( const TQString &host ); + /** Gets the host name. Kconfig widget name: kcfg_ldaphost */ + TQString host() const; + + /** Sets the LDAP port. Kconfig widget name: kcfg_ldapport */ + void setPort( int port ); + /** Gets the LDAP port. Kconfig widget name: kcfg_ldapport */ + int port() const; + + /** Sets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */ + void setVer( int ver ); + /** Gets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */ + int ver() const; + + /** Sets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */ + void setDn( const TQString &dn ); + /** Gets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */ + TQString dn() const; + + /** Sets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */ + void setFilter( const TQString &filter ); + /** Gets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */ + TQString filter() const; + + /** Sets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */ + void setMech( const TQString &mech ); + /** Gets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */ + TQString mech() const; + + /** + * Sets the configuration to no transport security. + * Kconfig widget name: kcfg_ldapnosec + */ + void setSecNO( bool b = true ); + /** + * Returns true if no transport security selected. + * Kconfig widget name: kcfg_ldapnosec + */ + bool isSecNO() const; + + /** + * Sets the configuration to TLS. + * Kconfig widget name: kcfg_ldaptls + */ + void setSecTLS( bool b = true ); + /** + * Returns true if TLS selected. + * Kconfig widget name: kcfg_ldaptls + */ + bool isSecTLS() const; + + /** + * Sets the configuration to SSL. + * Kconfig widget name: kcfg_ldapssl + */ + void setSecSSL( bool b = true ); + /** + * Returns true if SSL selected. + * Kconfig widget name: kcfg_ldapssl + */ + bool isSecSSL() const; + + /** + * Sets the authentication to anonymous. + * Kconfig widget name: kcfg_ldapanon + */ + void setAuthAnon( bool b = true ); + /** + * Returns true if Anonymous authentication selected. + * Kconfig widget name: kcfg_ldapanon + */ + bool isAuthAnon() const; + + /** + * Sets the authentication to simple. + * Kconfig widget name: kcfg_ldapsimple + */ + void setAuthSimple( bool b = true ); + /** + * Returns true if Simple authentication selected. + * Kconfig widget name: kcfg_ldapsimple + */ + bool isAuthSimple() const; + + /** + * Sets the authentication to SASL. + * Kconfig widget name: kcfg_ldapsasl + */ + void setAuthSASL( bool b = true ); + /** + * Returns true if SASL authentication selected. + * Kconfig widget name: kcfg_ldapsasl + */ + bool isAuthSASL() const; + + /** + * Sets the size limit. + * TDEConfig widget name: kcfg_ldapsizelimit + */ + void setSizeLimit( int sizelimit ); + /** + * Returns the size limit. + * TDEConfig widget name: kcfg_ldapsizelimit + */ + int sizeLimit() const; + + /** + * Sets the time limit. + * TDEConfig widget name: kcfg_ldaptimelimit + */ + void setTimeLimit( int timelimit ); + /** + * Returns the time limit. + * TDEConfig widget name: kcfg_ldaptimelimit + */ + int timeLimit() const; + + int flags() const; + void setFlags( int flags ); + inline LCW_Flags flagsProp() const { return (LCW_Flags)flags(); } + inline void setFlagsProp( LCW_Flags flags ) { setFlags((int)flags); } + + /** + * Returns a LDAP Url constructed from the settings given. + * Extensions are filled for use in the LDAP ioslave + */ + TDEABC::LDAPUrl url() const; + + private slots: + void setLDAPPort(); + void setLDAPSPort(); + void setAnonymous( int state ); + void setSimple( int state ); + void setSASL( int state ); + void mQueryDNClicked(); + void mQueryMechClicked(); + void loadData( TDEIO::Job*, const TQByteArray& ); + void loadResult( TDEIO::Job* ); + private: + + int mFlags; + LDIF mLdif; + TQStringList mQResult; + TQString mAttr; + + KLineEdit *mUser; + KLineEdit *mPassword; + KLineEdit *mHost; + TQSpinBox *mPort, *mVer, *mSizeLimit, *mTimeLimit; + KLineEdit *mDn, *mBindDN, *mRealm; + KLineEdit *mFilter; + TQRadioButton *mAnonymous,*mSimple,*mSASL; + TQCheckBox *mSubTree; + TQPushButton *mEditButton; + TQPushButton *mQueryMech; + TQRadioButton *mSecNO,*mSecTLS,*mSecSSL; + KComboBox *mMech; + + TQString mErrorMsg; + bool mCancelled; + KProgressDialog *mProg; + + TQGridLayout *mainLayout; + class LDAPConfigWidgetPrivate; + LDAPConfigWidgetPrivate *d; + + void sendQuery(); + void initWidget(); + }; +} + +#endif diff --git a/tdeabc/ldapurl.cpp b/tdeabc/ldapurl.cpp new file mode 100644 index 000000000..95363efaf --- /dev/null +++ b/tdeabc/ldapurl.cpp @@ -0,0 +1,201 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <tqstringlist.h> +#include <tqdir.h> + +#include "ldapurl.h" + +using namespace TDEABC; + +LDAPUrl::LDAPUrl() +{ + m_scope = Base; +} + +LDAPUrl::LDAPUrl(const KURL &_url) + : KURL(_url), m_extensions() +{ + m_dn = path(); + if ( !TQDir::isRelativePath(m_dn) ) +#ifdef Q_WS_WIN + m_dn.remove(0,3); // e.g. "c:/" +#else + m_dn.remove(0,1); +#endif + parseQuery(); +} + +void LDAPUrl::setDn( const TQString &dn) +{ + m_dn = dn; + if ( !TQDir::isRelativePath(m_dn) ) +#ifdef Q_WS_WIN + m_dn.remove(0,3); // e.g. "c:/" +#else + m_dn.remove(0,1); +#endif + setPath(m_dn); +} + +bool LDAPUrl::hasExtension( const TQString &key ) const +{ + return m_extensions.contains( key ); +} + +LDAPUrl::Extension LDAPUrl::extension( const TQString &key ) const +{ + TQMap<TQString, Extension>::const_iterator it; + + it = m_extensions.find( key ); + if ( it != m_extensions.constEnd() ) + return (*it); + else { + Extension ext; + ext.value = ""; + ext.critical = false; + return ext; + } +} + +TQString LDAPUrl::extension( const TQString &key, bool &critical ) const +{ + Extension ext; + + ext = extension( key ); + critical = ext.critical; + return ext.value; +} + +void LDAPUrl::setExtension( const TQString &key, const LDAPUrl::Extension &ext ) +{ + m_extensions[ key ] = ext; + updateQuery(); +} + +void LDAPUrl::setExtension( const TQString &key, const TQString &value, bool critical ) +{ + Extension ext; + ext.value = value; + ext.critical = critical; + setExtension( key, ext ); +} + +void LDAPUrl::removeExtension( const TQString &key ) +{ + m_extensions.remove( key ); + updateQuery(); +} + +void LDAPUrl::updateQuery() +{ + Extension ext; + TQMap<TQString, Extension>::iterator it; + TQString q = "?"; + + // set the attributes to query + if ( m_attributes.count() > 0 ) q += m_attributes.join(","); + + // set the scope + q += "?"; + switch( m_scope ) { + case Sub: + q += "sub"; + break; + case One: + q += "one"; + break; + case Base: + q += "base"; + break; + } + + // set the filter + q += "?"; + if ( m_filter != "(objectClass=*)" && !m_filter.isEmpty() ) + q += m_filter; + + // set the extensions + q += "?"; + for ( it = m_extensions.begin(); it != m_extensions.end(); ++it ) { + if ( it.data().critical ) q += "!"; + q += it.key(); + if ( !it.data().value.isEmpty() ) + q += "=" + it.data().value; + q += ","; + } + while ( q.endsWith("?") || q.endsWith(",") ) + q.remove( q.length() - 1, 1 ); + + setQuery(q); + kdDebug(5700) << "LDAP URL updateQuery(): " << prettyURL() << endl; +} + +void LDAPUrl::parseQuery() +{ + Extension ext; + TQStringList extensions; + TQString q = query(); + // remove first ? + if (q.startsWith("?")) + q.remove(0,1); + + // split into a list + TQStringList url_items = TQStringList::split("?", q, true); + + m_attributes.clear(); + m_scope = Base; + m_filter = "(objectClass=*)"; + m_extensions.clear(); + + int i = 0; + for ( TQStringList::Iterator it = url_items.begin(); it != url_items.end(); ++it, i++ ) { + switch (i) { + case 0: + m_attributes = TQStringList::split(",", (*it), false); + break; + case 1: + if ( (*it) == "sub" ) m_scope = Sub; else + if ( (*it) == "one") m_scope = One; + break; + case 2: + m_filter = decode_string( *it ); + break; + case 3: + extensions = TQStringList::split(",", (*it), false); + break; + } + } + + TQString name,value; + for ( TQStringList::Iterator it = extensions.begin(); it != extensions.end(); ++it ) { + ext.critical = false; + name = decode_string( (*it).section('=',0,0) ).lower(); + value = decode_string( (*it).section('=',1) ); + if ( name.startsWith("!") ) { + ext.critical = true; + name.remove(0, 1); + } + kdDebug(5700) << "LDAPUrl extensions name= " << name << " value: " << value << endl; + ext.value = value.replace( "%2", "," ); + setExtension( name, ext ); + } +} diff --git a/tdeabc/ldapurl.h b/tdeabc/ldapurl.h new file mode 100644 index 000000000..f86c8a466 --- /dev/null +++ b/tdeabc/ldapurl.h @@ -0,0 +1,110 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _K_LDAPURL_H_ +#define _K_LDAPURL_H_ + +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqmap.h> + +#include <kurl.h> + +namespace TDEABC { + +/** + * LDAPUrl + + * LDAPUrl implements an RFC 2255 compliant LDAP Url parser, with minimal + * differences. LDAP Urls implemented by this class has the following format: + * ldap[s]://[user[:password]@]hostname[:port]["/" [dn ["?" [attributes] + * ["?" [scope] ["?" [filter] ["?" extensions]]]]]] + */ + + + class KABC_EXPORT LDAPUrl : public KURL + { + public: + + struct Extension { + TQString value; + bool critical; + }; + + typedef enum Scope { Base, One, Sub }; + + /** Constructs an empty KLDAPUrl. */ + LDAPUrl(); + /** Constructs a KLDAPUrl from a KURL. */ + LDAPUrl( const KURL &url ); + + /** + * Returns the dn part of the LDAP Url (same as path(), but slash removed + * from the beginning). + */ + const TQString& dn() const { return m_dn; } + /** Sets the the dn part of the LDAP Url. */ + void setDn( const TQString &dn ); + + /** Returns the attributes part of the LDAP Url */ + const TQStringList &attributes() { return m_attributes; } + /** Sets the attributes part of the LDAP Url */ + void setAttributes( const TQStringList &attributes ) + { m_attributes=attributes; updateQuery(); } + + /** Returns the scope part of the LDAP Url */ + Scope scope() const { return m_scope; } + /** Sets the scope part of the LDAP Url */ + void setScope(Scope scope) { m_scope = scope; updateQuery(); } + + /** Returns the filter part of the LDAP Url */ + const TQString &filter() const { return m_filter; } + /** Sets the filter part of the LDAP Url */ + void setFilter( TQString filter ) { m_filter = filter; updateQuery(); } + + /** Returns if the specified extension exists in the LDAP Url */ + bool hasExtension( const TQString &key ) const; + /** Returns the specified extension */ + Extension extension( const TQString &key ) const; + /** Returns the specified extension */ + TQString extension( const TQString &key, bool &critical ) const; + /** Sets the specified extension key with the value and criticality in ext */ + void setExtension( const TQString &key, const Extension &ext ); + /** Sets the specified extension key with the value and criticality specified */ + void setExtension( const TQString &key, const TQString &value, bool critical = false ); + /** Removes the specified extension */ + void removeExtension( const TQString &key ); + /** Updates the query component from the attributes, scope, filter and extensions */ + void updateQuery(); + + protected: + void parseQuery(); + + private: + + TQMap<TQString, Extension> m_extensions; + TQString m_dn; + TQStringList m_attributes; + Scope m_scope; + TQString m_filter; + }; +} + +#endif diff --git a/tdeabc/ldif.cpp b/tdeabc/ldif.cpp new file mode 100644 index 000000000..a40f5a818 --- /dev/null +++ b/tdeabc/ldif.cpp @@ -0,0 +1,365 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <kmdcodec.h> + +#include "ldif.h" + +using namespace TDEABC; + +LDIF::LDIF() +{ + startParsing(); +} + +LDIF::~LDIF() +{ +} + +TQCString LDIF::assembleLine( const TQString &fieldname, const TQByteArray &value, + uint linelen, bool url ) +{ + bool safe = false; + bool isDn; + TQCString result; + uint i; + + if ( url ) { + result = fieldname.utf8() + ":< " + TQCString( value.data(), value.size()+1 ); + } else { + isDn = fieldname.lower() == "dn"; + //SAFE-INIT-CHAR + if ( value.size() > 0 && value[0] > 0 && value[0] != '\n' && + value[0] != '\r' && value[0] != ':' && value[0] != '<' ) safe = true; + + //SAFE-CHAR + if ( safe ) { + for ( i=1; i < value.size(); i++ ) { + //allow utf-8 in Distinguished Names + if ( ( isDn && value[i] == 0 ) || + ( !isDn && value[i] <= 0 ) || + value[i] == '\r' || value[i] == '\n' ) { + safe = false; + break; + } + } + } + + if ( value.size() == 0 ) safe = true; + + if( safe ) { + result = fieldname.utf8() + ": " + TQCString( value.data(), value.size()+1 ); + } else { + result = fieldname.utf8() + ":: " + KCodecs::base64Encode( value, false ); + } + + if ( linelen > 0 ) { + i = (fieldname.length()+2) > linelen ? fieldname.length()+2 : linelen; + while ( i < result.length() ) { + result.insert( i, "\n " ); + i += linelen+2; + } + } + } + return result; +} + +TQCString LDIF::assembleLine( const TQString &fieldname, const TQCString &value, + uint linelen, bool url ) +{ + TQCString ret; + TQByteArray tmp; + uint valuelen = value.length(); + const char *data = value.data(); + + tmp.setRawData( data, valuelen ); + ret = assembleLine( fieldname, tmp, linelen, url ); + tmp.resetRawData( data, valuelen ); + return ret; + +} + +TQCString LDIF::assembleLine( const TQString &fieldname, const TQString &value, + uint linelen, bool url ) +{ + return assembleLine( fieldname, value.utf8(), linelen, url ); +} + +bool LDIF::splitLine( const TQCString &line, TQString &fieldname, TQByteArray &value ) +{ + int position; + TQByteArray tmp; + int linelen; + const char *data; + +// kdDebug(5700) << "splitLine line: " << TQString::fromUtf8(line) << endl; + + position = line.find( ":" ); + if ( position == -1 ) { + // strange: we did not find a fieldname + fieldname = ""; + TQCString str; + str = line.stripWhiteSpace(); + linelen = str.length(); + data = str.data(); + tmp.setRawData( data, linelen ); + value = tmp.copy(); + tmp.resetRawData( data, linelen ); +// kdDebug(5700) << "value : " << value[0] << endl; + return false; + } + + linelen = line.length(); + + if ( linelen > ( position + 1 ) && line[ position + 1 ] == ':' ) { + // String is BASE64 encoded -> decode it now. + fieldname = TQString::fromUtf8( + line.left( position ).stripWhiteSpace() ); + if ( linelen <= ( position + 3 ) ) { + value.resize( 0 ); + return false; + } + data = &line.data()[ position + 3 ]; + tmp.setRawData( data, linelen - position - 3 ); + KCodecs::base64Decode( tmp, value ); + tmp.resetRawData( data, linelen - position - 3 ); + return false; + } + + if ( linelen > ( position + 1 ) && line[ position + 1 ] == '<' ) { + // String is an URL. + fieldname = TQString::fromUtf8( + line.left( position ).stripWhiteSpace() ); + if ( linelen <= ( position + 3 ) ) { + value.resize( 0 ); + return false; + } + data = &line.data()[ position + 3]; + tmp.setRawData( data, linelen - position - 3 ); + value = tmp.copy(); + tmp.resetRawData( data, linelen - position - 3 ); + return true; + } + + fieldname = TQString::fromUtf8(line.left( position ).stripWhiteSpace()); + if ( linelen <= ( position + 2 ) ) { + value.resize( 0 ); + return false; + } + data = &line.data()[ position + 2 ]; + tmp.setRawData( data, linelen - position - 2 ); + value = tmp.copy(); + tmp.resetRawData( data, linelen - position - 2 ); + return false; +} + +bool LDIF::splitControl( const TQCString &line, TQString &oid, bool &critical, + TQByteArray &value ) +{ + TQString tmp; + critical = false; + bool url = splitLine( line, tmp, value ); + + kdDebug(5700) << "splitControl: value: " << TQString(TQString::fromUtf8(value, value.size())) << endl; + if ( tmp.isEmpty() ) { + tmp = TQString::fromUtf8( value, value.size() ); + value.resize( 0 ); + } + if ( tmp.right( 4 ) == "true" ) { + critical = true; + tmp.truncate( tmp.length() - 5 ); + } else if ( tmp.right( 5 ) == "false" ) { + critical = false; + tmp.truncate( tmp.length() - 6 ); + } + oid = tmp; + return url; +} + +LDIF::ParseVal LDIF::processLine() +{ + + if ( mIsComment ) return None; + + ParseVal retval = None; + if ( mLastParseVal == EndEntry ) mEntryType = Entry_None; + + mUrl = splitLine( line, mAttr, mVal ); + + TQString attrLower = mAttr.lower(); + + switch ( mEntryType ) { + case Entry_None: + if ( attrLower == "version" ) { + if ( !mDn.isEmpty() ) retval = Err; + } else if ( attrLower == "dn" ) { + kdDebug(5700) << "ldapentry dn: " << TQString(TQString::fromUtf8( mVal, mVal.size() )) << endl; + mDn = TQString::fromUtf8( mVal, mVal.size() ); + mModType = Mod_None; + retval = NewEntry; + } else if ( attrLower == "changetype" ) { + if ( mDn.isEmpty() ) + retval = Err; + else { + TQString tmpval = TQString::fromUtf8( mVal, mVal.size() ); + kdDebug(5700) << "changetype: " << tmpval << endl; + if ( tmpval == "add" ) mEntryType = Entry_Add; + else if ( tmpval == "delete" ) mEntryType = Entry_Del; + else if ( tmpval == "modrdn" || tmpval == "moddn" ) { + mNewRdn = ""; + mNewSuperior = ""; + mDelOldRdn = true; + mEntryType = Entry_Modrdn; + } + else if ( tmpval == "modify" ) mEntryType = Entry_Mod; + else retval = Err; + } + } else if ( attrLower == "control" ) { + mUrl = splitControl( TQCString( mVal, mVal.size() + 1 ), mOid, mCritical, mVal ); + retval = Control; + } else if ( !mAttr.isEmpty() && mVal.size() > 0 ) { + mEntryType = Entry_Add; + retval = Item; + } + break; + case Entry_Add: + if ( mAttr.isEmpty() && mVal.size() == 0 ) + retval = EndEntry; + else + retval = Item; + break; + case Entry_Del: + if ( mAttr.isEmpty() && mVal.size() == 0 ) + retval = EndEntry; + else + retval = Err; + break; + case Entry_Mod: + if ( mModType == Mod_None ) { + kdDebug(5700) << "tdeio_ldap: new modtype " << mAttr << endl; + if ( mAttr.isEmpty() && mVal.size() == 0 ) { + retval = EndEntry; + } else if ( attrLower == "add" ) { + mModType = Mod_Add; + } else if ( attrLower == "replace" ) { + mModType = Mod_Replace; + mAttr = TQString::fromUtf8( mVal, mVal.size() ); + mVal.resize( 0 ); + retval = Item; + } else if ( attrLower == "delete" ) { + mModType = Mod_Del; + mAttr = TQString::fromUtf8( mVal, mVal.size() ); + mVal.resize( 0 ); + retval = Item; + } else { + retval = Err; + } + } else { + if ( mAttr.isEmpty() ) { + if ( TQString::fromUtf8( mVal, mVal.size() ) == "-" ) { + mModType = Mod_None; + } else if ( mVal.size() == 0 ) { + retval = EndEntry; + } else + retval = Err; + } else + retval = Item; + } + break; + case Entry_Modrdn: + if ( mAttr.isEmpty() && mVal.size() == 0 ) + retval = EndEntry; + else if ( attrLower == "newrdn" ) + mNewRdn = TQString::fromUtf8( mVal, mVal.size() ); + else if ( attrLower == "newsuperior" ) + mNewSuperior = TQString::fromUtf8( mVal, mVal.size() ); + else if ( attrLower == "deleteoldrdn" ) { + if ( mVal.size() > 0 && mVal[0] == '0' ) + mDelOldRdn = false; + else if ( mVal.size() > 0 && mVal[0] == '1' ) + mDelOldRdn = true; + else + retval = Err; + } else + retval = Err; + break; + } + return retval; +} + +LDIF::ParseVal LDIF::nextItem() +{ + ParseVal retval = None; + char c=0; + + while( retval == None ) { + if ( mPos < mLdif.size() ) { + c = mLdif[mPos]; + mPos++; + if ( mIsNewLine && c == '\r' ) continue; //handle \n\r line end + if ( mIsNewLine && ( c == ' ' || c == '\t' ) ) { //line folding + mIsNewLine = false; + continue; + } + if ( mIsNewLine ) { + mIsNewLine = false; + retval = processLine(); + mLastParseVal = retval; + line.resize( 0 ); + mIsComment = ( c == '#' ); + } + if ( c == '\n' || c == '\r' ) { + mLineNo++; + mIsNewLine = true; + continue; + } + } else { + retval = MoreData; + break; + } + + if ( !mIsComment ) line += c; + } + return retval; +} + +void LDIF::endLDIF() +{ + TQByteArray tmp( 3 ); + tmp[ 0 ] = '\n'; + tmp[ 1 ] = '\n'; + tmp[ 2 ] = '\n'; + mLdif = tmp; + mPos = 0; +} + +void LDIF::startParsing() +{ + mPos = mLineNo = 0; + mDelOldRdn = false; + mEntryType = Entry_None; + mModType = Mod_None; + mDn = mNewRdn = mNewSuperior = ""; + line = ""; + mIsNewLine = false; + mIsComment = false; + mLastParseVal = None; +} diff --git a/tdeabc/ldif.h b/tdeabc/ldif.h new file mode 100644 index 000000000..6cbc536e8 --- /dev/null +++ b/tdeabc/ldif.h @@ -0,0 +1,182 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Szombathelyi Gyorgy <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _K_LDIF_H_ +#define _K_LDIF_H_ + +#include <tqstring.h> +#include <tqcstring.h> +#include <tqmemarray.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + + /** + * LDIF + + * LDIF implements an RFC 2849 compliant LDIF parser. LDIF files are used to + * represent directory information on LDAP-based servers, or to describe a set + * of changes which are to be applied to a directory. + */ + + class KABC_EXPORT LDIF + { + public: + + enum ParseVal{ None, NewEntry, EndEntry, Item, Control, Err, MoreData }; + enum EntryType{ Entry_None, Entry_Add, Entry_Del, Entry_Mod, Entry_Modrdn }; + enum ModType{ Mod_None, Mod_Add, Mod_Replace, Mod_Del }; + LDIF(); + virtual ~LDIF(); + + /** + * Assembles fieldname and value into a valid LDIF line, BASE64 encodes the + * value if neccessary and optionally splits into more lines. + * @param fieldname The name of the entry. + * @param value The value of the entry. + * @param linelen Maximum length of the lines in the result. + * @param url If true, encode value as url ( use :< ). + */ + static TQCString assembleLine( const TQString &fieldname, + const TQByteArray &value, uint linelen=0, bool url=false ); + /** + * This is the same as the above function, the only difference that + * this accepts TQCString as the value. + */ + static TQCString assembleLine( const TQString &fieldname, + const TQCString &value, uint linelen=0, bool url=false ); + /** + * This is the same as the above function, the only difference that + * this accepts TQString as the value. + */ + static TQCString assembleLine( const TQString &fieldname, + const TQString &value, uint linelen=0, bool url=false ); + + /** + * Splits one line from an LDIF file to attribute and value components. + * @returns true if value is an URL, false otherwise + */ + static bool splitLine( const TQCString &line, TQString &fieldname, TQByteArray &value ); + /** + * Splits a control specification (without the "control:" directive) + * @param line is the control directive + * @param oid will contain the OID + * @param critical will contain the criticality of control + * @param value is the control value + */ + static bool splitControl( const TQCString &line, TQString &oid, bool &critical, + TQByteArray &value ); + /** + * Starts the parsing of a new LDIF + */ + void startParsing(); + /** + * Process one LDIF line + */ + ParseVal processLine(); + /** + * Process the LDIF until a complete item can be returned + * @returns NewEntry if a new DN encountered, + * Item if a new item returned, + * Err if the LDIF contains error, + * EndEntry if the parser reached the end of the current entry + * and MoreData if the parser encountered the end of the current chunk of + * the LDIF. If you want to finish the parsing after receiving + * MoreData, then call endLDIF(), so the parser can safely flush + * the current entry. + */ + ParseVal nextItem(); + /** + * Sets a chunk of LDIF. Call before startParsing(), or if nextItem() returned + * MoreData. + */ + void setLDIF( const TQByteArray &ldif ) { mLdif = ldif; mPos = 0; } + /** + * Indicates the end of the LDIF file/stream. Call if nextItem() returned + * MoreData, but actually you don't have more data. + */ + void endLDIF(); + /** + * Returns the requested LDAP operation extracted from the current entry. + */ + EntryType entryType() const { return mEntryType; } + /** + * Returns the LDAP modify request type if entryType() returned Entry_Mod. + */ + int modType() const { return mModType; } + /** + * Returns the Distinguished Name of the current entry. + */ + const TQString& dn() const { return mDn; } + /** + * Returns the new Relative Distinguished Name if modType() returned Entry_Modrdn. + */ + const TQString& newRdn() const { return mNewRdn; } + /** + * Returns the new parent of the entry if modType() returned Entry_Modrdn. + */ + const TQString& newSuperior() const { return mNewSuperior; } + /** + * Returns if the delete of the old RDN is required. + */ + bool delOldRdn() const { return mDelOldRdn; } + /** + * Returns the attribute name. + */ + const TQString& attr() const { return mAttr; } + /** + * Returns the attribute value. + */ + const TQByteArray& val() const { return mVal; } + /** + * Returns if val() is an url + */ + bool isUrl() const { return mUrl; } + /** + * Returns the criticality level when modType() returned Control. + */ + bool critical() const { return mCritical; } + /** + * Returns the OID when modType() returned Control. + */ + const TQString& oid() const { return mOid; } + /** + * Returns the line number which the parser processes. + */ + uint lineNo() const { return mLineNo; } + private: + int mModType; + bool mDelOldRdn, mUrl; + TQString mDn,mAttr,mNewRdn,mNewSuperior, mOid; + TQByteArray mLdif, mVal; + EntryType mEntryType; + + bool mIsNewLine, mIsComment,mCritical; + ParseVal mLastParseVal; + uint mPos,mLineNo; + TQCString line; + + class LDIFPrivate; + LDIFPrivate *d; + }; +} + +#endif diff --git a/tdeabc/ldifconverter.cpp b/tdeabc/ldifconverter.cpp new file mode 100644 index 000000000..8338f5ba0 --- /dev/null +++ b/tdeabc/ldifconverter.cpp @@ -0,0 +1,573 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Helge Deller <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +/* + Useful links: + - http://tldp.org/HOWTO/LDAP-Implementation-HOWTO/schemas.html + - http://www.faqs.org/rfcs/rfc2849.html + + Not yet handled items: + - objectclass microsoftaddressbook + - info, + - initials, + - otherfacsimiletelephonenumber, + - otherpager, + - physicaldeliveryofficename, +*/ + +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqregexp.h> +#include <tqtextstream.h> + +#include <tdelocale.h> +#include <kdebug.h> +#include <kmdcodec.h> + +#include "addressee.h" +#include "address.h" + +#include "ldif.h" +#include "ldifconverter.h" +#include "vcardconverter.h" + +using namespace TDEABC; + +/* generate LDIF stream */ + +bool LDIFConverter::addresseeToLDIF( const AddresseeList &addrList, TQString &str ) +{ + AddresseeList::ConstIterator it; + for ( it = addrList.begin(); it != addrList.end(); ++it ) { + addresseeToLDIF( *it, str ); + } + return true; +} + + + +static void ldif_out( TQTextStream &t, TQString formatStr, TQString value ) +{ + if ( value.isEmpty() ) + return; + + TQCString txt = LDIF::assembleLine( formatStr, value, 72 ); + + // write the string + t << TQString::fromUtf8(txt) << "\n"; +} + +bool LDIFConverter::addresseeToLDIF( const Addressee &addr, TQString &str ) +{ + if ( addr.isEmpty() ) + return false; + + TQTextStream t( str, IO_WriteOnly|IO_Append ); + t.setEncoding( TQTextStream::UnicodeUTF8 ); + + const Address homeAddr = addr.address( Address::Home ); + const Address workAddr = addr.address( Address::Work ); + + ldif_out( t, "dn", TQString( "cn=%1,mail=%2" ) + .arg( TQString(addr.formattedName()).simplifyWhiteSpace() ) + .arg( addr.preferredEmail() ) ); + ldif_out( t, "givenname", addr.givenName() ); + ldif_out( t, "sn", addr.familyName() ); + ldif_out( t, "cn", TQString(addr.formattedName()).simplifyWhiteSpace() ); + ldif_out( t, "uid", addr.uid() ); + ldif_out( t, "nickname", addr.nickName() ); + ldif_out( t, "xmozillanickname", addr.nickName() ); + + ldif_out( t, "mail", addr.preferredEmail() ); + if ( addr.emails().count() > 1 ) + ldif_out( t, "mozillasecondemail", addr.emails()[ 1 ] ); +//ldif_out( t, "mozilla_AIMScreenName: %1\n", "screen_name" ); + + ldif_out( t, "telephonenumber", addr.phoneNumber( PhoneNumber::Work ).number() ); + ldif_out( t, "facsimiletelephonenumber", addr.phoneNumber( PhoneNumber::Fax ).number() ); + ldif_out( t, "homephone", addr.phoneNumber( PhoneNumber::Home ).number() ); + ldif_out( t, "mobile", addr.phoneNumber( PhoneNumber::Cell ).number() ); // Netscape 7 + ldif_out( t, "cellphone", addr.phoneNumber( PhoneNumber::Cell ).number() ); // Netscape 4.x + ldif_out( t, "pager", addr.phoneNumber( PhoneNumber::Pager ).number() ); + ldif_out( t, "pagerphone", addr.phoneNumber( PhoneNumber::Pager ).number() ); + + ldif_out( t, "streethomeaddress", homeAddr.street() ); + ldif_out( t, "postalcode", workAddr.postalCode() ); + ldif_out( t, "postofficebox", workAddr.postOfficeBox() ); + + TQStringList streets = TQStringList::split( '\n', homeAddr.street() ); + if ( streets.count() > 0 ) + ldif_out( t, "homepostaladdress", streets[ 0 ] ); // Netscape 7 + if ( streets.count() > 1 ) + ldif_out( t, "mozillahomepostaladdress2", streets[ 1 ] ); // Netscape 7 + ldif_out( t, "mozillahomelocalityname", homeAddr.locality() ); // Netscape 7 + ldif_out( t, "mozillahomestate", homeAddr.region() ); + ldif_out( t, "mozillahomepostalcode", homeAddr.postalCode() ); + ldif_out( t, "mozillahomecountryname", Address::ISOtoCountry(homeAddr.country()) ); + ldif_out( t, "locality", workAddr.locality() ); + ldif_out( t, "streetaddress", workAddr.street() ); // Netscape 4.x + + streets = TQStringList::split( '\n', workAddr.street() ); + if ( streets.count() > 0 ) + ldif_out( t, "postaladdress", streets[ 0 ] ); + if ( streets.count() > 1 ) + ldif_out( t, "mozillapostaladdress2", streets[ 1 ] ); + ldif_out( t, "countryname", Address::ISOtoCountry(workAddr.country()) ); + ldif_out( t, "l", workAddr.locality() ); + ldif_out( t, "c", Address::ISOtoCountry(workAddr.country()) ); + ldif_out( t, "st", workAddr.region() ); + + ldif_out( t, "title", addr.title() ); + ldif_out( t, "vocation", addr.prefix() ); + ldif_out( t, "ou", addr.role() ); + ldif_out( t, "o", addr.organization() ); + ldif_out( t, "organization", addr.organization() ); + ldif_out( t, "organizationname", addr.organization() ); + + // Compatibility with older kabc versions. + if ( !addr.department().isEmpty() ) + ldif_out( t, "department", addr.department() ); + else + ldif_out( t, "department", addr.custom("KADDRESSBOOK", "X-Department") ); + + ldif_out( t, "workurl", addr.url().prettyURL() ); + ldif_out( t, "homeurl", addr.url().prettyURL() ); + ldif_out( t, "description", addr.note() ); + if (addr.revision().isValid()) + ldif_out(t, "modifytimestamp", dateToVCardString( TQT_TQDATETIME_OBJECT(addr.revision())) ); + + t << "objectclass: top\n"; + t << "objectclass: person\n"; + t << "objectclass: organizationalPerson\n"; + + t << "\n"; + + return true; +} + + +/* convert from LDIF stream */ + +bool LDIFConverter::LDIFToAddressee( const TQString &str, AddresseeList &addrList, TQDateTime dt ) +{ + if (str.isEmpty()) + return true; + + bool endldif = false, end = false; + LDIF ldif; + LDIF::ParseVal ret; + const char *latinstr = str.latin1(); + int latinstrlen = tqstrlen( latinstr ); + TQByteArray data; + Addressee a; + Address homeAddr, workAddr; + + data.setRawData( latinstr, latinstrlen ); + ldif.setLDIF( data ); + if (!dt.isValid()) + dt = TQDateTime::currentDateTime(); + a.setRevision(dt); + homeAddr = Address( Address::Home ); + workAddr = Address( Address::Work ); + + do { + ret = ldif.nextItem(); + switch ( ret ) { + case LDIF::Item: { + TQString fieldname = ldif.attr().lower(); + TQString value = TQString::fromUtf8( ldif.val(), ldif.val().size() ); + evaluatePair( a, homeAddr, workAddr, fieldname, value ); + break; + } + case LDIF::EndEntry: + // if the new address is not empty, append it + if ( !a.formattedName().isEmpty() || !a.name().isEmpty() || + !a.familyName().isEmpty() ) { + if ( !homeAddr.isEmpty() ) + a.insertAddress( homeAddr ); + if ( !workAddr.isEmpty() ) + a.insertAddress( workAddr ); + addrList.append( a ); + } + a = Addressee(); + a.setRevision(dt); + homeAddr = Address( Address::Home ); + workAddr = Address( Address::Work ); + break; + case LDIF::MoreData: { + if ( endldif ) + end = true; + else { + ldif.endLDIF(); + endldif = true; + break; + } + } + default: + break; + } + } while ( !end ); + + data.resetRawData( latinstr, latinstrlen ); + + return true; +} + +bool LDIFConverter::evaluatePair( Addressee &a, Address &homeAddr, + Address &workAddr, + TQString &fieldname, TQString &value ) +{ + if ( fieldname == TQString::fromLatin1( "dn" ) ) // ignore & return false! + return false; + + if ( fieldname.startsWith("#") ) { + return true; + } + + if ( fieldname.isEmpty() && !a.note().isEmpty() ) { + // some LDIF export filters are borken and add additional + // comments on stand-alone lines. Just add them to the notes for now. + a.setNote( a.note() + "\n" + value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "givenname" ) ) { + a.setGivenName( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "xmozillanickname") || + fieldname == TQString::fromLatin1( "nickname") ) { + a.setNickName( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "sn" ) ) { + a.setFamilyName( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "uid" ) ) { + a.setUid( value ); + return true; + } + if ( fieldname == TQString::fromLatin1( "mail" ) || + fieldname == TQString::fromLatin1( "mozillasecondemail" ) ) { // mozilla + if ( a.emails().findIndex( value ) == -1 ) + a.insertEmail( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "title" ) ) { + a.setTitle( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "vocation" ) ) { + a.setPrefix( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "cn" ) ) { + a.setFormattedName( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "o" ) || + fieldname == TQString::fromLatin1( "organization" ) || // Exchange + fieldname == TQString::fromLatin1( "organizationname" ) ) { // Exchange + a.setOrganization( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "description" ) ) { +addComment: + if ( !a.note().isEmpty() ) + a.setNote( a.note() + "\n" ); + a.setNote( a.note() + value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "custom1" ) || + fieldname == TQString::fromLatin1( "custom2" ) || + fieldname == TQString::fromLatin1( "custom3" ) || + fieldname == TQString::fromLatin1( "custom4" ) ) { + goto addComment; + } + + if ( fieldname == TQString::fromLatin1( "homeurl" ) || + fieldname == TQString::fromLatin1( "workurl" ) ) { + if (a.url().isEmpty()) { + a.setUrl( KURL( value ) ); + return true; + } + if ( a.url().prettyURL() == KURL(value).prettyURL() ) + return true; + // TODO: current version of kabc only supports one URL. + // TODO: change this with KDE 4 + } + + if ( fieldname == TQString::fromLatin1( "homephone" ) ) { + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Home ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "telephonenumber" ) ) { + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Work ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mobile" ) ) { // mozilla/Netscape 7 + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Cell ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "cellphone" ) ) { + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Cell ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "pager" ) || // mozilla + fieldname == TQString::fromLatin1( "pagerphone" ) ) { // mozilla + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Pager ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "facsimiletelephonenumber" ) ) { + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Fax ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "xmozillaanyphone" ) ) { // mozilla + a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Work ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "street" ) || + fieldname == TQString::fromLatin1( "streethomeaddress" ) ) { + homeAddr.setStreet( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "postaladdress" ) ) { // mozilla + workAddr.setStreet( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillapostaladdress2" ) ) { // mozilla + workAddr.setStreet( workAddr.street() + TQString::fromLatin1( "\n" ) + value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "postalcode" ) ) { + workAddr.setPostalCode( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "postofficebox" ) ) { + workAddr.setPostOfficeBox( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "homepostaladdress" ) ) { // Netscape 7 + homeAddr.setStreet( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillahomepostaladdress2" ) ) { // mozilla + homeAddr.setStreet( homeAddr.street() + TQString::fromLatin1( "\n" ) + value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillahomelocalityname" ) ) { // mozilla + homeAddr.setLocality( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillahomestate" ) ) { // mozilla + homeAddr.setRegion( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillahomepostalcode" ) ) { // mozilla + homeAddr.setPostalCode( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "mozillahomecountryname" ) ) { // mozilla + if ( value.length() <= 2 ) + value = Address::ISOtoCountry(value); + homeAddr.setCountry( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "locality" ) ) { + workAddr.setLocality( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "streetaddress" ) ) { // Netscape 4.x + workAddr.setStreet( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "countryname" ) || + fieldname == TQString::fromLatin1( "c" ) ) { // mozilla + if ( value.length() <= 2 ) + value = Address::ISOtoCountry(value); + workAddr.setCountry( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "l" ) ) { // mozilla + workAddr.setLocality( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "st" ) ) { + workAddr.setRegion( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "ou" ) ) { + a.setRole( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "department" ) ) { + a.setDepartment( value ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "member" ) ) { + // this is a mozilla list member (cn=xxx, mail=yyy) + TQStringList list( TQStringList::split( ',', value ) ); + TQString name, email; + + TQStringList::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( (*it).startsWith( "cn=" ) ) + name = (*it).mid( 3 ).stripWhiteSpace(); + if ( (*it).startsWith( "mail=" ) ) + email = (*it).mid( 5 ).stripWhiteSpace(); + } + if ( !name.isEmpty() && !email.isEmpty() ) + email = " <" + email + ">"; + a.insertEmail( name + email ); + a.insertCategory( i18n( "List of Emails" ) ); + return true; + } + + if ( fieldname == TQString::fromLatin1( "modifytimestamp" ) ) { + if (value == TQString::fromLatin1("0Z")) // ignore + return true; + TQDateTime dt = VCardStringToDate( value ); + if ( dt.isValid() ) { + a.setRevision(dt); + return true; + } + } + + if ( fieldname == TQString::fromLatin1( "objectclass" ) ) // ignore + return true; + + kdWarning() << TQString(TQString("LDIFConverter: Unknown field for '%1': '%2=%3'\n") + .arg(a.formattedName()).arg(fieldname).arg(value)); + + return true; +} + +/* The following functions are obsoleted. Similar functionality can be found + * in the LDIF class */ + +bool LDIFConverter::parseSingleLine( Addressee &a, Address &homeAddr, + Address &workAddr, TQString &line ) +{ + if ( line.isEmpty() ) + return true; + + TQString fieldname, value; + TQByteArray val; + + LDIF::splitLine( line.latin1(), fieldname, val ); + value = TQString::fromUtf8( val.data(), val.size() ); + return evaluatePair( a, homeAddr, workAddr, fieldname, value); +} + + +bool LDIFConverter::splitLine( TQString &line, TQString &fieldname, TQString &value) +{ + TQByteArray val; + bool ret = LDIF::splitLine( line.latin1(), fieldname, val ); + value = TQString::fromUtf8( val.data(), val.size() ); + return ret; +} + + +TQString LDIFConverter::makeLDIFfieldString( TQString formatStr, TQString value, bool allowEncode ) +{ + if ( value.isEmpty() ) + return TQString(); + + // append format if not given + if (formatStr.find(':') == -1) + formatStr.append(": %1\n"); + + // check if base64-encoding is needed + bool printable = true; + unsigned int i, len; + len = value.length(); + for (i = 0; i<len; ++i ) { + if (!value[i].isPrint()) { + printable = false; + break; + } + } + + if (printable) // always encode if we find special chars... + printable = (value.find('\n') == -1); + + if (!printable && allowEncode) { + // encode to base64 + value = KCodecs::base64Encode( value.utf8() ); + int p = formatStr.find(':'); + if (p>=0) + formatStr.insert(p, ':'); + } + + // generate the new string and split it to 72 chars/line + TQCString txt = TQString(formatStr.arg(value)).utf8(); + + if (allowEncode) { + len = txt.length(); + if (len && txt[len-1] == '\n') + --len; + i = 72; + while (i < len) { + txt.insert(i, "\n "); + i += 72+1; + len += 2; + } + } + + return TQString::fromUtf8(txt); +} + diff --git a/tdeabc/ldifconverter.h b/tdeabc/ldifconverter.h new file mode 100644 index 000000000..8788136b3 --- /dev/null +++ b/tdeabc/ldifconverter.h @@ -0,0 +1,100 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Helge Deller <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 only as published by the Free Software Foundation. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_LDIFCONVERTER_H +#define KABC_LDIFCONVERTER_H + +#include <tqstring.h> +#include <tqdatetime.h> + +#include "addressee.h" +#include "addresseelist.h" + +namespace TDEABC { + + /** + * A set of functions to convert a string with LDIF information to addressees + * and vice versa. It is useful for addressbook import- and exportfilters + * and might be used to read and write Mozilla and Netscape addresssbooks. + */ + + namespace LDIFConverter { + + /** + * Converts a LDIF string to a list of addressees. + * + * @param str The vcard string. + * @param addrList The addresseelist. + * @param dt The date & time value of the last modification (e.g. file modification time). + * @since 3.2 + */ + KABC_EXPORT bool LDIFToAddressee( const TQString &str, AddresseeList &addrList, TQDateTime dt = TQDateTime::currentDateTime() ); + + /** + * Converts a list of addressees to a LDIF string. + * + * @param addrList The addresseelist. + * @param str The LDIF string. + * @since 3.2 + */ + KABC_EXPORT bool addresseeToLDIF( const AddresseeList &addrList, TQString &str ); + + /** + * Converts an addressee to a LDIF string. + * + * @param addr The addressee. + * @param str The LDIF string. + * @since 3.2 + */ + KABC_EXPORT bool addresseeToLDIF( const Addressee &addr, TQString &str ); + + /** + * @deprecated + * Obsoleted - please use LDIF::assembleLine() + * Returns a LDIF compatible string representing a given field/value pair. + * If necessary, the value parameter will be base64encoded and split into multiple. + * This function will return an empty string if the given value is empty. + * + * @param field The LDAP field name or a complete LDIF field string (e.g. "cn" or "cn = %1\n"). + * @param value The value for this field. + * @param allowEncode Set to false if you wish no encoding of the value. + * @since 3.2 + */ + KABC_EXPORT TQString makeLDIFfieldString( TQString field, TQString value, bool allowEncode = true ) KDE_DEPRECATED; + + + + /* internal functions - do not use !! */ + + /** No need for this function anymore - use LDIF::splitLine() + evaluatePair() */ + KABC_EXPORT bool parseSingleLine( Addressee &a, + Address &homeAddr, Address &workAddr, TQString &line ); + + /** No need for this function anymore - use LDIF::splitLine() */ + KABC_EXPORT bool splitLine( TQString &line, TQString &fieldname, TQString &value); + + + KABC_EXPORT bool evaluatePair( Addressee &a, Address &homeAddr, Address &workAddr, + TQString &fieldname, TQString &value ); + + } + +} +#endif + diff --git a/tdeabc/lock.cpp b/tdeabc/lock.cpp new file mode 100644 index 000000000..782b60afa --- /dev/null +++ b/tdeabc/lock.cpp @@ -0,0 +1,162 @@ +/* + This file is part of libkabc. + Copyright (c) 2001,2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "lock.h" + +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <tdetempfile.h> + +#include <tqfile.h> + +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +using namespace TDEABC; + +Lock::Lock( const TQString &identifier ) + : mIdentifier( identifier ) +{ + mIdentifier.replace( "/", "_" ); +} + +Lock::~Lock() +{ + unlock(); +} + +TQString Lock::locksDir() +{ + return locateLocal( "data", "tdeabc/lock/" ); +} + +bool Lock::readLockFile( const TQString &filename, int &pid, TQString &app ) +{ + TQFile file( filename ); + if ( !file.open( IO_ReadOnly ) ) return false; + + TQTextStream t( &file ); + pid = t.readLine().toInt(); + app = t.readLine(); + + return true; +} + +bool Lock::writeLockFile( const TQString &filename ) +{ + TQFile file( filename ); + if ( !file.open( IO_WriteOnly ) ) return false; + TQTextStream t( &file ); + t << ::getpid() << endl << TQString( TDEGlobal::instance()->instanceName() ); + + return true; +} + +TQString Lock::lockFileName() const +{ + return locksDir() + mIdentifier + ".lock"; +} + +bool Lock::lock() +{ + kdDebug(5700) << "Lock::lock()" << endl; + + TQString lockName = lockFileName(); + kdDebug(5700) << "-- lock name: " << lockName << endl; + + if ( TQFile::exists( lockName ) ) { // check if it is a stale lock file + int pid; + TQString app; + + if ( !readLockFile( lockFileName(), pid, app ) ) { + mError = i18n("Unable to open lock file."); + return false; + } + + int retval = ::kill( pid, 0 ); + if ( retval == -1 && errno == ESRCH ) { // process doesn't exists anymore + TQFile::remove( lockName ); + kdWarning(5700) << "Removed stale lock file from process '" << app << "'" + << endl; + } else { + TQString identifier( mIdentifier ); + identifier.replace( '_', '/' ); + + mError = i18n("The address book '%1' is locked by application '%2'.\nIf you believe this is incorrect, just remove the lock file from '%3'") + .arg( identifier ).arg( app ).arg( locateLocal( "data", "tdeabc/lock/*.lock" ) ); + return false; + } + } + + TQString lockUniqueName; + lockUniqueName = mIdentifier + kapp->randomString( 8 ); + mLockUniqueName = locateLocal( "data", "tdeabc/lock/" + lockUniqueName ); + kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; + + // Create unique file + writeLockFile( mLockUniqueName ); + + // Create lock file + int result = ::link( TQFile::encodeName( mLockUniqueName ), + TQFile::encodeName( lockName ) ); + + if ( result == 0 ) { + mError = ""; + emit locked(); + return true; + } + + // TODO: check stat + + mError = i18n("Error"); + return false; +} + +bool Lock::unlock() +{ + int pid; + TQString app; + if ( readLockFile( lockFileName(), pid, app ) ) { + if ( pid == getpid() ) { + TQFile::remove( lockFileName() ); + TQFile::remove( mLockUniqueName ); + emit unlocked(); + } else { + mError = i18n("Unlock failed. Lock file is owned by other process: %1 (%2)") + .arg( app ).arg( TQString::number( pid ) ); + kdDebug() << "Lock::unlock(): " << mError << endl; + return false; + } + } + + mError = ""; + return true; +} + +TQString Lock::error() const +{ + return mError; +} + +#include "lock.moc" diff --git a/tdeabc/lock.h b/tdeabc/lock.h new file mode 100644 index 000000000..0b4c2ffe0 --- /dev/null +++ b/tdeabc/lock.h @@ -0,0 +1,88 @@ +/* + This file is part of libkabc. + + Copyright (c) 2001,2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_LOCK_H +#define KABC_LOCK_H + +#include <tqstring.h> +#include <tqobject.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** + This class provides locking functionality for a file, directory or an + arbitrary string-represented resource. +*/ +class KABC_EXPORT Lock : public TQObject +{ + Q_OBJECT + public: + /** + Constructor. + + @param identifier An identifier for the resource to be locked, e.g. a file + name. + */ + Lock( const TQString &identifier ); + + /** + Destruct lock object. This also removes the lock on the resource. + */ + ~Lock(); + + /** + Lock resource. + */ + virtual bool lock(); + + /** + Unlock resource. + */ + virtual bool unlock(); + + virtual TQString error() const; + + TQString lockFileName() const; + + static bool readLockFile( const TQString &filename, int &pid, TQString &app ); + static bool writeLockFile( const TQString &filename ); + + static TQString locksDir(); + + signals: + void locked(); + void unlocked(); + + private: + TQString mIdentifier; + + TQString mLockUniqueName; + + TQString mError; + + class Private; + Private *d; +}; + +} + +#endif diff --git a/tdeabc/locknull.cpp b/tdeabc/locknull.cpp new file mode 100644 index 000000000..c38bda0ce --- /dev/null +++ b/tdeabc/locknull.cpp @@ -0,0 +1,63 @@ +/* + This file is part of libkabc. + + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "locknull.h" + +#include <tdelocale.h> +#include <kdebug.h> + +using namespace TDEABC; + +LockNull::LockNull( bool allowAccess ) + : Lock( TQString::null ), mAllowAccess( allowAccess ) +{ +} + +LockNull::~LockNull() +{ + unlock(); +} + +bool LockNull::lock() +{ + if ( !mAllowAccess ) return false; + + kdWarning() << "LockNull::lock() force success. Doesn't actually lock." + << endl; + + emit locked(); + + return true; +} + +bool LockNull::unlock() +{ + emit unlocked(); + return true; +} + +TQString LockNull::error() const +{ + if ( mAllowAccess ) + return i18n("LockNull: All locks succeed but no actual locking is done."); + else + return i18n("LockNull: All locks fail."); +} diff --git a/tdeabc/locknull.h b/tdeabc/locknull.h new file mode 100644 index 000000000..fdc6e9aab --- /dev/null +++ b/tdeabc/locknull.h @@ -0,0 +1,54 @@ +/* + This file is part of libkabc. + + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_LOCKNULL_H +#define KABC_LOCKNULL_H + +#include <tqstring.h> + +#include "lock.h" + +namespace TDEABC { + +/** + This class provides a lock without actually locking. It can be constructed in + two ways: One that let all locks succeed and one that let all locks fail. +*/ +class KABC_EXPORT LockNull : public Lock +{ + public: + LockNull( bool allowAccess ); + ~LockNull(); + + bool lock(); + bool unlock(); + + TQString error() const; + + private: + bool mAllowAccess; + + class Private; + Private *d; +}; + +} + +#endif diff --git a/tdeabc/phonenumber.cpp b/tdeabc/phonenumber.cpp new file mode 100644 index 000000000..f6022052c --- /dev/null +++ b/tdeabc/phonenumber.cpp @@ -0,0 +1,213 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdeapplication.h> +#include <tdelocale.h> + +#include "phonenumber.h" + +using namespace TDEABC; + +PhoneNumber::PhoneNumber() : + mType( Home ) +{ + init(); +} + +PhoneNumber::PhoneNumber( const TQString &number, int type ) : + mType( type ) +{ + init(); + + validateNumber( number ); +} + +PhoneNumber::~PhoneNumber() +{ +} + +void PhoneNumber::init() +{ + mId = TDEApplication::randomString( 8 ); +} + +void PhoneNumber::validateNumber( const TQString &number ) +{ + mNumber = number; + + // remove line breaks + mNumber = mNumber.replace( '\n', "" ); + mNumber = mNumber.replace( '\r', "" ); +} + +bool PhoneNumber::operator==( const PhoneNumber &p ) const +{ + if ( mNumber != p.mNumber ) return false; + if ( mType != p.mType ) return false; + + return true; +} + +bool PhoneNumber::operator!=( const PhoneNumber &p ) const +{ + return !( p == *this ); +} + +void PhoneNumber::setId( const TQString &id ) +{ + mId = id; +} + +TQString PhoneNumber::id() const +{ + return mId; +} + +void PhoneNumber::setNumber( const TQString &number ) +{ + validateNumber( number ); +} + +TQString PhoneNumber::number() const +{ + return mNumber; +} + +void PhoneNumber::setType( int type ) +{ + mType = type; +} + +int PhoneNumber::type() const +{ + return mType; +} + +TQString PhoneNumber::typeLabel() const +{ + TQString label; + bool first = true; + + const TypeList list = typeList(); + + TypeList::ConstIterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { + label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); + if ( first ) + first = false; + } + } + + return label; +} + +TQString PhoneNumber::label() const +{ + return typeLabel( type() ); +} + +PhoneNumber::TypeList PhoneNumber::typeList() +{ + static TypeList list; + + if ( list.isEmpty() ) { + list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video + << Bbs << Modem << Car << Isdn << Pcs << Pager; + } + + return list; +} + +TQString PhoneNumber::label( int type ) +{ + return typeLabel( type ); +} + +TQString PhoneNumber::typeLabel( int type ) +{ + if ( type & Pref ) + return i18n( "Preferred phone", "Preferred" ); + + switch ( type ) { + case Home: + return i18n("Home phone", "Home"); + break; + case Work: + return i18n("Work phone", "Work"); + break; + case Msg: + return i18n("Messenger"); + break; + case Pref: + return i18n("Preferred Number"); + break; + case Voice: + return i18n("Voice"); + break; + case Fax: + return i18n("Fax"); + break; + case Cell: + return i18n("Mobile Phone", "Mobile" ); + break; + case Video: + return i18n("Video"); + break; + case Bbs: + return i18n("Mailbox"); + break; + case Modem: + return i18n("Modem"); + break; + case Car: + return i18n("Car Phone", "Car" ); + break; + case Isdn: + return i18n("ISDN"); + break; + case Pcs: + return i18n("PCS"); + break; + case Pager: + return i18n("Pager"); + break; + case Home | Fax: + return i18n("Home Fax"); + break; + case Work | Fax: + return i18n("Work Fax"); + break; + default: + return i18n("Other"); + } +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const PhoneNumber &phone ) +{ + return s << phone.mId << phone.mType << phone.mNumber; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, PhoneNumber &phone ) +{ + s >> phone.mId >> phone.mType >> phone.mNumber; + + return s; +} diff --git a/tdeabc/phonenumber.h b/tdeabc/phonenumber.h new file mode 100644 index 000000000..737f57ff8 --- /dev/null +++ b/tdeabc/phonenumber.h @@ -0,0 +1,161 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_PHONENUMBER_H +#define KABC_PHONENUMBER_H + +#include <tqvaluelist.h> +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** + @short Phonenumber information. + + This class provides phone number information. A phone number is classified by + a type. The following types are available, it's possible to use multiple types + Types for a number by combining them through a logical or. +*/ +class KABC_EXPORT PhoneNumber +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const PhoneNumber & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, PhoneNumber & ); + + public: + typedef TQValueList<PhoneNumber> List; + typedef TQValueList<int> TypeList; + + /** + @li @p Home - Home number + @li @p Work - Office number + @li @p Msg - Messaging + @li @p Pref - Preferred number + @li @p Voice - Voice + @li @p Fax - Fax machine + @li @p Cell - Cell phone + @li @p Video - Video phone + @li @p Bbs - Mailbox + @li @p Modem - Modem + @li @p Car - Car phone + @li @p Isdn - ISDN connection + @li @p Pcs - Personal Communication Service + @li @p Pager - Pager + */ + enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, + Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, + Isdn = 2048, Pcs = 4096, Pager = 8192 }; + + /** + Create an empty phone number object. + */ + PhoneNumber(); + + /** + Create a phonenumber object. + + @param number Number + @param type Type as defined in enum. Multiple types can be + specified by combining them by a logical or. + */ + PhoneNumber( const TQString &number, int type = Home ); + + /** + Destructor. + */ + ~PhoneNumber(); + + bool operator==( const PhoneNumber & ) const; + bool operator!=( const PhoneNumber & ) const; + + /** + Sets the unique identifier. + */ + void setId( const TQString &id ); + + /** + Returns the unique identifier. + */ + TQString id() const; + + /** + Sets the number. + */ + void setNumber( const TQString & ); + + /** + Returns the number. + */ + TQString number() const; + + /** + Sets the type. Multiple types can be specified by combining them by + a logical or. + */ + void setType( int ); + + /** + Returns the type. Can be a multiple types combined by a logical or. + */ + int type() const; + + /** + Returns a translated string of all types the address has. + */ + TQString typeLabel() const; + + /** + Returns the translated label for phone number depending on its type. + */ + TQString label() const; + + /** + Returns a list of all available types + */ + static TypeList typeList(); + + /** + Returns the translated label for phone number type. + */ + static TQString typeLabel( int type ); + + /** + Returns the translated label for phone number type. + @obsolete + */ + static TQString label( int type ); + + private: + void init(); + void validateNumber( const TQString& ); + + TQString mId; + + int mType; + TQString mNumber; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const PhoneNumber & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, PhoneNumber & ); + +} + +#endif diff --git a/tdeabc/picture.cpp b/tdeabc/picture.cpp new file mode 100644 index 000000000..057be604c --- /dev/null +++ b/tdeabc/picture.cpp @@ -0,0 +1,120 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "picture.h" + +using namespace TDEABC; + +Picture::Picture() + : mIntern( false ) +{ +} + +Picture::Picture( const TQString &url ) + : mUrl( url ), mIntern( false ) +{ +} + +Picture::Picture( const TQImage &data ) + : mData( data ), mIntern( true ) +{ +} + +Picture::~Picture() +{ +} + +bool Picture::operator==( const Picture &p ) const +{ + if ( mIntern != p.mIntern ) return false; + + if ( mIntern ) { + if ( mData != p.mData ) + return false; + } else { + if ( mUrl != p.mUrl ) + return false; + } + + return true; +} + +bool Picture::operator!=( const Picture &p ) const +{ + return !( p == *this ); +} + +void Picture::setUrl( const TQString &url ) +{ + mUrl = url; + mIntern = false; +} + +void Picture::setData( const TQImage &data ) +{ + mData = data; + mIntern = true; +} + +void Picture::setType( const TQString &type ) +{ + mType = type; +} + +bool Picture::isIntern() const +{ + return mIntern; +} + +TQString Picture::url() const +{ + return mUrl; +} + +TQImage Picture::data() const +{ + return mData; +} + +TQString Picture::type() const +{ + return mType; +} + +TQString Picture::asString() const +{ + if ( mIntern ) + return "intern picture"; + else + return mUrl; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Picture &picture ) +{ + return s << picture.mIntern << picture.mUrl << picture.mType; +// return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Picture &picture ) +{ + s >> picture.mIntern >> picture.mUrl >> picture.mType; +// s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; + return s; +} diff --git a/tdeabc/picture.h b/tdeabc/picture.h new file mode 100644 index 000000000..ca8f086ed --- /dev/null +++ b/tdeabc/picture.h @@ -0,0 +1,128 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_PICTURE_H +#define KABC_PICTURE_H + +#include <tqimage.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +class KABC_EXPORT Picture +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Picture & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Picture & ); + +public: + + /** + * Consturctor. Creates an empty object. + */ + Picture(); + + /** + * Consturctor. + * + * @param url A URL that describes the position of the picture file. + */ + Picture( const TQString &url ); + + /** + * Consturctor. + * + * @param data The raw data of the picture. + */ + Picture( const TQImage &data ); + + /** + * Destructor. + */ + ~Picture(); + + + bool operator==( const Picture & ) const; + bool operator!=( const Picture & ) const; + + /** + * Sets a URL for the location of the picture file. When using this + * function, isIntern() will return 'false' until you use + * setData(). + * + * @param url The location URL of the picture file. + */ + void setUrl( const TQString &url ); + + /** + * Sets the raw data of the picture. When using this function, + * isIntern() will return 'true' until you use setUrl(). + * + * @param data The raw data of the picture. + */ + void setData( const TQImage &data ); + + /** + * Sets the type of the picture. + */ + void setType( const TQString &type ); + + /** + * Returns whether the picture is described by a URL (extern) or + * by the raw data (intern). + * When this method returns 'true' you can use data() to + * get the raw data. Otherwise you can request the URL of this + * picture by url() and load the raw data from that location. + */ + bool isIntern() const; + + /** + * Returns the location URL of this picture. + */ + TQString url() const; + + /** + * Returns the raw data of this picture. + */ + TQImage data() const; + + /** + * Returns the type of this picture. + */ + TQString type() const; + + /** + * Returns string representation of the picture. + */ + TQString asString() const; + +private: + TQString mUrl; + TQString mType; + TQImage mData; + + int mIntern; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Picture & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Picture & ); + +} +#endif diff --git a/tdeabc/plugin.cpp b/tdeabc/plugin.cpp new file mode 100644 index 000000000..9c1453bc5 --- /dev/null +++ b/tdeabc/plugin.cpp @@ -0,0 +1,61 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "plugin.h" + +using namespace TDEABC; + +Plugin::Plugin() +{ +} + +Plugin::~Plugin() +{ +} + +void Plugin::setType( const TQString& type ) +{ + mType = type; +} + +TQString Plugin::type() const +{ + return mType; +} + +void Plugin::setNameLabel( const TQString& label ) +{ + mNameLabel = label; +} + +TQString Plugin::nameLabel() const +{ + return mNameLabel; +} + +void Plugin::setDescriptionLabel( const TQString& label ) +{ + mDescriptionLabel = label; +} + +TQString Plugin::descriptionLabel() const +{ + return mDescriptionLabel; +} diff --git a/tdeabc/plugin.h b/tdeabc/plugin.h new file mode 100644 index 000000000..b242e5a8c --- /dev/null +++ b/tdeabc/plugin.h @@ -0,0 +1,52 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_PLUGIN_H +#define KABC_PLUGIN_H + +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +class KABC_EXPORT Plugin +{ +public: + Plugin(); + virtual ~Plugin(); + + virtual void setType( const TQString& type ); + virtual TQString type() const; + + virtual void setNameLabel( const TQString& label ); + virtual TQString nameLabel() const; + + virtual void setDescriptionLabel( const TQString& label ); + virtual TQString descriptionLabel() const; + +private: + TQString mType; + TQString mNameLabel; + TQString mDescriptionLabel; +}; + +} +#endif diff --git a/tdeabc/plugins/CMakeLists.txt b/tdeabc/plugins/CMakeLists.txt new file mode 100644 index 000000000..597486816 --- /dev/null +++ b/tdeabc/plugins/CMakeLists.txt @@ -0,0 +1,15 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( file ) +add_subdirectory( dir ) +add_subdirectory( net ) +add_subdirectory( ldaptdeio ) diff --git a/tdeabc/plugins/Makefile.am b/tdeabc/plugins/Makefile.am new file mode 100644 index 000000000..bdedbec0f --- /dev/null +++ b/tdeabc/plugins/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = file dir net ldaptdeio diff --git a/tdeabc/plugins/dir/CMakeLists.txt b/tdeabc/plugins/dir/CMakeLists.txt new file mode 100644 index 000000000..322c659d4 --- /dev/null +++ b/tdeabc/plugins/dir/CMakeLists.txt @@ -0,0 +1,73 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdeabc + ${CMAKE_SOURCE_DIR}/tdeabc + + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + resourcedir.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### other data ################################ + +install( FILES dir.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/tdeabc ) + + +##### tdeabc_dir (library) ######################## + +set( target tdeabc_dir ) + +set( ${target}_SRCS + resourcedir.cpp resourcedirconfig.cpp +) + +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION 1.0.0 + LINK tdeabc-shared + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### tdeabc_dir (module) ######################### + +set( target tdeabc_dir ) + +set( ${target}_SRCS + resourcedirplugin.cpp +) + +tde_add_kpart( ${target} + SOURCES ${${target}_SRCS} + LINK tdeabc_dir-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeabc/plugins/dir/Makefile.am b/tdeabc/plugins/dir/Makefile.am new file mode 100644 index 000000000..d054bbaf9 --- /dev/null +++ b/tdeabc/plugins/dir/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc -I$(top_builddir) $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourcedirconfig.h + +lib_LTLIBRARIES = libtdeabc_dir.la +libtdeabc_dir_la_SOURCES = resourcedir.cpp resourcedirconfig.cpp +libtdeabc_dir_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined +libtdeabc_dir_la_LIBADD = $(LIB_TDEABC) $(LIB_QT) $(top_builddir)/tderesources/libtderesources.la $(LIB_TDECORE) $(LIB_TDEFILE) $(LIB_TDEUI) +libtdeabc_dir_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + +kde_module_LTLIBRARIES = tdeabc_dir.la +tdeabc_dir_la_SOURCES = resourcedirplugin.cpp +tdeabc_dir_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +tdeabc_dir_la_LIBADD = libtdeabc_dir.la $(LIB_QT) $(LIB_TDECORE) + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_dir.pot + +kabcincludedir = $(includedir)/tdeabc +kabcinclude_HEADERS = resourcedir.h + +servicedir = $(kde_servicesdir)/tderesources/tdeabc +service_DATA = dir.desktop + +resourcedirplugin.lo: ../../addressee.h diff --git a/tdeabc/plugins/dir/dir.desktop b/tdeabc/plugins/dir/dir.desktop new file mode 100644 index 000000000..292815637 --- /dev/null +++ b/tdeabc/plugins/dir/dir.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Name=Directory +Name[af]=Gids +Name[ar]=دليل +Name[az]=Cərgə +Name[be]=Тэчка +Name[bn]=ডিরেক্টরি +Name[br]=Renkell +Name[bs]=Direktorij +Name[ca]=Directori +Name[cs]=Adresář +Name[csb]=Katalog +Name[cy]=Cyfeiriadur +Name[da]=Mappe +Name[de]=Verzeichnis +Name[el]=Κατάλογος +Name[eo]=Dosierujo +Name[es]=Directorio +Name[et]=Kataloog +Name[eu]=Direktorioa +Name[fa]=فهرست راهنما +Name[fi]=Hakemisto +Name[fo]=Fíluskrá +Name[fr]=Dossier +Name[fy]=Map +Name[ga]=Comhadlann +Name[gl]=Directório +Name[he]=ספריה +Name[hi]=डिरेक्ट्री +Name[hr]=Mapa +Name[hsb]=Zapisk +Name[hu]=Könyvtár +Name[id]=Direktori +Name[is]=Mappa +Name[it]=Cartella +Name[ja]=ディレクトリ +Name[ka]=დასტა +Name[kk]=Каталог +Name[km]=ថត +Name[ko]=자료방 +Name[ku]=Peldank +Name[lb]=Verzeechnis +Name[lt]=Aplankas +Name[lv]=Direktorija +Name[mk]=Именик +Name[mn]=Лавлах +Name[ms]=Direktori +Name[mt]=Direttorju +Name[nb]=Katalog +Name[nds]=Orner +Name[ne]=डाइरेक्टरी +Name[nl]=Map +Name[nn]=Katalog +Name[nso]=Tshupetso +Name[oc]=Directori +Name[pa]=ਡਾਇਰੈਕਟਰੀ +Name[pl]=Katalog +Name[pt]=Directoria +Name[pt_BR]=Diretório +Name[ro]=Director +Name[ru]=Каталог +Name[rw]=ububiko +Name[se]=Ohcu +Name[sk]=Priečinok +Name[sl]=Imenik +Name[sq]=Fioka +Name[sr]=Фасцикла +Name[sr@Latn]=Fascikla +Name[ss]=I-directory +Name[sv]=Katalog +Name[ta]=அடைவு +Name[te]=డైరక్టరి +Name[tg]=Феҳраст +Name[th]=ไดเรกทอรี +Name[tr]=Dizin +Name[tt]=Törgäk +Name[uk]=Каталог +Name[uz]=Jild +Name[uz@cyrillic]=Жилд +Name[ven]=Tsumbavhulwo +Name[vi]=Thư mục +Name[wa]=Ridant +Name[xh]=Ulawulo +Name[zh_CN]=目录 +Name[zh_HK]=目錄 +Name[zh_TW]=目錄 +Name[zu]=Uhlu lwamafayela +X-TDE-Library=tdeabc_dir +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=dir diff --git a/tdeabc/plugins/dir/resourcedir.cpp b/tdeabc/plugins/dir/resourcedir.cpp new file mode 100644 index 000000000..eaf774066 --- /dev/null +++ b/tdeabc/plugins/dir/resourcedir.cpp @@ -0,0 +1,310 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 - 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <errno.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <tqregexp.h> +#include <tqtimer.h> +#include <tqwidget.h> + +#include <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kurlrequester.h> + +#include "addressbook.h" +#include "formatfactory.h" +#include "resourcedirconfig.h" +#include "stdaddressbook.h" +#include "lock.h" + +#include "resourcedir.h" + +using namespace TDEABC; + +extern "C" +{ + void *init_tdeabc_dir() + { + return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); + } +} + + +ResourceDir::ResourceDir( const TDEConfig *config ) + : Resource( config ), mAsynchronous( false ) +{ + if ( config ) { + init( config->readPathEntry( "FilePath", StdAddressBook::directoryName() ), + config->readEntry( "FileFormat", "vcard" ) ); + } else { + init( StdAddressBook::directoryName(), "vcard" ); + } +} + +ResourceDir::ResourceDir( const TQString &path, const TQString &format ) + : Resource( 0 ), mAsynchronous( false ) +{ + init( path, format ); +} + +void ResourceDir::init( const TQString &path, const TQString &format ) +{ + mFormatName = format; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); + + if ( !mFormat ) { + mFormatName = "vcard"; + mFormat = factory->format( mFormatName ); + } + + mLock = 0; + + connect( &mDirWatch, TQT_SIGNAL( dirty(const TQString&) ), TQT_SLOT( pathChanged() ) ); + connect( &mDirWatch, TQT_SIGNAL( created(const TQString&) ), TQT_SLOT( pathChanged() ) ); + connect( &mDirWatch, TQT_SIGNAL( deleted(const TQString&) ), TQT_SLOT( pathChanged() ) ); + + setPath( path ); +} + +ResourceDir::~ResourceDir() +{ + delete mFormat; + mFormat = 0; +} + +void ResourceDir::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + if ( mPath == StdAddressBook::directoryName() ) + config->deleteEntry( "FilePath" ); + else + config->writePathEntry( "FilePath", mPath ); + + config->writeEntry( "FileFormat", mFormatName ); +} + +Ticket *ResourceDir::requestSaveTicket() +{ + kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl; + + if ( !addressBook() ) return 0; + + delete mLock; + mLock = new Lock( mPath ); + + if ( mLock->lock() ) { + addressBook()->emitAddressBookLocked(); + } else { + addressBook()->error( mLock->error() ); + kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock path '" + << mPath << "': " << mLock->error() << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceDir::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; + + delete mLock; + mLock = 0; +} + +bool ResourceDir::doOpen() +{ + TQDir dir( mPath ); + if ( !dir.exists() ) { // no directory available + return dir.mkdir( dir.path() ); + } else { + TQString testName = dir.entryList( TQDir::Files )[0]; + if ( testName.isNull() || testName.isEmpty() ) // no file in directory + return true; + + TQFile file( mPath + "/" + testName ); + if ( file.open( IO_ReadOnly ) ) + return true; + + if ( file.size() == 0 ) + return true; + + bool ok = mFormat->checkFormat( &file ); + file.close(); + return ok; + } +} + +void ResourceDir::doClose() +{ +} + +bool ResourceDir::load() +{ + kdDebug(5700) << "ResourceDir::load(): '" << mPath << "'" << endl; + + mAsynchronous = false; + + TQDir dir( mPath ); + TQStringList files = dir.entryList( TQDir::Files ); + + TQStringList::Iterator it; + bool ok = true; + for ( it = files.begin(); it != files.end(); ++it ) { + TQFile file( mPath + "/" + (*it) ); + + if ( !file.open( IO_ReadOnly ) ) { + addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) ); + ok = false; + continue; + } + + if ( !mFormat->loadAll( addressBook(), this, &file ) ) + ok = false; + + file.close(); + } + + return ok; +} + +bool ResourceDir::asyncLoad() +{ + mAsynchronous = true; + + bool ok = load(); + if ( !ok ) + emit loadingError( this, i18n( "Loading resource '%1' failed!" ) + .arg( resourceName() ) ); + else + emit loadingFinished( this ); + + return ok; +} + +bool ResourceDir::save( Ticket * ) +{ + kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl; + + Addressee::Map::Iterator it; + bool ok = true; + + mDirWatch.stopScan(); + + for ( it = mAddrMap.begin(); it != mAddrMap.end(); ++it ) { + if ( !it.data().changed() ) + continue; + + TQFile file( mPath + "/" + (*it).uid() ); + if ( !file.open( IO_WriteOnly ) ) { + addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); + continue; + } + + mFormat->save( *it, &file ); + + // mark as unchanged + (*it).setChanged( false ); + + file.close(); + } + + mDirWatch.startScan(); + + return ok; +} + +bool ResourceDir::asyncSave( Ticket *ticket ) +{ + bool ok = save( ticket ); + if ( !ok ) + emit savingError( this, i18n( "Saving resource '%1' failed!" ) + .arg( resourceName() ) ); + else + emit savingFinished( this ); + + return ok; +} + +void ResourceDir::setPath( const TQString &path ) +{ + mDirWatch.stopScan(); + if ( mDirWatch.contains( mPath ) ) + mDirWatch.removeDir( mPath ); + + mPath = path; + mDirWatch.addDir( mPath, true ); + mDirWatch.startScan(); +} + +TQString ResourceDir::path() const +{ + return mPath; +} + +void ResourceDir::setFormat( const TQString &format ) +{ + mFormatName = format; + + if ( mFormat ) + delete mFormat; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); +} + +TQString ResourceDir::format() const +{ + return mFormatName; +} + +void ResourceDir::pathChanged() +{ + if ( !addressBook() ) + return; + + clear(); + if ( mAsynchronous ) + asyncLoad(); + else { + load(); + addressBook()->emitAddressBookChanged(); + } +} + +void ResourceDir::removeAddressee( const Addressee& addr ) +{ + TQFile::remove( mPath + "/" + addr.uid() ); + mAddrMap.erase( addr.uid() ); +} + +#include "resourcedir.moc" diff --git a/tdeabc/plugins/dir/resourcedir.h b/tdeabc/plugins/dir/resourcedir.h new file mode 100644 index 000000000..035b8a6ae --- /dev/null +++ b/tdeabc/plugins/dir/resourcedir.h @@ -0,0 +1,113 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 - 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCEDIR_H +#define KABC_RESOURCEDIR_H + +#include <tdeconfig.h> +#include <kdirwatch.h> + +#include <sys/types.h> + +#include <tdeabc/resource.h> + +class TQTimer; + +namespace TDEABC { + +class FormatPlugin; +class Lock; + +/** + @internal +*/ +class KABC_EXPORT ResourceDir : public Resource +{ + Q_OBJECT + + public: + ResourceDir( const TDEConfig* ); + ResourceDir( const TQString &path, const TQString &type = "vcard" ); + ~ResourceDir(); + + virtual void writeConfig( TDEConfig* ); + + virtual bool doOpen(); + virtual void doClose(); + + virtual Ticket *requestSaveTicket(); + virtual void releaseSaveTicket( Ticket* ); + + virtual bool load(); + virtual bool asyncLoad(); + virtual bool save( Ticket* ticket ); + virtual bool asyncSave( Ticket* ticket ); + + /** + Set path to be used for saving. + */ + void setPath( const TQString & ); + + /** + Return path used for loading and saving the address book. + */ + TQString path() const; + + /** + Set the format by name. + */ + void setFormat( const TQString &format ); + + /** + Returns the format name. + */ + TQString format() const; + + /** + Remove a addressee from its source. + This method is mainly called by TDEABC::AddressBook. + */ + virtual void removeAddressee( const Addressee& addr ); + + protected slots: + void pathChanged(); + + protected: + void init( const TQString &path, const TQString &format ); + + private: + FormatPlugin *mFormat; + + KDirWatch mDirWatch; + + TQString mPath; + TQString mFormatName; + + Lock *mLock; + + bool mAsynchronous; + + class ResourceDirPrivate; + ResourceDirPrivate *d; +}; + +} + +#endif diff --git a/tdeabc/plugins/dir/resourcedirconfig.cpp b/tdeabc/plugins/dir/resourcedirconfig.cpp new file mode 100644 index 000000000..212ef6156 --- /dev/null +++ b/tdeabc/plugins/dir/resourcedirconfig.cpp @@ -0,0 +1,107 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlabel.h> +#include <tqlayout.h> + +#include <kdebug.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kdialog.h> + +#include "formatfactory.h" +#include "resourcedir.h" +#include "stdaddressbook.h" + +#include "resourcedirconfig.h" + +using namespace TDEABC; + +ResourceDirConfig::ResourceDirConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0, + KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "Format:" ), this ); + mFormatBox = new KComboBox( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mFormatBox, 0, 1 ); + + label = new TQLabel( i18n( "Location:" ), this ); + mFileNameEdit = new KURLRequester( this ); + mFileNameEdit->setMode( KFile::Directory ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mFileNameEdit, 1, 1 ); + + FormatFactory *factory = FormatFactory::self(); + TQStringList formats = factory->formats(); + TQStringList::Iterator it; + for ( it = formats.begin(); it != formats.end(); ++it ) { + FormatInfo *info = factory->info( *it ); + if ( info ) { + mFormatTypes << (*it); + mFormatBox->insertItem( info->nameLabel ); + } + } + + mInEditMode = false; +} + +void ResourceDirConfig::setEditMode( bool value ) +{ + mFormatBox->setEnabled( !value ); + mInEditMode = value; +} + +void ResourceDirConfig::loadSettings( KRES::Resource *res ) +{ + ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; + return; + } + + mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); + + mFileNameEdit->setURL( resource->path() ); + if ( mFileNameEdit->url().isEmpty() ) + mFileNameEdit->setURL( TDEABC::StdAddressBook::directoryName() ); +} + +void ResourceDirConfig::saveSettings( KRES::Resource *res ) +{ + ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; + return; + } + + if ( mInEditMode ) + resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); + + resource->setPath( mFileNameEdit->url() ); +} + +#include "resourcedirconfig.moc" diff --git a/tdeabc/plugins/dir/resourcedirconfig.h b/tdeabc/plugins/dir/resourcedirconfig.h new file mode 100644 index 000000000..98efd76d0 --- /dev/null +++ b/tdeabc/plugins/dir/resourcedirconfig.h @@ -0,0 +1,54 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCEDIRCONFIG_H +#define RESOURCEDIRCONFIG_H + +#include <kcombobox.h> +#include <kurlrequester.h> + +#include <tderesources/configwidget.h> + +namespace TDEABC { + +class KABC_EXPORT ResourceDirConfig : public KRES::ConfigWidget +{ + Q_OBJECT + +public: + ResourceDirConfig( TQWidget* parent = 0, const char* name = 0 ); + + void setEditMode( bool value ); + +public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + +private: + KComboBox* mFormatBox; + KURLRequester* mFileNameEdit; + + TQStringList mFormatTypes; + + bool mInEditMode; +}; + +} +#endif diff --git a/tdeabc/plugins/dir/resourcedirplugin.cpp b/tdeabc/plugins/dir/resourcedirplugin.cpp new file mode 100644 index 000000000..5662a7062 --- /dev/null +++ b/tdeabc/plugins/dir/resourcedirplugin.cpp @@ -0,0 +1,32 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 - 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "resourcedir.h" +#include "resourcedirconfig.h" + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_dir() + { + return new KRES::PluginFactory<ResourceDir, ResourceDirConfig>(); + } +} diff --git a/tdeabc/plugins/evolution/Makefile.am b/tdeabc/plugins/evolution/Makefile.am new file mode 100644 index 000000000..67a5a64b8 --- /dev/null +++ b/tdeabc/plugins/evolution/Makefile.am @@ -0,0 +1,19 @@ +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourceevo.h dbwrapper.h + +kde_module_LTLIBRARIES = tdeabc_evo.la + +tdeabc_evo_la_SOURCES = dbwrapper.cpp resourceevo.cpp + +tdeabc_evo_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +tdeabc_evo_la_LIBADD = ../../../tdeabc/libkabc.la ../../../tdeui/libtdeui.la -ldb ../../../tdeabc/vcardparser/libvcards.la + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_evolution.pot + +servicedir = $(kde_servicesdir)/tderesources/tdeabc +service_DATA = evolution.desktop diff --git a/tdeabc/plugins/evolution/README b/tdeabc/plugins/evolution/README new file mode 100644 index 000000000..7dfefce00 --- /dev/null +++ b/tdeabc/plugins/evolution/README @@ -0,0 +1,15 @@ +A Resource using DB3 to access the evolution +addressbook make sure the wombat is not running +In future versions I may use bonobo to access it... + + +DESIGN: +The Format vs Resource idea is somehow not applyable to the +Evolution PAS + +Format would be vCard and Resource would be DB3.. +BUT +Format get's a QFile* pointer which is just not usable +with a DB3 +INSTEAD we will use the vCardImpl directly to convert +a string to Addressee
\ No newline at end of file diff --git a/tdeabc/plugins/evolution/dbwrapper.cpp b/tdeabc/plugins/evolution/dbwrapper.cpp new file mode 100644 index 000000000..fbdff165a --- /dev/null +++ b/tdeabc/plugins/evolution/dbwrapper.cpp @@ -0,0 +1,187 @@ +#include <db.h> + +#include <tqfile.h> + +#include "dbwrapper.h" + + +using namespace Evolution; + +struct DBIterator::Data { + DBWrapper *wrapper; + TQString key; + TQString data; + DBC* cursor; + bool atEnd; +}; + +DBIterator::DBIterator( DBWrapper* wra) { + data = new Data; + data->wrapper = wra; + data->atEnd = false; + data->cursor = 0l; +} +DBIterator::DBIterator( const DBIterator& copy ) { + data = new Data; + data->wrapper = copy.data->wrapper; + data->key = copy.data->key; + data->data = copy.data->data; + data->atEnd = copy.data->atEnd; + if (copy.data->cursor ) + copy.data->cursor->c_dup(copy.data->cursor, &data->cursor, 0 ); + else + data->cursor = 0l; +} +DBIterator::~DBIterator() { + if (data->cursor) + data->cursor->c_close(data->cursor); + delete data; +} +DBIterator& DBIterator::operator=( const DBIterator& rhs ) { + if ( *this == rhs ) + return *this; + if (data->cursor) + data->cursor->c_close(data->cursor); + delete data; + data = new Data; + data->wrapper = rhs.data->wrapper; + data->key = rhs.data->key; + data->data = rhs.data->data; + data->atEnd = rhs.data->atEnd; + if ( rhs.data->cursor ) + rhs.data->cursor->c_dup(rhs.data->cursor, &data->cursor, 0 ); + else + data->cursor = 0l; + + return *this; +} +TQString DBIterator::key()const{ + return data->key; +} +TQString DBIterator::value()const { + return data->data; +} +TQString DBIterator::operator*() { + return data->data; +} +DBIterator& DBIterator::operator++() { + DBT key, val; + ::memset(&key, 0, sizeof(key) ); + ::memset(&val, 0, sizeof(val) ); + if ( data->cursor ) + if ( data->cursor->c_get(data->cursor, &key, &val,DB_NEXT ) != 0 ) + data->atEnd = true; + data->key = TQString::fromUtf8( (char*)key.data, key.size ); + data->data = TQString::fromUtf8( (char*)val.data, val.size ); + return *this; +} +DBIterator& DBIterator::operator--() { + DBT key, val; + ::memset(&key, 0, sizeof(key) ); + ::memset(&val, 0, sizeof(val) ); + if ( data->cursor ) + if ( data->cursor->c_get(data->cursor, &key, &val,DB_PREV ) != 0 ) + data->atEnd = true; + data->key = TQString::fromUtf8( (char*)key.data, key.size ); + data->data = TQString::fromUtf8( (char*)val.data, val.size ); + return *this; +} +bool DBIterator::operator==( const DBIterator& rhs ) { + if ( data->atEnd && data->atEnd == rhs.data->atEnd ) return true; + + return false; +} +bool DBIterator::operator!=( const DBIterator& rhs ) { + return !this->operator==(rhs ); +} +struct DBWrapper::Data { + DB* db; + bool only; +}; +DBWrapper::DBWrapper() { + data = new Data; + (void)db_create(&data->db, NULL, 0 ); + data->only = false; +} +DBWrapper::~DBWrapper() { + data->db->close(data->db, 0 ); + delete data; +} +bool DBWrapper::open( const TQString& file, bool on) { + data->only = on; + return !data->db->open(data->db, TQFile::encodeName( file ), NULL, DB_HASH, 0, 0666 ); +} +bool DBWrapper::save() { + return true; +} +DBIterator DBWrapper::begin() { + DBIterator it(this); + DBC* cursor; + DBT key, val; + int ret; + ret = data->db->cursor(data->db, NULL, &cursor, 0 ); + if (ret ) { + it.data->atEnd = true; + return it; + } + + ::memset(&key, 0, sizeof(key) ); + ::memset(&val, 0, sizeof(val) ); + ret = cursor->c_get(cursor, &key, &val, DB_FIRST ); + if (ret ) { + it.data->atEnd = true; + return it; + } + + it.data->cursor = cursor; + it.data->key = TQString::fromUtf8((char*)key.data, key.size ); + it.data->data = TQString::fromUtf8((char*)val.data, val.size ); + + return it; +} +DBIterator DBWrapper::end() { + DBIterator it(this); + it.data->atEnd = true; + + return it; +} +bool DBWrapper::find( const TQString& _key, TQString& _val ) { + DBT key, val; + ::memset(&key, 0, sizeof(key) ); + ::memset(&val, 0, sizeof(val) ); + + TQCString db_key = _key.local8Bit(); + key.data = db_key.data(); + key.size = db_key.size(); + + int ret = data->db->get(data->db, NULL, &key, &val, 0 ); + if (!ret) { + _val = TQString::fromUtf8( (char*)val.data, val.size ); + tqWarning("key: %s val: %sXXX", (char*)key.data, (char*)val.data ); + return true; + } + return false; +} +bool DBWrapper::add( const TQString& _key, const TQString& _val ) { + TQCString db_key = _key.local8Bit(); + TQCString db_val = _val.local8Bit(); + DBT key, val; + ::memset(&key, 0, sizeof(key) ); + ::memset(&val, 0, sizeof(val) ); + + key.data = db_key.data(); + key.size = db_key.size(); + val.data = db_val.data(); + val.size = db_val.size(); + + return !data->db->put(data->db, NULL, &key, &val, 0 ); +} +bool DBWrapper::remove( const TQString& _key ) { + TQCString db_key = _key.local8Bit(); + DBT key; + memset(&key, 0, sizeof(key) ); + key.data = db_key.data(); + key.size = db_key.size(); + + return !data->db->del(data->db, NULL, &key, 0 ); +} diff --git a/tdeabc/plugins/evolution/dbwrapper.h b/tdeabc/plugins/evolution/dbwrapper.h new file mode 100644 index 000000000..e5e0a2c33 --- /dev/null +++ b/tdeabc/plugins/evolution/dbwrapper.h @@ -0,0 +1,60 @@ +#ifndef KABC_EVOLUTION_DB_WRAPPER +#define KABC_EVOLUTION_DB_WRAPPER + +#include <db.h> + +#include <tqstring.h> +#include <tqpair.h> + +namespace Evolution { + + class DBWrapper; + class DBIterator { + friend class DBWrapper; + public: + DBIterator( DBWrapper* = 0l ); + ~DBIterator(); + + DBIterator( const DBIterator& ); + DBIterator &operator=( const DBIterator& ); + + TQString key()const; + TQString value()const; + + TQString operator*(); + + DBIterator &operator++(); + DBIterator &operator--(); + + bool operator==( const DBIterator& ); + bool operator!=( const DBIterator& ); + private: + struct Data; + Data* data; + }; + class DBWrapper { + public: + DBWrapper(); + ~DBWrapper(); + + TQString lastError()const; + + bool open( const TQString& file, bool readOnly = false); + bool save(); + DBIterator begin(); + DBIterator end(); + + bool find( const TQString& key, TQString& value ); + bool add( const TQString& key, const TQString& val ); + bool remove( const TQString& key ); + private: + // DBT element( const TQString& ); + struct Data; + Data* data; + + }; + +} + + +#endif diff --git a/tdeabc/plugins/evolution/evolution.desktop b/tdeabc/plugins/evolution/evolution.desktop new file mode 100644 index 000000000..6893abdad --- /dev/null +++ b/tdeabc/plugins/evolution/evolution.desktop @@ -0,0 +1,26 @@ +[Desktop Entry] +Name=Evolution +Name[be]=Эвалюцыя +Name[bn]=ইভোলিউশন +Name[eo]=Evoluo +Name[fa]=اوولوشن +Name[hi]=एवॉल्यूशन +Name[ko]=에볼루션 +Name[mn]=Хөгжил +Name[ne]=इभोल्युसन +Name[pa]=ਏਵੂਲੇਸ਼ਨ +Name[sr]=Еволуција +Name[sr@Latn]=Evolucija +Name[ta]=படிப்படியான வளர்ச்சி +Name[te]=ఎవల్యుషన్ +Name[th]=เอฟโวลูชัน +Name[tt]=Üseş +Name[ven]=Tsikoni +Name[wa]=Evolucion +Name[xh]=Utshintsho lwendawo ngokwenqanawa +Name[zu]=Evolushini +X-TDE-Library=tdeabc_evo +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=evolution diff --git a/tdeabc/plugins/evolution/resourceevo.cpp b/tdeabc/plugins/evolution/resourceevo.cpp new file mode 100644 index 000000000..a5df5fe18 --- /dev/null +++ b/tdeabc/plugins/evolution/resourceevo.cpp @@ -0,0 +1,132 @@ +#include <tqdir.h> + +#include <tdeglobal.h> +#include <tdelocale.h> +#include <kdebug.h> + +#include <stdio.h> + +#include <tdeabc/vcardparser/vcardtool.h> + +#include "dbwrapper.h" +#include "resourceevo.h" + +using namespace Evolution; +using namespace TDEABC; + +class EvolutionFactory : public KRES::PluginFactoryBase +{ + public: + KRES::Resource *resource( const TDEConfig *config ) + { + return new ResourceEvolution( config ); + } + + KRES::ConfigWidget *configWidget( TQWidget * ) + { + return 0; + } +}; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_evo() + { + return ( new EvolutionFactory() ); + } +} + +ResourceEvolution::ResourceEvolution( const TDEConfig* conf ) + : Resource( conf ), mWrap(0l) +{ + m_isOpen = false; +} +ResourceEvolution::~ResourceEvolution() { + delete mWrap; +} +bool ResourceEvolution::doOpen() { + mWrap = new DBWrapper; + if (!mWrap->open( TQDir::homeDirPath() + "/evolution/local/Contacts/addressbook.db" ) ) { + return false; + } + + TQString val; + if (!mWrap->find( "PAS-DB-VERSION", val ) ) + return false; + + if (!val.startsWith("0.2") ) + return false; + + m_isOpen = true; + + return true; +} +void ResourceEvolution::doClose() { + delete mWrap; + mWrap = 0l; + m_isOpen = false; +} +Ticket* ResourceEvolution::requestSaveTicket() { + if ( !addressBook() ) return 0; + return createTicket( this ); +} +/* + * skip the first key + */ + +bool ResourceEvolution::load() { + /* doOpen never get's called :( */ + if (!doOpen()) return false; + if (!mWrap ) return false; // open first! + + DBIterator it = mWrap->begin(); + // skip the "PAS-DB-VERSION" + + for ( ; it != mWrap->end(); ++it ) { + if ( it.key().startsWith("PAS-DB-VERSION") ) + continue; + + tqWarning( "val:%s", it.value().latin1() ); + VCardTool tool; + TQString str = it.value().stripWhiteSpace(); + Addressee::List list = tool.parseVCards( str ); + if (!list.first().isEmpty() ) { + Addressee adr = list.first(); + adr.setResource(this); + addressBook()->insertAddressee( adr ); + } + } + return true; +} +bool ResourceEvolution::save( Ticket* ticket ) { + delete ticket; + if (!m_isOpen ) return false; + + // just delete the summary so evolution will regenerate it + // on next start up + (void)TQFile::remove( TQDir::homeDirPath() + "/evolution/local/Contacts/addressbook.db.summary" ); + + + AddressBook::Iterator it; + Addressee::List list; + for ( it = addressBook()->begin(); it !=addressBook()->end(); ++it ) { + if ( (*it).resource() != this || !(*it).changed() ) + continue; + + // remove, convert add set unchanged false + list.clear(); + mWrap->remove( (*it).uid() ); + VCardTool tool; + list.append( (*it) ); + mWrap->add( (*it).uid(), tool.createVCards( list, VCard::v2_1) ); + + (*it).setChanged( false ); + } + + return true; +} +void ResourceEvolution::removeAddressee( const Addressee& rem) { + if (!m_isOpen) return; + + mWrap->remove( rem.uid() ); +} diff --git a/tdeabc/plugins/evolution/resourceevo.h b/tdeabc/plugins/evolution/resourceevo.h new file mode 100644 index 000000000..82bcab5cb --- /dev/null +++ b/tdeabc/plugins/evolution/resourceevo.h @@ -0,0 +1,23 @@ +#include "resource.h" + +namespace Evolution { + class DBWrapper; +} + +namespace TDEABC { + class ResourceEvolution : public Resource { + public: + ResourceEvolution( const TDEConfig* config ); + ~ResourceEvolution(); + + bool doOpen(); + void doClose(); + Ticket* requestSaveTicket(); + bool load(); + bool save( Ticket* ticket ); + void removeAddressee( const Addressee& ); + private: + Evolution::DBWrapper *mWrap; + bool m_isOpen : 1; + }; +} diff --git a/tdeabc/plugins/file/CMakeLists.txt b/tdeabc/plugins/file/CMakeLists.txt new file mode 100644 index 000000000..c7dbfef46 --- /dev/null +++ b/tdeabc/plugins/file/CMakeLists.txt @@ -0,0 +1,73 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdeabc + ${CMAKE_SOURCE_DIR}/tdeabc + + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + resourcefile.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### other data ################################ + +install( FILES file.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/tdeabc ) + + +##### tdeabc_file (library) ####################### + +set( target tdeabc_file ) + +set( ${target}_SRCS + resourcefile.cpp resourcefileconfig.cpp +) + +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION 1.0.0 + LINK tdeabc-shared + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### tdeabc_file (module) ######################## + +set( target tdeabc_file ) + +set( ${target}_SRCS + resourcefileplugin.cpp +) + +tde_add_kpart( ${target} + SOURCES ${${target}_SRCS} + LINK tdeabc_file-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeabc/plugins/file/Makefile.am b/tdeabc/plugins/file/Makefile.am new file mode 100644 index 000000000..475fcd4dc --- /dev/null +++ b/tdeabc/plugins/file/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourcefileconfig.h + +lib_LTLIBRARIES = libtdeabc_file.la +libtdeabc_file_la_SOURCES = resourcefile.cpp resourcefileconfig.cpp +libtdeabc_file_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined +libtdeabc_file_la_LIBADD = $(LIB_TDEABC) $(LIB_QT) $(top_builddir)/tderesources/libtderesources.la $(LIB_TDEFILE) $(LIB_TDECORE) $(LIB_TDEUI) +libtdeabc_file_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + + +kde_module_LTLIBRARIES = tdeabc_file.la +tdeabc_file_la_SOURCES = resourcefileplugin.cpp +tdeabc_file_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +tdeabc_file_la_LIBADD = libtdeabc_file.la $(LIB_QT) $(LIB_TDECORE) +tdeabc_file_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_file.pot + +kabcincludedir = $(includedir)/tdeabc +kabcinclude_HEADERS = resourcefile.h + +servicedir = $(kde_servicesdir)/tderesources/tdeabc +service_DATA = file.desktop diff --git a/tdeabc/plugins/file/file.desktop b/tdeabc/plugins/file/file.desktop new file mode 100644 index 000000000..4c7991989 --- /dev/null +++ b/tdeabc/plugins/file/file.desktop @@ -0,0 +1,82 @@ +[Desktop Entry] +Name=File +Name[af]=Lêer +Name[ar]=ملفّ +Name[az]=Fayl +Name[be]=Файл +Name[bn]=ফাইল +Name[br]=Restr +Name[bs]=Datoteka +Name[ca]=Fitxer +Name[cs]=Soubor +Name[csb]=Lopk +Name[cy]=Ffeil +Name[da]=Fil +Name[de]=Datei +Name[el]=Αρχείο +Name[eo]=Dosiero +Name[es]=Archivo +Name[et]=Fail +Name[eu]=Fitxategia +Name[fa]=پرونده +Name[fi]=Tiedosto +Name[fr]=Fichier +Name[fy]=Triem +Name[ga]=Comhad +Name[gl]=Ficheiro +Name[he]=קובץ +Name[hi]=फ़ाइल +Name[hr]=Datoteka +Name[hsb]=Dataja +Name[hu]=Fájl +Name[id]=Berkas +Name[is]=Skrá +Name[ja]=ファイル +Name[ka]=ფაილი +Name[kk]=Файл +Name[km]=ឯកសារ +Name[ko]=파일 +Name[lb]=Datei +Name[lt]=Byla +Name[lv]=Fails +Name[mk]=Датотека +Name[mn]=Файл +Name[ms]=Fail +Name[nb]=Fil +Name[nds]=Datei +Name[ne]=फाइल +Name[nl]=Bestand +Name[nn]=Fil +Name[pa]=ਫਾਇਲ +Name[pl]=Plik +Name[pt]=Ficheiro +Name[pt_BR]=Arquivo +Name[ro]=Fişier +Name[ru]=Файл +Name[rw]=Idosiye +Name[se]=Fiila +Name[sk]=Súbor +Name[sl]=Datoteka +Name[sq]=Skedë +Name[sr]=Фајл +Name[sr@Latn]=Fajl +Name[sv]=Fil +Name[ta]=கோப்பு +Name[te]=దస్త్రం +Name[tg]=Файл +Name[th]=แฟ้ม +Name[tr]=Dosya +Name[tt]=Birem +Name[uk]=Файл +Name[uz]=Fayl +Name[uz@cyrillic]=Файл +Name[vi]=Tập tin +Name[wa]=Fitchî +Name[zh_CN]=文件 +Name[zh_HK]=檔案 +Name[zh_TW]=檔案 +X-TDE-Library=tdeabc_file +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=file diff --git a/tdeabc/plugins/file/resourcefile.cpp b/tdeabc/plugins/file/resourcefile.cpp new file mode 100644 index 000000000..4df5db42c --- /dev/null +++ b/tdeabc/plugins/file/resourcefile.cpp @@ -0,0 +1,395 @@ +/* + This file is part of libkabc. + + Copyright (c) 2001,2003 Cornelius Schumacher <[email protected]> + Copyright (c) 2006 Tom Abers <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <tqfile.h> +#include <tqfileinfo.h> +#include <tqtimer.h> + +#include <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <tdeio/scheduler.h> +#include <tdelocale.h> +#include <ksavefile.h> +#include <kstandarddirs.h> + +#include "formatfactory.h" +#include "resourcefileconfig.h" +#include "stdaddressbook.h" +#include "lock.h" + +#include "resourcefile.h" + +using namespace TDEABC; + +ResourceFile::ResourceFile( const TDEConfig *config ) + : Resource( config ), mFormat( 0 ), + mAsynchronous( false ) +{ + TQString fileName, formatName; + + if ( config ) { + fileName = config->readPathEntry( "FileName", StdAddressBook::fileName() ); + formatName = config->readEntry( "FileFormat", "vcard" ); + } else { + fileName = StdAddressBook::fileName(); + formatName = "vcard"; + } + + init( fileName, formatName ); +} + +ResourceFile::ResourceFile( const TQString &fileName, + const TQString &formatName ) + : Resource( 0 ), mFormat( 0 ), + mAsynchronous( false ) +{ + init( fileName, formatName ); +} + +void ResourceFile::init( const TQString &fileName, const TQString &formatName ) +{ + mFormatName = formatName; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); + + if ( !mFormat ) { + mFormatName = "vcard"; + mFormat = factory->format( mFormatName ); + } + + connect( &mDirWatch, TQT_SIGNAL( dirty(const TQString&) ), TQT_SLOT( fileChanged() ) ); + connect( &mDirWatch, TQT_SIGNAL( created(const TQString&) ), TQT_SLOT( fileChanged() ) ); + connect( &mDirWatch, TQT_SIGNAL( deleted(const TQString&) ), TQT_SLOT( fileChanged() ) ); + + setFileName( fileName ); + + mLock = 0; +} + +ResourceFile::~ResourceFile() +{ + delete mFormat; + mFormat = 0; +} + +void ResourceFile::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + if ( mFileName == StdAddressBook::fileName() ) + config->deleteEntry( "FileName" ); + else + config->writePathEntry( "FileName", mFileName ); + + config->writeEntry( "FileFormat", mFormatName ); +} + +Ticket *ResourceFile::requestSaveTicket() +{ + kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; + + if ( !addressBook() ) return 0; + + delete mLock; + mLock = new Lock( mFileName ); + + if ( mLock->lock() ) { + addressBook()->emitAddressBookLocked(); + } else { + addressBook()->error( mLock->error() ); + kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" + << mFileName << "': " << mLock->error() << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceFile::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; + + delete mLock; + mLock = 0; + + addressBook()->emitAddressBookUnlocked(); +} + +bool ResourceFile::doOpen() +{ + TQFile file( mFileName ); + + if ( !file.exists() ) { + // try to create the file + bool ok = file.open( IO_WriteOnly ); + if ( ok ) + file.close(); + + return ok; + } else { + TQFileInfo fileInfo( mFileName ); + if ( readOnly() || !fileInfo.isWritable() ) { + if ( !file.open( IO_ReadOnly ) ) + return false; + } else { + if ( !file.open( IO_ReadWrite ) ) + return false; + } + + if ( file.size() == 0 ) { + file.close(); + kdDebug() << "File size is zero. Evaluating backups" << endl; + for (int i=0; i!=20; i++) + { + TQFile backup( mFileName + "__" + TQString::number(i) ); + kdDebug() << "Evaluating" << backup.name() << " size: " << backup.size() << endl; + if ( backup.size() != 0 ) + { + kdDebug() << "Restoring backup " << i << endl; + const TQString src = mFileName + "__" + TQString::number(i); + const TQString dest = mFileName; + + // remove dest + TQFile::remove( dest ); + + // copy src to dest + if ( backup.open( IO_ReadOnly ) ) { + const TQByteArray data = backup.readAll(); + + TQFile out( dest ); + if ( out.open( IO_WriteOnly ) ) { + out.writeBlock( data ); + out.close(); + } + + backup.close(); + } + return true; + } + } + return true; + } + + bool ok = mFormat->checkFormat( &file ); + file.close(); + + return ok; + } +} + +void ResourceFile::doClose() +{ +} + +bool ResourceFile::load() +{ + kdDebug(5700) << "ResourceFile::load(): '" << mFileName << "'" << endl; + + mAsynchronous = false; + + TQFile file( mFileName ); + if ( !file.open( IO_ReadOnly ) ) { + addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); + return false; + } + + clear(); + + return mFormat->loadAll( addressBook(), this, &file ); +} + +bool ResourceFile::asyncLoad() +{ + kdDebug(5700) << "ResourceFile::asyncLoad()" << endl; + + mAsynchronous = true; + + bool ok = load(); + + if ( !ok ) + emitLoadingError(); + else + emitLoadingFinished(); + + return true; +} + +bool ResourceFile::save( Ticket * ) +{ + kdDebug(5700) << "ResourceFile::save()" << endl; + + // Only do the logrotate dance when the __0 file is not 0 bytes. + TQFile file( mFileName + "__0" ); + if ( file.size() != 0 ) { + const TQString last = mFileName + "__20"; + kdDebug() << "deleting " << last << endl; + + TQFile::remove( last ); + + for (int i=19; i>=0; i--) + { + const TQString src = mFileName + "__" + TQString::number(i); + const TQString dest = mFileName + "__" + TQString::number(i+1); + kdDebug() << "moving " << src << " -> " << dest << endl; + + // copy src to dest + TQFile in( src ); + if ( in.open( IO_ReadOnly ) ) { + const TQByteArray data = in.readAll(); + + TQFile out( dest ); + if ( out.open( IO_WriteOnly ) ) { + out.writeBlock( data ); + out.close(); + } + + in.close(); + } + + // remove src + TQFile::remove( src ); + } + } else + kdDebug() << "Not starting logrotate __0 is 0 bytes." << endl; + + TQString extension = "__0"; + (void) KSaveFile::backupFile( mFileName, TQString::null /*directory*/, + extension ); + + mDirWatch.stopScan(); + + KSaveFile saveFile( mFileName ); + bool ok = false; + + if ( saveFile.status() == 0 && saveFile.file() ) { + mFormat->saveAll( addressBook(), this, saveFile.file() ); + ok = saveFile.close(); + } + + if ( !ok ) { + saveFile.abort(); + addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); + } + + mDirWatch.startScan(); + + return ok; +} + +bool ResourceFile::asyncSave( Ticket *ticket ) +{ + kdDebug(5700) << "ResourceFile::asyncSave()" << endl; + + bool ok = save( ticket ); + + if ( !ok ) + TQTimer::singleShot( 0, this, TQT_SLOT( emitSavingError() ) ); + else + TQTimer::singleShot( 0, this, TQT_SLOT( emitSavingFinished() ) ); + + return ok; +} + +void ResourceFile::setFileName( const TQString &fileName ) +{ + mDirWatch.stopScan(); + if ( mDirWatch.contains( mFileName ) ) + mDirWatch.removeFile( mFileName ); + + mFileName = fileName; + + mDirWatch.addFile( mFileName ); + mDirWatch.startScan(); +} + +TQString ResourceFile::fileName() const +{ + return mFileName; +} + +void ResourceFile::setFormat( const TQString &format ) +{ + mFormatName = format; + delete mFormat; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); +} + +TQString ResourceFile::format() const +{ + return mFormatName; +} + +void ResourceFile::fileChanged() +{ + kdDebug(5700) << "ResourceFile::fileChanged(): " << mFileName << endl; + + if ( !addressBook() ) + return; + + if ( mAsynchronous ) + asyncLoad(); + else { + load(); + kdDebug() << "addressBookChanged() " << endl; + addressBook()->emitAddressBookChanged(); + } +} + +void ResourceFile::removeAddressee( const Addressee &addr ) +{ + TQFile::remove( TQFile::encodeName( locateLocal( "data", "tdeabc/photos/" ) + addr.uid() ) ); + TQFile::remove( TQFile::encodeName( locateLocal( "data", "tdeabc/logos/" ) + addr.uid() ) ); + TQFile::remove( TQFile::encodeName( locateLocal( "data", "tdeabc/sounds/" ) + addr.uid() ) ); + + mAddrMap.erase( addr.uid() ); +} + +void ResourceFile::emitSavingFinished() +{ + emit savingFinished( this ); +} + +void ResourceFile::emitSavingError() +{ + emit savingError( this, i18n( "Unable to save file '%1'." ).arg( mFileName ) ); +} + +void ResourceFile::emitLoadingFinished() +{ + emit loadingFinished( this ); +} + +void ResourceFile::emitLoadingError() +{ + emit loadingError( this, i18n( "Problems during parsing file '%1'." ).arg( mFileName ) ); +} + +#include "resourcefile.moc" diff --git a/tdeabc/plugins/file/resourcefile.h b/tdeabc/plugins/file/resourcefile.h new file mode 100644 index 000000000..76652d179 --- /dev/null +++ b/tdeabc/plugins/file/resourcefile.h @@ -0,0 +1,162 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCEFILE_H +#define KABC_RESOURCEFILE_H + +#include <tdeconfig.h> +#include <kdirwatch.h> + +#include <sys/types.h> + +#include <tdeabc/resource.h> + +namespace TDEABC { + +class FormatPlugin; +class ResourceConfigWidget; +class Lock; + +/** + This resource allows access to a local file. +*/ +class KABC_EXPORT ResourceFile : public Resource +{ + Q_OBJECT + + public: + /** + Constructor. + + @param cfg The config object where custom resource settings are stored. + */ + ResourceFile( const TDEConfig *cfg ); + + /** + Construct file resource on file @arg fileName using format @arg formatName. + */ + ResourceFile( const TQString &fileName, const TQString &formatName = "vcard" ); + + /** + Destructor. + */ + ~ResourceFile(); + + /** + Writes the config back. + */ + virtual void writeConfig( TDEConfig *cfg ); + + /** + Tries to open the file and checks for the proper format. + This method should be called before load(). + */ + virtual bool doOpen(); + + /** + Closes the file again. + */ + virtual void doClose(); + + /** + Requests a save ticket, that is used by save() + */ + virtual Ticket *requestSaveTicket(); + + virtual void releaseSaveTicket( Ticket* ); + + /** + Loads all addressees from file to the address book. + Returns true if all addressees could be loaded otherwise false. + */ + virtual bool load(); + + virtual bool asyncLoad(); + + /** + Saves all addresses from address book to file. + Returns true if all addressees could be saved otherwise false. + + @param ticket The ticket returned by requestSaveTicket() + */ + virtual bool save( Ticket *ticket ); + + virtual bool asyncSave( Ticket *ticket ); + + /** + Set name of file to be used for saving. + */ + void setFileName( const TQString & ); + + /** + Return name of file used for loading and saving the address book. + */ + TQString fileName() const; + + /** + Sets a new format by name. + */ + void setFormat( const TQString &name ); + + /** + Returns the format name. + */ + TQString format() const; + + /** + Remove a addressee from its source. + This method is mainly called by TDEABC::AddressBook. + */ + virtual void removeAddressee( const Addressee& addr ); + + private slots: + void emitLoadingFinished(); + void emitLoadingError(); + void emitSavingFinished(); + void emitSavingError(); + + protected slots: + void fileChanged(); + + protected: + void init( const TQString &fileName, const TQString &format ); + + bool lock( const TQString &fileName ); + void unlock( const TQString &fileName ); + + private: + TQString mFileName; + TQString mFormatName; + + FormatPlugin *mFormat; + + Lock *mLock; + + KDirWatch mDirWatch; + + bool mAsynchronous; + + class ResourceFilePrivate; + ResourceFilePrivate *d; +}; + +} + +#endif diff --git a/tdeabc/plugins/file/resourcefileconfig.cpp b/tdeabc/plugins/file/resourcefileconfig.cpp new file mode 100644 index 000000000..516a33a61 --- /dev/null +++ b/tdeabc/plugins/file/resourcefileconfig.cpp @@ -0,0 +1,118 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlabel.h> +#include <tqlayout.h> + +#include <kdebug.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kdialog.h> + +#include <unistd.h> + +#include "formatfactory.h" +#include "resourcefile.h" +#include "stdaddressbook.h" + +#include "resourcefileconfig.h" + +using namespace TDEABC; + +ResourceFileConfig::ResourceFileConfig( TQWidget* parent, const char* name ) + : ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0, + KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "Format:" ), this ); + mFormatBox = new KComboBox( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mFormatBox, 0, 1 ); + + label = new TQLabel( i18n( "Location:" ), this ); + mFileNameEdit = new KURLRequester( this ); + + connect( mFileNameEdit, TQT_SIGNAL( textChanged( const TQString & ) ), + TQT_SLOT( checkFilePermissions( const TQString & ) ) ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mFileNameEdit, 1, 1 ); + + FormatFactory *factory = FormatFactory::self(); + TQStringList formats = factory->formats(); + TQStringList::Iterator it; + for ( it = formats.begin(); it != formats.end(); ++it ) { + FormatInfo *info = factory->info( *it ); + if ( info ) { + mFormatTypes << (*it); + mFormatBox->insertItem( info->nameLabel ); + } + } + + mInEditMode = false; +} + +void ResourceFileConfig::setEditMode( bool value ) +{ + mFormatBox->setEnabled( !value ); + mInEditMode = value; +} + +void ResourceFileConfig::loadSettings( KRES::Resource *res ) +{ + ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceFileConfig::loadSettings(): cast failed" << endl; + return; + } + + mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); + + mFileNameEdit->setURL( resource->fileName() ); + if ( mFileNameEdit->url().isEmpty() ) + mFileNameEdit->setURL( TDEABC::StdAddressBook::fileName() ); +} + +void ResourceFileConfig::saveSettings( KRES::Resource *res ) +{ + ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceFileConfig::saveSettings(): cast failed" << endl; + return; + } + + if ( !mInEditMode ) + resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); + + resource->setFileName( mFileNameEdit->url() ); +} + +void ResourceFileConfig::checkFilePermissions( const TQString& fileName ) +{ + // If file exist but is not writeable... + if ( access( TQFile::encodeName( fileName ), F_OK ) == 0 ) + emit setReadOnly( access( TQFile::encodeName( fileName ), W_OK ) < 0 ); +} + +#include "resourcefileconfig.moc" diff --git a/tdeabc/plugins/file/resourcefileconfig.h b/tdeabc/plugins/file/resourcefileconfig.h new file mode 100644 index 000000000..e7b8ca9ea --- /dev/null +++ b/tdeabc/plugins/file/resourcefileconfig.h @@ -0,0 +1,57 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCEFILECONFIG_H +#define RESOURCEFILECONFIG_H + +#include <kcombobox.h> +#include <kurlrequester.h> + +#include <tderesources/configwidget.h> + +namespace TDEABC { + +class KABC_EXPORT ResourceFileConfig : public KRES::ConfigWidget +{ + Q_OBJECT + +public: + ResourceFileConfig( TQWidget* parent = 0, const char* name = 0 ); + + void setEditMode( bool value ); + +public slots: + void loadSettings( KRES::Resource *resource ); + void saveSettings( KRES::Resource *resource ); + +protected slots: + void checkFilePermissions( const TQString& fileName ); + +private: + KComboBox* mFormatBox; + KURLRequester* mFileNameEdit; + bool mInEditMode; + + TQStringList mFormatTypes; +}; + +} + +#endif diff --git a/tdeabc/plugins/file/resourcefileplugin.cpp b/tdeabc/plugins/file/resourcefileplugin.cpp new file mode 100644 index 000000000..5a44f76ca --- /dev/null +++ b/tdeabc/plugins/file/resourcefileplugin.cpp @@ -0,0 +1,32 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "resourcefile.h" +#include "resourcefileconfig.h" + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_file() + { + return new KRES::PluginFactory<ResourceFile, ResourceFileConfig>(); + } +} diff --git a/tdeabc/plugins/ldaptdeio/CMakeLists.txt b/tdeabc/plugins/ldaptdeio/CMakeLists.txt new file mode 100644 index 000000000..6e85a73d5 --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/CMakeLists.txt @@ -0,0 +1,73 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdeabc + ${CMAKE_SOURCE_DIR}/tdeabc + + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefiles +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + resourceldaptdeio.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### other data ################################ + +install( FILES ldaptdeio.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/tdeabc ) + + +##### tdeabc_ldaptdeio ############################## + +set( target tdeabc_ldaptdeio ) + +set( ${target}_SRCS + resourceldaptdeio.cpp resourceldaptdeioconfig.cpp +) + +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION 1.0.0 + LINK tdeabc-shared + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### tdeabc_ldaptdeio ############################## + +set( target tdeabc_ldaptdeio ) + +set( ${target}_SRCS + resourceldaptdeioplugin.cpp +) + +tde_add_kpart( ${target} + SOURCES ${${target}_SRCS} + LINK tdeabc_ldaptdeio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeabc/plugins/ldaptdeio/Makefile.am b/tdeabc/plugins/ldaptdeio/Makefile.am new file mode 100644 index 000000000..205c412ce --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = -I$(top_srcdir)/tdeabc -I$(top_builddir)/tdeabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourceldaptdeioconfig.h + +lib_LTLIBRARIES = libtdeabc_ldaptdeio.la +libtdeabc_ldaptdeio_la_SOURCES = resourceldaptdeio.cpp resourceldaptdeioconfig.cpp +libtdeabc_ldaptdeio_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined +libtdeabc_ldaptdeio_la_LIBADD = $(LIB_TDEABC) $(LIB_KIO) $(LIB_QT) $(top_builddir)/tderesources/libtderesources.la $(LIB_TDEUI) $(LIB_TDECORE) +libtdeabc_ldaptdeio_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + +kde_module_LTLIBRARIES = tdeabc_ldaptdeio.la +tdeabc_ldaptdeio_la_SOURCES = resourceldaptdeioplugin.cpp +tdeabc_ldaptdeio_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +tdeabc_ldaptdeio_la_LIBADD = libtdeabc_ldaptdeio.la $(LIB_QT) $(LIB_TDECORE) + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_ldaptdeio.pot + +kabcincludedir = $(includedir)/tdeabc +kabcinclude_HEADERS = resourceldaptdeio.h + +servicedir = $(kde_servicesdir)/tderesources/tdeabc +service_DATA = ldaptdeio.desktop + +resourceldaptdeioplugin.lo: ../../addressee.h diff --git a/tdeabc/plugins/ldaptdeio/ldaptdeio.desktop b/tdeabc/plugins/ldaptdeio/ldaptdeio.desktop new file mode 100644 index 000000000..683a38d13 --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/ldaptdeio.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=LDAP +Name[bn]=এল-ডি-এ-পি (LDAP) +Name[hi]=एलडीएपी (LDAP) +Name[te]=ఎల్డిఏపి +X-TDE-Library=tdeabc_ldaptdeio +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=ldaptdeio diff --git a/tdeabc/plugins/ldaptdeio/resourceldaptdeio.cpp b/tdeabc/plugins/ldaptdeio/resourceldaptdeio.cpp new file mode 100644 index 000000000..0e182755a --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/resourceldaptdeio.cpp @@ -0,0 +1,1041 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include <tqapplication.h> +#include <tqbuffer.h> +#include <tqfile.h> + +#include <kdebug.h> +#include <tdeglobal.h> +#include <kstandarddirs.h> +#include <klineedit.h> +#include <tdelocale.h> +#include <tdeconfig.h> +#include <kstringhandler.h> +#include <tdetempfile.h> + +#include <stdlib.h> +#include <tdeio/netaccess.h> +#include <tdeabc/ldif.h> +#include <tdeabc/ldapurl.h> + +#include "resourceldaptdeio.h" +#include "resourceldaptdeioconfig.h" + +using namespace TDEABC; + +// Hack from Netaccess +void tqt_enter_modal( TQWidget *widget ); +void tqt_leave_modal( TQWidget *widget ); + +class ResourceLDAPTDEIO::ResourceLDAPTDEIOPrivate +{ + public: + LDIF mLdif; + bool mTLS,mSSL,mSubTree; + TQString mResultDn; + Addressee mAddr; + Address mAd; + Resource::Iterator mSaveIt; + bool mSASL; + TQString mMech; + TQString mRealm, mBindDN; + LDAPUrl mLDAPUrl; + int mVer, mSizeLimit, mTimeLimit, mRDNPrefix; + int mError; + int mCachePolicy; + bool mReadOnly; + bool mAutoCache; + TQString mCacheDst; + KTempFile *mTmp; +}; + +ResourceLDAPTDEIO::ResourceLDAPTDEIO( const TDEConfig *config ) + : Resource( config ) +{ + d = new ResourceLDAPTDEIOPrivate; + if ( config ) { + TQMap<TQString, TQString> attrList; + TQStringList attributes = config->readListEntry( "LdapAttributes" ); + for ( uint pos = 0; pos < attributes.count(); pos += 2 ) + mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); + + mUser = config->readEntry( "LdapUser" ); + mPassword = KStringHandler::obscure( config->readEntry( "LdapPassword" ) ); + mDn = config->readEntry( "LdapDn" ); + mHost = config->readEntry( "LdapHost" ); + mPort = config->readNumEntry( "LdapPort", 389 ); + mFilter = config->readEntry( "LdapFilter" ); + mAnonymous = config->readBoolEntry( "LdapAnonymous" ); + d->mTLS = config->readBoolEntry( "LdapTLS" ); + d->mSSL = config->readBoolEntry( "LdapSSL" ); + d->mSubTree = config->readBoolEntry( "LdapSubTree" ); + d->mSASL = config->readBoolEntry( "LdapSASL" ); + d->mMech = config->readEntry( "LdapMech" ); + d->mRealm = config->readEntry( "LdapRealm" ); + d->mBindDN = config->readEntry( "LdapBindDN" ); + d->mVer = config->readNumEntry( "LdapVer", 3 ); + d->mTimeLimit = config->readNumEntry( "LdapTimeLimit", 0 ); + d->mSizeLimit = config->readNumEntry( "LdapSizeLimit", 0 ); + d->mRDNPrefix = config->readNumEntry( "LdapRDNPrefix", 0 ); + d->mCachePolicy = config->readNumEntry( "LdapCachePolicy", 0 ); + d->mAutoCache = config->readBoolEntry( "LdapAutoCache", true ); + } else { + mPort = 389; + mAnonymous = true; + mUser = mPassword = mHost = mFilter = mDn = ""; + d->mMech = d->mRealm = d->mBindDN = ""; + d->mTLS = d->mSSL = d->mSubTree = d->mSASL = false; + d->mVer = 3; d->mRDNPrefix = 0; + d->mTimeLimit = d->mSizeLimit = 0; + d->mCachePolicy = Cache_No; + d->mAutoCache = true; + } + d->mCacheDst = TDEGlobal::dirs()->saveLocation("cache", "ldaptdeio") + "/" + + type() + "_" + identifier(); + init(); +} + +ResourceLDAPTDEIO::~ResourceLDAPTDEIO() +{ + delete d; +} + +void ResourceLDAPTDEIO::enter_loop() +{ + TQWidget dummy(0,0,(WFlags)(WType_Dialog | WShowModal)); + dummy.setFocusPolicy( TQ_NoFocus ); + tqt_enter_modal(&dummy); + tqApp->enter_loop(); + tqt_leave_modal(&dummy); +} + +void ResourceLDAPTDEIO::entries( TDEIO::Job*, const TDEIO::UDSEntryList & list ) +{ + TDEIO::UDSEntryListConstIterator it = list.begin(); + TDEIO::UDSEntryListConstIterator end = list.end(); + for (; it != end; ++it) { + TDEIO::UDSEntry::ConstIterator it2 = (*it).begin(); + for( ; it2 != (*it).end(); it2++ ) { + if ( (*it2).m_uds == TDEIO::UDS_URL ) { + KURL tmpurl( (*it2).m_str ); + d->mResultDn = tmpurl.path(); + kdDebug(7125) << "findUid(): " << d->mResultDn << endl; + if ( d->mResultDn.startsWith("/") ) d->mResultDn.remove(0,1); + return; + } + } + } +} + +void ResourceLDAPTDEIO::listResult( TDEIO::Job *job) +{ + d->mError = job->error(); + if ( d->mError && d->mError != TDEIO::ERR_USER_CANCELED ) + mErrorMsg = job->errorString(); + else + mErrorMsg = ""; + tqApp->exit_loop(); +} + +TQString ResourceLDAPTDEIO::findUid( const TQString &uid ) +{ + LDAPUrl url( d->mLDAPUrl ); + TDEIO::UDSEntry entry; + + mErrorMsg = d->mResultDn = ""; + + url.setAttributes("dn"); + url.setFilter( "(" + mAttributes[ "uid" ] + "=" + uid + ")" + mFilter ); + url.setExtension( "x-dir", "one" ); + + kdDebug(7125) << "ResourceLDAPTDEIO::findUid() uid: " << uid << " url " << + url.prettyURL() << endl; + + TDEIO::ListJob * listJob = TDEIO::listDir( url, false /* no GUI */ ); + connect( listJob, + TQT_SIGNAL( entries( TDEIO::Job *, const TDEIO::UDSEntryList& ) ), + TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); + connect( listJob, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( listResult( TDEIO::Job* ) ) ); + + enter_loop(); + return d->mResultDn; +} + +TQCString ResourceLDAPTDEIO::addEntry( const TQString &attr, const TQString &value, bool mod ) +{ + TQCString tmp; + if ( !attr.isEmpty() ) { + if ( mod ) tmp += LDIF::assembleLine( "replace", attr ) + "\n"; + tmp += LDIF::assembleLine( attr, value ) + "\n"; + if ( mod ) tmp += "-\n"; + } + return ( tmp ); +} + +bool ResourceLDAPTDEIO::AddresseeToLDIF( TQByteArray &ldif, const Addressee &addr, + const TQString &olddn ) +{ + TQCString tmp; + TQString dn; + TQByteArray data; + bool mod = false; + + if ( olddn.isEmpty() ) { + //insert new entry + switch ( d->mRDNPrefix ) { + case 1: + dn = mAttributes[ "uid" ] + "=" + addr.uid() + "," +mDn; + break; + case 0: + default: + dn = mAttributes[ "commonName" ] + "=" + addr.assembledName() + "," +mDn; + break; + } + } else { + //modify existing entry + mod = true; + if ( olddn.startsWith( mAttributes[ "uid" ] ) ) { + dn = mAttributes[ "uid" ] + "=" + addr.uid() + "," + olddn.section( ',', 1 ); + } else if ( olddn.startsWith( mAttributes[ "commonName" ] ) ) { + dn = mAttributes[ "commonName" ] + "=" + addr.assembledName() + "," + + olddn.section( ',', 1 ); + } else { + dn = olddn; + } + + if ( olddn.lower() != dn.lower() ) { + tmp = LDIF::assembleLine( "dn", olddn ) + "\n"; + tmp += "changetype: modrdn\n"; + tmp += LDIF::assembleLine( "newrdn", dn.section( ',', 0, 0 ) ) + "\n"; + tmp += "deleteoldrdn: 1\n\n"; + } + } + + + tmp += LDIF::assembleLine( "dn", dn ) + "\n"; + if ( mod ) tmp += "changetype: modify\n"; + if ( !mod ) { + tmp += "objectClass: top\n"; + TQStringList obclass = TQStringList::split( ',', mAttributes[ "objectClass" ] ); + for ( TQStringList::iterator it = obclass.begin(); it != obclass.end(); it++ ) { + tmp += LDIF::assembleLine( "objectClass", *it ) + "\n"; + } + } + + tmp += addEntry( mAttributes[ "commonName" ], addr.assembledName(), mod ); + tmp += addEntry( mAttributes[ "formattedName" ], addr.formattedName(), mod ); + tmp += addEntry( mAttributes[ "givenName" ], addr.givenName(), mod ); + tmp += addEntry( mAttributes[ "familyName" ], addr.familyName(), mod ); + tmp += addEntry( mAttributes[ "uid" ], addr.uid(), mod ); + + PhoneNumber number; + number = addr.phoneNumber( PhoneNumber::Home ); + tmp += addEntry( mAttributes[ "phoneNumber" ], number.number().utf8(), mod ); + number = addr.phoneNumber( PhoneNumber::Work ); + tmp += addEntry( mAttributes[ "telephoneNumber" ], number.number().utf8(), mod ); + number = addr.phoneNumber( PhoneNumber::Fax ); + tmp += addEntry( mAttributes[ "facsimileTelephoneNumber" ], number.number().utf8(), mod ); + number = addr.phoneNumber( PhoneNumber::Cell ); + tmp += addEntry( mAttributes[ "mobile" ], number.number().utf8(), mod ); + number = addr.phoneNumber( PhoneNumber::Pager ); + tmp += addEntry( mAttributes[ "pager" ], number.number().utf8(), mod ); + + tmp += addEntry( mAttributes[ "description" ], addr.note(), mod ); + tmp += addEntry( mAttributes[ "title" ], addr.title(), mod ); + tmp += addEntry( mAttributes[ "organization" ], addr.organization(), mod ); + + Address ad = addr.address( Address::Home ); + if ( !ad.isEmpty() ) { + tmp += addEntry( mAttributes[ "street" ], ad.street(), mod ); + tmp += addEntry( mAttributes[ "state" ], ad.region(), mod ); + tmp += addEntry( mAttributes[ "city" ], ad.locality(), mod ); + tmp += addEntry( mAttributes[ "postalcode" ], ad.postalCode(), mod ); + } + + TQStringList emails = addr.emails(); + TQStringList::ConstIterator mailIt = emails.begin(); + + if ( !mAttributes[ "mail" ].isEmpty() ) { + if ( mod ) tmp += + LDIF::assembleLine( "replace", mAttributes[ "mail" ] ) + "\n"; + if ( mailIt != emails.end() ) { + tmp += LDIF::assembleLine( mAttributes[ "mail" ], *mailIt ) + "\n"; + mailIt ++; + } + if ( mod && mAttributes[ "mail" ] != mAttributes[ "mailAlias" ] ) tmp += "-\n"; + } + + if ( !mAttributes[ "mailAlias" ].isEmpty() ) { + if ( mod && mAttributes[ "mail" ] != mAttributes[ "mailAlias" ] ) tmp += + LDIF::assembleLine( "replace", mAttributes[ "mailAlias" ] ) + "\n"; + for ( ; mailIt != emails.end(); ++mailIt ) { + tmp += LDIF::assembleLine( mAttributes[ "mailAlias" ], *mailIt ) + "\n" ; + } + if ( mod ) tmp += "-\n"; + } + + if ( !mAttributes[ "jpegPhoto" ].isEmpty() ) { + TQByteArray pic; + TQBuffer buffer( pic ); + buffer.open( IO_WriteOnly ); + addr.photo().data().save( &buffer, "JPEG" ); + + if ( mod ) tmp += + LDIF::assembleLine( "replace", mAttributes[ "jpegPhoto" ] ) + "\n"; + tmp += LDIF::assembleLine( mAttributes[ "jpegPhoto" ], pic, 76 ) + "\n"; + if ( mod ) tmp += "-\n"; + } + + tmp += "\n"; + kdDebug(7125) << "ldif: " << TQString(TQString::fromUtf8(tmp)) << endl; + ldif = tmp; + return true; +} + +void ResourceLDAPTDEIO::setReadOnly( bool value ) +{ + //save the original readonly flag, because offline using disables writing + d->mReadOnly = true; + Resource::setReadOnly( value ); +} + +void ResourceLDAPTDEIO::init() +{ + if ( mPort == 0 ) mPort = 389; + + /** + If you want to add new attributes, append them here, add a + translation string in the ctor of AttributesDialog and + handle them in the load() method below. + These are the default values + */ + if ( !mAttributes.contains("objectClass") ) + mAttributes.insert( "objectClass", "inetOrgPerson" ); + if ( !mAttributes.contains("commonName") ) + mAttributes.insert( "commonName", "cn" ); + if ( !mAttributes.contains("formattedName") ) + mAttributes.insert( "formattedName", "displayName" ); + if ( !mAttributes.contains("familyName") ) + mAttributes.insert( "familyName", "sn" ); + if ( !mAttributes.contains("givenName") ) + mAttributes.insert( "givenName", "givenName" ); + if ( !mAttributes.contains("mail") ) + mAttributes.insert( "mail", "mail" ); + if ( !mAttributes.contains("mailAlias") ) + mAttributes.insert( "mailAlias", "" ); + if ( !mAttributes.contains("phoneNumber") ) + mAttributes.insert( "phoneNumber", "homePhone" ); + if ( !mAttributes.contains("telephoneNumber") ) + mAttributes.insert( "telephoneNumber", "telephoneNumber" ); + if ( !mAttributes.contains("facsimileTelephoneNumber") ) + mAttributes.insert( "facsimileTelephoneNumber", "facsimileTelephoneNumber" ); + if ( !mAttributes.contains("mobile") ) + mAttributes.insert( "mobile", "mobile" ); + if ( !mAttributes.contains("pager") ) + mAttributes.insert( "pager", "pager" ); + if ( !mAttributes.contains("description") ) + mAttributes.insert( "description", "description" ); + + if ( !mAttributes.contains("title") ) + mAttributes.insert( "title", "title" ); + if ( !mAttributes.contains("street") ) + mAttributes.insert( "street", "street" ); + if ( !mAttributes.contains("state") ) + mAttributes.insert( "state", "st" ); + if ( !mAttributes.contains("city") ) + mAttributes.insert( "city", "l" ); + if ( !mAttributes.contains("organization") ) + mAttributes.insert( "organization", "o" ); + if ( !mAttributes.contains("postalcode") ) + mAttributes.insert( "postalcode", "postalCode" ); + + if ( !mAttributes.contains("uid") ) + mAttributes.insert( "uid", "uid" ); + if ( !mAttributes.contains("jpegPhoto") ) + mAttributes.insert( "jpegPhoto", "jpegPhoto" ); + + d->mLDAPUrl = KURL(); + if ( !mAnonymous ) { + d->mLDAPUrl.setUser( mUser ); + d->mLDAPUrl.setPass( mPassword ); + } + d->mLDAPUrl.setProtocol( d->mSSL ? "ldaps" : "ldap"); + d->mLDAPUrl.setHost( mHost ); + d->mLDAPUrl.setPort( mPort ); + d->mLDAPUrl.setDn( mDn ); + + if (!mAttributes.empty()) { + TQMap<TQString,TQString>::Iterator it; + TQStringList attr; + for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) { + if ( !it.data().isEmpty() && it.key() != "objectClass" ) + attr.append( it.data() ); + } + d->mLDAPUrl.setAttributes( attr ); + } + + d->mLDAPUrl.setScope( d->mSubTree ? LDAPUrl::Sub : LDAPUrl::One ); + if ( !mFilter.isEmpty() && mFilter != "(objectClass=*)" ) + d->mLDAPUrl.setFilter( mFilter ); + d->mLDAPUrl.setExtension( "x-dir", "base" ); + if ( d->mTLS ) d->mLDAPUrl.setExtension( "x-tls", "" ); + d->mLDAPUrl.setExtension( "x-ver", TQString::number( d->mVer ) ); + if ( d->mSizeLimit ) + d->mLDAPUrl.setExtension( "x-sizelimit", TQString::number( d->mSizeLimit ) ); + if ( d->mTimeLimit ) + d->mLDAPUrl.setExtension( "x-timelimit", TQString::number( d->mTimeLimit ) ); + if ( d->mSASL ) { + d->mLDAPUrl.setExtension( "x-sasl", "" ); + if ( !d->mBindDN.isEmpty() ) d->mLDAPUrl.setExtension( "bindname", d->mBindDN ); + if ( !d->mMech.isEmpty() ) d->mLDAPUrl.setExtension( "x-mech", d->mMech ); + if ( !d->mRealm.isEmpty() ) d->mLDAPUrl.setExtension( "x-realm", d->mRealm ); + } + + d->mReadOnly = readOnly(); + + kdDebug(7125) << "resource_ldaptdeio url: " << d->mLDAPUrl.prettyURL() << endl; +} + +void ResourceLDAPTDEIO::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + config->writeEntry( "LdapUser", mUser ); + config->writeEntry( "LdapPassword", KStringHandler::obscure( mPassword ) ); + config->writeEntry( "LdapDn", mDn ); + config->writeEntry( "LdapHost", mHost ); + config->writeEntry( "LdapPort", mPort ); + config->writeEntry( "LdapFilter", mFilter ); + config->writeEntry( "LdapAnonymous", mAnonymous ); + config->writeEntry( "LdapTLS", d->mTLS ); + config->writeEntry( "LdapSSL", d->mSSL ); + config->writeEntry( "LdapSubTree", d->mSubTree ); + config->writeEntry( "LdapSASL", d->mSASL ); + config->writeEntry( "LdapMech", d->mMech ); + config->writeEntry( "LdapVer", d->mVer ); + config->writeEntry( "LdapTimeLimit", d->mTimeLimit ); + config->writeEntry( "LdapSizeLimit", d->mSizeLimit ); + config->writeEntry( "LdapRDNPrefix", d->mRDNPrefix ); + config->writeEntry( "LdapRealm", d->mRealm ); + config->writeEntry( "LdapBindDN", d->mBindDN ); + config->writeEntry( "LdapCachePolicy", d->mCachePolicy ); + config->writeEntry( "LdapAutoCache", d->mAutoCache ); + + TQStringList attributes; + TQMap<TQString, TQString>::Iterator it; + for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) + attributes << it.key() << it.data(); + + config->writeEntry( "LdapAttributes", attributes ); +} + +Ticket *ResourceLDAPTDEIO::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(7125) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceLDAPTDEIO::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceLDAPTDEIO::doOpen() +{ + return true; +} + +void ResourceLDAPTDEIO::doClose() +{ +} + +void ResourceLDAPTDEIO::createCache() +{ + d->mTmp = NULL; + if ( d->mCachePolicy == Cache_NoConnection && d->mAutoCache ) { + d->mTmp = new KTempFile( d->mCacheDst, "tmp" ); + d->mTmp->setAutoDelete( true ); + } +} + +void ResourceLDAPTDEIO::activateCache() +{ + if ( d->mTmp && d->mError == 0 ) { + d->mTmp->close(); + rename( TQFile::encodeName( d->mTmp->name() ), TQFile::encodeName( d->mCacheDst ) ); + } + if ( d->mTmp ) { + delete d->mTmp; + d->mTmp = 0; + } +} + +TDEIO::Job *ResourceLDAPTDEIO::loadFromCache() +{ + TDEIO::Job *job = NULL; + if ( d->mCachePolicy == Cache_Always || + ( d->mCachePolicy == Cache_NoConnection && + d->mError == TDEIO::ERR_COULD_NOT_CONNECT ) ) { + + d->mAddr = Addressee(); + d->mAd = Address( Address::Home ); + //initialize ldif parser + d->mLdif.startParsing(); + + Resource::setReadOnly( true ); + + KURL url( d->mCacheDst ); + job = TDEIO::get( url, true, false ); + connect( job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), + this, TQT_SLOT( data( TDEIO::Job*, const TQByteArray& ) ) ); + } + return job; +} + +bool ResourceLDAPTDEIO::load() +{ + kdDebug(7125) << "ResourceLDAPTDEIO::load()" << endl; + TDEIO::Job *job; + + clear(); + //clear the addressee + d->mAddr = Addressee(); + d->mAd = Address( Address::Home ); + //initialize ldif parser + d->mLdif.startParsing(); + + //set to original settings, offline use will disable writing + Resource::setReadOnly( d->mReadOnly ); + + createCache(); + if ( d->mCachePolicy != Cache_Always ) { + job = TDEIO::get( d->mLDAPUrl, true, false ); + connect( job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), + this, TQT_SLOT( data( TDEIO::Job*, const TQByteArray& ) ) ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( syncLoadSaveResult( TDEIO::Job* ) ) ); + enter_loop(); + } + + job = loadFromCache(); + if ( job ) { + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( syncLoadSaveResult( TDEIO::Job* ) ) ); + enter_loop(); + } + if ( mErrorMsg.isEmpty() ) { + kdDebug(7125) << "ResourceLDAPTDEIO load ok!" << endl; + return true; + } else { + kdDebug(7125) << "ResourceLDAPTDEIO load finished with error: " << mErrorMsg << endl; + addressBook()->error( mErrorMsg ); + return false; + } +} + +bool ResourceLDAPTDEIO::asyncLoad() +{ + clear(); + //clear the addressee + d->mAddr = Addressee(); + d->mAd = Address( Address::Home ); + //initialize ldif parser + d->mLdif.startParsing(); + + Resource::setReadOnly( d->mReadOnly ); + + createCache(); + if ( d->mCachePolicy != Cache_Always ) { + TDEIO::Job *job = TDEIO::get( d->mLDAPUrl, true, false ); + connect( job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), + this, TQT_SLOT( data( TDEIO::Job*, const TQByteArray& ) ) ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( result( TDEIO::Job* ) ) ); + } else { + result( NULL ); + } + return true; +} + +void ResourceLDAPTDEIO::data( TDEIO::Job *, const TQByteArray &data ) +{ + if ( data.size() ) { + d->mLdif.setLDIF( data ); + if ( d->mTmp ) { + d->mTmp->file()->writeBlock( data ); + } + } else { + d->mLdif.endLDIF(); + } + + LDIF::ParseVal ret; + TQString name; + TQByteArray value; + do { + ret = d->mLdif.nextItem(); + switch ( ret ) { + case LDIF::NewEntry: + kdDebug(7125) << "new entry: " << d->mLdif.dn() << endl; + break; + case LDIF::Item: + name = d->mLdif.attr().lower(); + value = d->mLdif.val(); + if ( name == mAttributes[ "commonName" ].lower() ) { + if ( !d->mAddr.formattedName().isEmpty() ) { + TQString fn = d->mAddr.formattedName(); + d->mAddr.setNameFromString( TQString::fromUtf8( value, value.size() ) ); + d->mAddr.setFormattedName( fn ); + } else + d->mAddr.setNameFromString( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "formattedName" ].lower() ) { + d->mAddr.setFormattedName( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "givenName" ].lower() ) { + d->mAddr.setGivenName( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "mail" ].lower() ) { + d->mAddr.insertEmail( TQString::fromUtf8( value, value.size() ), true ); + } else if ( name == mAttributes[ "mailAlias" ].lower() ) { + d->mAddr.insertEmail( TQString::fromUtf8( value, value.size() ), false ); + } else if ( name == mAttributes[ "phoneNumber" ].lower() ) { + PhoneNumber phone; + phone.setNumber( TQString::fromUtf8( value, value.size() ) ); + d->mAddr.insertPhoneNumber( phone ); + } else if ( name == mAttributes[ "telephoneNumber" ].lower() ) { + PhoneNumber phone( TQString::fromUtf8( value, value.size() ), + PhoneNumber::Work ); + d->mAddr.insertPhoneNumber( phone ); + } else if ( name == mAttributes[ "facsimileTelephoneNumber" ].lower() ) { + PhoneNumber phone( TQString::fromUtf8( value, value.size() ), + PhoneNumber::Fax ); + d->mAddr.insertPhoneNumber( phone ); + } else if ( name == mAttributes[ "mobile" ].lower() ) { + PhoneNumber phone( TQString::fromUtf8( value, value.size() ), + PhoneNumber::Cell ); + d->mAddr.insertPhoneNumber( phone ); + } else if ( name == mAttributes[ "pager" ].lower() ) { + PhoneNumber phone( TQString::fromUtf8( value, value.size() ), + PhoneNumber::Pager ); + d->mAddr.insertPhoneNumber( phone ); + } else if ( name == mAttributes[ "description" ].lower() ) { + d->mAddr.setNote( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "title" ].lower() ) { + d->mAddr.setTitle( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "street" ].lower() ) { + d->mAd.setStreet( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "state" ].lower() ) { + d->mAd.setRegion( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "city" ].lower() ) { + d->mAd.setLocality( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "postalcode" ].lower() ) { + d->mAd.setPostalCode( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "organization" ].lower() ) { + d->mAddr.setOrganization( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "familyName" ].lower() ) { + d->mAddr.setFamilyName( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "uid" ].lower() ) { + d->mAddr.setUid( TQString::fromUtf8( value, value.size() ) ); + } else if ( name == mAttributes[ "jpegPhoto" ].lower() ) { + TDEABC::Picture photo; + TQImage img( value ); + if ( !img.isNull() ) { + photo.setData( img ); + photo.setType( "image/jpeg" ); + d->mAddr.setPhoto( photo ); + } + } + + break; + case LDIF::EndEntry: { + d->mAddr.setResource( this ); + d->mAddr.insertAddress( d->mAd ); + d->mAddr.setChanged( false ); + insertAddressee( d->mAddr ); + //clear the addressee + d->mAddr = Addressee(); + d->mAd = Address( Address::Home ); + } + break; + default: + break; + } + } while ( ret != LDIF::MoreData ); +} + +void ResourceLDAPTDEIO::loadCacheResult( TDEIO::Job *job ) +{ + mErrorMsg = ""; + d->mError = job->error(); + if ( d->mError && d->mError != TDEIO::ERR_USER_CANCELED ) { + mErrorMsg = job->errorString(); + } + if ( !mErrorMsg.isEmpty() ) + emit loadingError( this, mErrorMsg ); + else + emit loadingFinished( this ); +} + +void ResourceLDAPTDEIO::result( TDEIO::Job *job ) +{ + mErrorMsg = ""; + if ( job ) { + d->mError = job->error(); + if ( d->mError && d->mError != TDEIO::ERR_USER_CANCELED ) { + mErrorMsg = job->errorString(); + } + } else { + d->mError = 0; + } + activateCache(); + + TDEIO::Job *cjob; + cjob = loadFromCache(); + if ( cjob ) { + connect( cjob, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( loadCacheResult( TDEIO::Job* ) ) ); + } else { + if ( !mErrorMsg.isEmpty() ) + emit loadingError( this, mErrorMsg ); + else + emit loadingFinished( this ); + } +} + +bool ResourceLDAPTDEIO::save( Ticket* ) +{ + kdDebug(7125) << "ResourceLDAPTDEIO save" << endl; + + d->mSaveIt = begin(); + TDEIO::Job *job = TDEIO::put( d->mLDAPUrl, -1, true, false, false ); + connect( job, TQT_SIGNAL( dataReq( TDEIO::Job*, TQByteArray& ) ), + this, TQT_SLOT( saveData( TDEIO::Job*, TQByteArray& ) ) ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( syncLoadSaveResult( TDEIO::Job* ) ) ); + enter_loop(); + if ( mErrorMsg.isEmpty() ) { + kdDebug(7125) << "ResourceLDAPTDEIO save ok!" << endl; + return true; + } else { + kdDebug(7125) << "ResourceLDAPTDEIO finished with error: " << mErrorMsg << endl; + addressBook()->error( mErrorMsg ); + return false; + } +} + +bool ResourceLDAPTDEIO::asyncSave( Ticket* ) +{ + kdDebug(7125) << "ResourceLDAPTDEIO asyncSave" << endl; + d->mSaveIt = begin(); + TDEIO::Job *job = TDEIO::put( d->mLDAPUrl, -1, true, false, false ); + connect( job, TQT_SIGNAL( dataReq( TDEIO::Job*, TQByteArray& ) ), + this, TQT_SLOT( saveData( TDEIO::Job*, TQByteArray& ) ) ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( saveResult( TDEIO::Job* ) ) ); + return true; +} + +void ResourceLDAPTDEIO::syncLoadSaveResult( TDEIO::Job *job ) +{ + d->mError = job->error(); + if ( d->mError && d->mError != TDEIO::ERR_USER_CANCELED ) + mErrorMsg = job->errorString(); + else + mErrorMsg = ""; + activateCache(); + + tqApp->exit_loop(); +} + +void ResourceLDAPTDEIO::saveResult( TDEIO::Job *job ) +{ + d->mError = job->error(); + if ( d->mError && d->mError != TDEIO::ERR_USER_CANCELED ) + emit savingError( this, job->errorString() ); + else + emit savingFinished( this ); +} + +void ResourceLDAPTDEIO::saveData( TDEIO::Job*, TQByteArray& data ) +{ + while ( d->mSaveIt != end() && + !(*d->mSaveIt).changed() ) d->mSaveIt++; + + if ( d->mSaveIt == end() ) { + kdDebug(7125) << "ResourceLDAPTDEIO endData" << endl; + data.resize(0); + return; + } + + kdDebug(7125) << "ResourceLDAPTDEIO saveData: " << (*d->mSaveIt).assembledName() << endl; + + AddresseeToLDIF( data, *d->mSaveIt, findUid( (*d->mSaveIt).uid() ) ); +// kdDebug(7125) << "ResourceLDAPTDEIO save LDIF: " << TQString::fromUtf8(data) << endl; + // mark as unchanged + (*d->mSaveIt).setChanged( false ); + + d->mSaveIt++; +} + +void ResourceLDAPTDEIO::removeAddressee( const Addressee& addr ) +{ + TQString dn = findUid( addr.uid() ); + + kdDebug(7125) << "ResourceLDAPTDEIO: removeAddressee: " << dn << endl; + + if ( !mErrorMsg.isEmpty() ) { + addressBook()->error( mErrorMsg ); + return; + } + if ( !dn.isEmpty() ) { + kdDebug(7125) << "ResourceLDAPTDEIO: found uid: " << dn << endl; + LDAPUrl url( d->mLDAPUrl ); + url.setPath( "/" + dn ); + url.setExtension( "x-dir", "base" ); + url.setScope( LDAPUrl::Base ); + if ( TDEIO::NetAccess::del( url, NULL ) ) mAddrMap.erase( addr.uid() ); + } else { + //maybe it's not saved yet + mAddrMap.erase( addr.uid() ); + } +} + + +void ResourceLDAPTDEIO::setUser( const TQString &user ) +{ + mUser = user; +} + +TQString ResourceLDAPTDEIO::user() const +{ + return mUser; +} + +void ResourceLDAPTDEIO::setPassword( const TQString &password ) +{ + mPassword = password; +} + +TQString ResourceLDAPTDEIO::password() const +{ + return mPassword; +} + +void ResourceLDAPTDEIO::setDn( const TQString &dn ) +{ + mDn = dn; +} + +TQString ResourceLDAPTDEIO::dn() const +{ + return mDn; +} + +void ResourceLDAPTDEIO::setHost( const TQString &host ) +{ + mHost = host; +} + +TQString ResourceLDAPTDEIO::host() const +{ + return mHost; +} + +void ResourceLDAPTDEIO::setPort( int port ) +{ + mPort = port; +} + +int ResourceLDAPTDEIO::port() const +{ + return mPort; +} + +void ResourceLDAPTDEIO::setVer( int ver ) +{ + d->mVer = ver; +} + +int ResourceLDAPTDEIO::ver() const +{ + return d->mVer; +} + +void ResourceLDAPTDEIO::setSizeLimit( int sizelimit ) +{ + d->mSizeLimit = sizelimit; +} + +int ResourceLDAPTDEIO::sizeLimit() +{ + return d->mSizeLimit; +} + +void ResourceLDAPTDEIO::setTimeLimit( int timelimit ) +{ + d->mTimeLimit = timelimit; +} + +int ResourceLDAPTDEIO::timeLimit() +{ + return d->mTimeLimit; +} + +void ResourceLDAPTDEIO::setFilter( const TQString &filter ) +{ + mFilter = filter; +} + +TQString ResourceLDAPTDEIO::filter() const +{ + return mFilter; +} + +void ResourceLDAPTDEIO::setIsAnonymous( bool value ) +{ + mAnonymous = value; +} + +bool ResourceLDAPTDEIO::isAnonymous() const +{ + return mAnonymous; +} + +void ResourceLDAPTDEIO::setIsTLS( bool value ) +{ + d->mTLS = value; +} + +bool ResourceLDAPTDEIO::isTLS() const +{ + return d->mTLS; +} +void ResourceLDAPTDEIO::setIsSSL( bool value ) +{ + d->mSSL = value; +} + +bool ResourceLDAPTDEIO::isSSL() const +{ + return d->mSSL; +} + +void ResourceLDAPTDEIO::setIsSubTree( bool value ) +{ + d->mSubTree = value; +} + +bool ResourceLDAPTDEIO::isSubTree() const +{ + return d->mSubTree; +} + +void ResourceLDAPTDEIO::setAttributes( const TQMap<TQString, TQString> &attributes ) +{ + mAttributes = attributes; +} + +TQMap<TQString, TQString> ResourceLDAPTDEIO::attributes() const +{ + return mAttributes; +} + +void ResourceLDAPTDEIO::setRDNPrefix( int value ) +{ + d->mRDNPrefix = value; +} + +int ResourceLDAPTDEIO::RDNPrefix() const +{ + return d->mRDNPrefix; +} + +void ResourceLDAPTDEIO::setIsSASL( bool value ) +{ + d->mSASL = value; +} + +bool ResourceLDAPTDEIO::isSASL() const +{ + return d->mSASL; +} + +void ResourceLDAPTDEIO::setMech( const TQString &mech ) +{ + d->mMech = mech; +} + +TQString ResourceLDAPTDEIO::mech() const +{ + return d->mMech; +} + +void ResourceLDAPTDEIO::setRealm( const TQString &realm ) +{ + d->mRealm = realm; +} + +TQString ResourceLDAPTDEIO::realm() const +{ + return d->mRealm; +} + +void ResourceLDAPTDEIO::setBindDN( const TQString &binddn ) +{ + d->mBindDN = binddn; +} + +TQString ResourceLDAPTDEIO::bindDN() const +{ + return d->mBindDN; +} + +void ResourceLDAPTDEIO::setCachePolicy( int pol ) +{ + d->mCachePolicy = pol; +} + +int ResourceLDAPTDEIO::cachePolicy() const +{ + return d->mCachePolicy; +} + +void ResourceLDAPTDEIO::setAutoCache( bool value ) +{ + d->mAutoCache = value; +} + +bool ResourceLDAPTDEIO::autoCache() +{ + return d->mAutoCache; +} + +TQString ResourceLDAPTDEIO::cacheDst() const +{ + return d->mCacheDst; +} + + +#include "resourceldaptdeio.moc" diff --git a/tdeabc/plugins/ldaptdeio/resourceldaptdeio.h b/tdeabc/plugins/ldaptdeio/resourceldaptdeio.h new file mode 100644 index 000000000..051470960 --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/resourceldaptdeio.h @@ -0,0 +1,171 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + Copyright (c) 2004 Szombathelyi György <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCELDAP_H +#define KABC_RESOURCELDAP_H + +#include <tdeabc/resource.h> +#include <tdeabc/ldif.h> +#include <tdeio/job.h> + +class TDEConfig; + +namespace TDEABC { + +class KABC_EXPORT ResourceLDAPTDEIO : public Resource +{ + Q_OBJECT + + public: + enum CachePolicy{ Cache_No, Cache_NoConnection, Cache_Always }; + + ResourceLDAPTDEIO( const TDEConfig* ); + virtual ~ResourceLDAPTDEIO(); + /** + * Call this after you used one of the set... methods + */ + virtual void init(); + + virtual void writeConfig( TDEConfig* ); + + virtual bool doOpen(); + virtual void doClose(); + + virtual Ticket *requestSaveTicket(); + virtual void releaseSaveTicket( Ticket* ); + + virtual bool readOnly() const { return Resource::readOnly(); } + virtual void setReadOnly( bool value ); + + virtual bool load(); + virtual bool asyncLoad(); + virtual bool save( Ticket * ticket ); + virtual bool asyncSave( Ticket * ticket ); + + virtual void removeAddressee( const Addressee& addr ); + + void setUser( const TQString &user ); + TQString user() const; + + void setPassword( const TQString &password ); + TQString password() const; + + void setRealm( const TQString &realm ); + TQString realm() const; + + void setBindDN( const TQString &binddn ); + TQString bindDN() const; + + void setDn( const TQString &dn ); + TQString dn() const; + + void setHost( const TQString &host ); + TQString host() const; + + void setPort( int port ); + int port() const; + + void setVer( int ver ); + int ver() const; + + void setSizeLimit( int sizelimit ); + int sizeLimit(); + + void setTimeLimit( int timelimit ); + int timeLimit(); + + void setFilter( const TQString &filter ); + TQString filter() const; + + void setIsAnonymous( bool value ); + bool isAnonymous() const; + + void setAttributes( const TQMap<TQString, TQString> &attributes ); + TQMap<TQString, TQString> attributes() const; + + void setRDNPrefix( int value ); + int RDNPrefix() const; + + void setIsTLS( bool value ); + bool isTLS() const ; + + void setIsSSL( bool value ); + bool isSSL() const; + + void setIsSubTree( bool value ); + bool isSubTree() const ; + + void setIsSASL( bool value ); + bool isSASL() const ; + + void setMech( const TQString &mech ); + TQString mech() const; + + void setCachePolicy( int pol ); + int cachePolicy() const; + + void setAutoCache( bool value ); + bool autoCache(); + + TQString cacheDst() const; + +protected slots: + void entries( TDEIO::Job*, const TDEIO::UDSEntryList& ); + void data( TDEIO::Job*, const TQByteArray& ); + void result( TDEIO::Job* ); + void listResult( TDEIO::Job* ); + void syncLoadSaveResult( TDEIO::Job* ); + void saveResult( TDEIO::Job* ); + void saveData( TDEIO::Job*, TQByteArray& ); + void loadCacheResult( TDEIO::Job* ); + + private: + TQString mUser; + TQString mPassword; + TQString mDn; + TQString mHost; + TQString mFilter; + int mPort; + bool mAnonymous; + TQMap<TQString, TQString> mAttributes; + + KURL mLDAPUrl; + int mGetCounter; //KDE 4: remove + bool mErrorOccured; //KDE 4: remove + TQString mErrorMsg; + TQMap<TDEIO::Job*, TQByteArray> mJobMap; //KDE 4: remove + + TDEIO::Job *loadFromCache(); + void createCache(); + void activateCache(); + void enter_loop(); + TQCString addEntry( const TQString &attr, const TQString &value, bool mod ); + TQString findUid( const TQString &uid ); + bool AddresseeToLDIF( TQByteArray &ldif, const Addressee &addr, + const TQString &olddn ); + + class ResourceLDAPTDEIOPrivate; + ResourceLDAPTDEIOPrivate *d; +}; + +} + +#endif diff --git a/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.cpp b/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.cpp new file mode 100644 index 000000000..25099414c --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.cpp @@ -0,0 +1,388 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 - 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#include <tqapplication.h> + +#include <tqcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqspinbox.h> +#include <tqvbox.h> +#include <tqvgroupbox.h> +#include <tqhbuttongroup.h> +#include <tqradiobutton.h> + +#include <tdeaccelmanager.h> +#include <kcombobox.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <tdelocale.h> +#include <klineedit.h> +#include <tdemessagebox.h> +#include <tdeio/netaccess.h> + +#include "resourceldaptdeio.h" + +#include "resourceldaptdeioconfig.h" +#include "resourceldaptdeioconfig.moc" + +using namespace TDEABC; + +ResourceLDAPTDEIOConfig::ResourceLDAPTDEIOConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQBoxLayout *mainLayout = new TQVBoxLayout( this ); + mainLayout->setAutoAdd( true ); + cfg = new LdapConfigWidget( LdapConfigWidget::W_ALL, this ); + + mSubTree = new TQCheckBox( i18n( "Sub-tree query" ), this ); + TQHBox *box = new TQHBox( this ); + box->setSpacing( KDialog::spacingHint() ); + mEditButton = new TQPushButton( i18n( "Edit Attributes..." ), box ); + mCacheButton = new TQPushButton( i18n( "Offline Use..." ), box ); + + connect( mEditButton, TQT_SIGNAL( clicked() ), TQT_SLOT( editAttributes() ) ); + connect( mCacheButton, TQT_SIGNAL( clicked() ), TQT_SLOT( editCache() ) ); +} + +void ResourceLDAPTDEIOConfig::loadSettings( KRES::Resource *res ) +{ + ResourceLDAPTDEIO *resource = dynamic_cast<ResourceLDAPTDEIO*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceLDAPTDEIOConfig::loadSettings(): cast failed" << endl; + return; + } + + cfg->setUser( resource->user() ); + cfg->setPassword( resource->password() ); + cfg->setRealm( resource->realm() ); + cfg->setBindDN( resource->bindDN() ); + cfg->setHost( resource->host() ); + cfg->setPort( resource->port() ); + cfg->setVer( resource->ver() ); + cfg->setTimeLimit( resource->timeLimit() ); + cfg->setSizeLimit( resource->sizeLimit() ); + cfg->setDn( resource->dn() ); + cfg->setFilter( resource->filter() ); + cfg->setMech( resource->mech() ); + if ( resource->isTLS() ) cfg->setSecTLS(); + else if ( resource->isSSL() ) cfg->setSecSSL(); + else cfg->setSecNO(); + if ( resource->isAnonymous() ) cfg->setAuthAnon(); + else if ( resource->isSASL() ) cfg->setAuthSASL(); + else cfg->setAuthSimple(); + + mSubTree->setChecked( resource->isSubTree() ); + mAttributes = resource->attributes(); + mRDNPrefix = resource->RDNPrefix(); + mCachePolicy = resource->cachePolicy(); + mCacheDst = resource->cacheDst(); + mAutoCache = resource->autoCache(); +} + +void ResourceLDAPTDEIOConfig::saveSettings( KRES::Resource *res ) +{ + ResourceLDAPTDEIO *resource = dynamic_cast<ResourceLDAPTDEIO*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceLDAPTDEIOConfig::saveSettings(): cast failed" << endl; + return; + } + + resource->setUser( cfg->user() ); + resource->setPassword( cfg->password() ); + resource->setRealm( cfg->realm() ); + resource->setBindDN( cfg->bindDN() ); + resource->setHost( cfg->host() ); + resource->setPort( cfg->port() ); + resource->setVer( cfg->ver() ); + resource->setTimeLimit( cfg->timeLimit() ); + resource->setSizeLimit( cfg->sizeLimit() ); + resource->setDn( cfg->dn() ); + resource->setFilter( cfg->filter() ); + resource->setIsAnonymous( cfg->isAuthAnon() ); + resource->setIsSASL( cfg->isAuthSASL() ); + resource->setMech( cfg->mech() ); + resource->setIsTLS( cfg->isSecTLS() ); + resource->setIsSSL( cfg->isSecSSL() ); + resource->setIsSubTree( mSubTree->isChecked() ); + resource->setAttributes( mAttributes ); + resource->setRDNPrefix( mRDNPrefix ); + resource->setCachePolicy( mCachePolicy ); + resource->init(); + +} + +void ResourceLDAPTDEIOConfig::editAttributes() +{ + AttributesDialog dlg( mAttributes, mRDNPrefix, this ); + if ( dlg.exec() ) { + mAttributes = dlg.attributes(); + mRDNPrefix = dlg.rdnprefix(); + } +} + +void ResourceLDAPTDEIOConfig::editCache() +{ + LDAPUrl src; + TQStringList attr; + + src = cfg->url(); + src.setScope( mSubTree->isChecked() ? LDAPUrl::Sub : LDAPUrl::One ); + if (!mAttributes.empty()) { + TQMap<TQString,TQString>::Iterator it; + TQStringList attr; + for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) { + if ( !it.data().isEmpty() && it.key() != "objectClass" ) + attr.append( it.data() ); + } + src.setAttributes( attr ); + } + src.setExtension( "x-dir", "base" ); + OfflineDialog dlg( mAutoCache, mCachePolicy, src, mCacheDst, this ); + if ( dlg.exec() ) { + mCachePolicy = dlg.cachePolicy(); + mAutoCache = dlg.autoCache(); + } + +} + +AttributesDialog::AttributesDialog( const TQMap<TQString, TQString> &attributes, + int rdnprefix, + TQWidget *parent, const char *name ) + : KDialogBase( Plain, i18n( "Attributes Configuration" ), Ok | Cancel, + Ok, parent, name, true, true ) +{ + mNameDict.setAutoDelete( true ); + mNameDict.insert( "objectClass", new TQString( i18n( "Object classes" ) ) ); + mNameDict.insert( "commonName", new TQString( i18n( "Common name" ) ) ); + mNameDict.insert( "formattedName", new TQString( i18n( "Formatted name" ) ) ); + mNameDict.insert( "familyName", new TQString( i18n( "Family name" ) ) ); + mNameDict.insert( "givenName", new TQString( i18n( "Given name" ) ) ); + mNameDict.insert( "organization", new TQString( i18n( "Organization" ) ) ); + mNameDict.insert( "title", new TQString( i18n( "Title" ) ) ); + mNameDict.insert( "street", new TQString( i18n( "Street" ) ) ); + mNameDict.insert( "state", new TQString( i18n( "State" ) ) ); + mNameDict.insert( "city", new TQString( i18n( "City" ) ) ); + mNameDict.insert( "postalcode", new TQString( i18n( "Postal code" ) ) ); + mNameDict.insert( "mail", new TQString( i18n( "Email" ) ) ); + mNameDict.insert( "mailAlias", new TQString( i18n( "Email alias" ) ) ); + mNameDict.insert( "phoneNumber", new TQString( i18n( "Telephone number" ) ) ); + mNameDict.insert( "telephoneNumber", new TQString( i18n( "Work telephone number" ) ) ); + mNameDict.insert( "facsimileTelephoneNumber", new TQString( i18n( "Fax number" ) ) ); + mNameDict.insert( "mobile", new TQString( i18n( "Cell phone number" ) ) ); + mNameDict.insert( "pager", new TQString( i18n( "Pager" ) ) ); + mNameDict.insert( "description", new TQString( i18n( "Note" ) ) ); + mNameDict.insert( "uid", new TQString( i18n( "UID" ) ) ); + mNameDict.insert( "jpegPhoto", new TQString( i18n( "Photo" ) ) ); + + // default map + mDefaultMap.insert( "objectClass", "inetOrgPerson" ); + mDefaultMap.insert( "commonName", "cn" ); + mDefaultMap.insert( "formattedName", "displayName" ); + mDefaultMap.insert( "familyName", "sn" ); + mDefaultMap.insert( "givenName", "givenName" ); + mDefaultMap.insert( "title", "title" ); + mDefaultMap.insert( "street", "street" ); + mDefaultMap.insert( "state", "st" ); + mDefaultMap.insert( "city", "l" ); + mDefaultMap.insert( "organization", "o" ); + mDefaultMap.insert( "postalcode", "postalCode" ); + mDefaultMap.insert( "mail", "mail" ); + mDefaultMap.insert( "mailAlias", "" ); + mDefaultMap.insert( "phoneNumber", "homePhone" ); + mDefaultMap.insert( "telephoneNumber", "telephoneNumber" ); + mDefaultMap.insert( "facsimileTelephoneNumber", "facsimileTelephoneNumber" ); + mDefaultMap.insert( "mobile", "mobile" ); + mDefaultMap.insert( "pager", "pager" ); + mDefaultMap.insert( "description", "description" ); + mDefaultMap.insert( "uid", "uid" ); + mDefaultMap.insert( "jpegPhoto", "jpegPhoto" ); + + // overwrite the default values here + TQMap<TQString, TQString> kolabMap, netscapeMap, evolutionMap, outlookMap; + + // kolab + kolabMap.insert( "formattedName", "display-name" ); + kolabMap.insert( "mailAlias", "mailalias" ); + + // evolution + evolutionMap.insert( "formattedName", "fileAs" ); + + mMapList.append( attributes ); + mMapList.append( kolabMap ); + mMapList.append( netscapeMap ); + mMapList.append( evolutionMap ); + mMapList.append( outlookMap ); + + TQFrame *page = plainPage(); + TQGridLayout *layout = new TQGridLayout( page, 4, ( attributes.count() + 4 ) >> 1, + 0, spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "Template:" ), page ); + layout->addWidget( label, 0, 0 ); + mMapCombo = new KComboBox( page ); + layout->addWidget( mMapCombo, 0, 1 ); + + mMapCombo->insertItem( i18n( "User Defined" ) ); + mMapCombo->insertItem( i18n( "Kolab" ) ); + mMapCombo->insertItem( i18n( "Netscape" ) ); + mMapCombo->insertItem( i18n( "Evolution" ) ); + mMapCombo->insertItem( i18n( "Outlook" ) ); + connect( mMapCombo, TQT_SIGNAL( activated( int ) ), TQT_SLOT( mapChanged( int ) ) ); + + label = new TQLabel( i18n( "RDN prefix attribute:" ), page ); + layout->addWidget( label, 1, 0 ); + mRDNCombo = new KComboBox( page ); + layout->addWidget( mRDNCombo, 1, 1 ); + mRDNCombo->insertItem( i18n( "commonName" ) ); + mRDNCombo->insertItem( i18n( "UID" ) ); + mRDNCombo->setCurrentItem( rdnprefix ); + + TQMap<TQString, TQString>::ConstIterator it; + int i, j = 0; + for ( i = 2, it = attributes.begin(); it != attributes.end(); ++it, ++i ) { + if ( mNameDict[ it.key() ] == 0 ) { + i--; + continue; + } + if ( (uint)(i - 2) == ( mNameDict.count() >> 1 ) ) { + i = 0; + j = 2; + } + kdDebug(7125) << "itkey: " << it.key() << " i: " << i << endl; + label = new TQLabel( *mNameDict[ it.key() ] + ":", page ); + KLineEdit *lineedit = new KLineEdit( page ); + mLineEditDict.insert( it.key(), lineedit ); + lineedit->setText( it.data() ); + label->setBuddy( lineedit ); + layout->addWidget( label, i, j ); + layout->addWidget( lineedit, i, j+1 ); + } + + for ( i = 1; i < mMapCombo->count(); i++ ) { + TQDictIterator<KLineEdit> it2( mLineEditDict ); + for ( ; it2.current(); ++it2 ) { + if ( mMapList[ i ].contains( it2.currentKey() ) ) { + if ( mMapList[ i ][ it2.currentKey() ] != it2.current()->text() ) break; + } else { + if ( mDefaultMap[ it2.currentKey() ] != it2.current()->text() ) break; + } + } + if ( !it2.current() ) { + mMapCombo->setCurrentItem( i ); + break; + } + } + + TDEAcceleratorManager::manage( this ); +} + +AttributesDialog::~AttributesDialog() +{ +} + +TQMap<TQString, TQString> AttributesDialog::attributes() const +{ + TQMap<TQString, TQString> map; + + TQDictIterator<KLineEdit> it( mLineEditDict ); + for ( ; it.current(); ++it ) + map.insert( it.currentKey(), it.current()->text() ); + + return map; +} + +int AttributesDialog::rdnprefix() const +{ + return mRDNCombo->currentItem(); +} + +void AttributesDialog::mapChanged( int pos ) +{ + + // apply first the default and than the spezific changes + TQMap<TQString, TQString>::Iterator it; + for ( it = mDefaultMap.begin(); it != mDefaultMap.end(); ++it ) + mLineEditDict[ it.key() ]->setText( it.data() ); + + for ( it = mMapList[ pos ].begin(); it != mMapList[ pos ].end(); ++it ) { + if ( !it.data().isEmpty() ) { + KLineEdit *le = mLineEditDict[ it.key() ]; + if ( le ) le->setText( it.data() ); + } + } +} + +OfflineDialog::OfflineDialog( bool autoCache, int cachePolicy, const KURL &src, + const TQString &dst, TQWidget *parent, const char *name ) + : KDialogBase( Plain, i18n( "Offline Configuration" ), Ok | Cancel, + Ok, parent, name, true, true ) +{ + TQFrame *page = plainPage(); + TQVBoxLayout *layout = new TQVBoxLayout( page ); + layout->setAutoAdd( true ); + + mSrc = src; mDst = dst; + mCacheGroup = new TQButtonGroup( 1, Qt::Horizontal, + i18n("Offline Cache Policy"), page ); + + TQRadioButton *bt; + new TQRadioButton( i18n("Do not use offline cache"), mCacheGroup ); + bt = new TQRadioButton( i18n("Use local copy if no connection"), mCacheGroup ); + new TQRadioButton( i18n("Always use local copy"), mCacheGroup ); + mCacheGroup->setButton( cachePolicy ); + + mAutoCache = new TQCheckBox( i18n("Refresh offline cache automatically"), + page ); + mAutoCache->setChecked( autoCache ); + mAutoCache->setEnabled( bt->isChecked() ); + + connect( bt, TQT_SIGNAL(toggled(bool)), mAutoCache, TQT_SLOT(setEnabled(bool)) ); + + TQPushButton *lcache = new TQPushButton( i18n("Load into Cache"), page ); + connect( lcache, TQT_SIGNAL( clicked() ), TQT_SLOT( loadCache() ) ); +} + +OfflineDialog::~OfflineDialog() +{ +} + +bool OfflineDialog::autoCache() const +{ + return mAutoCache->isChecked(); +} + +int OfflineDialog::cachePolicy() const +{ + return mCacheGroup->selectedId(); +} + +void OfflineDialog::loadCache() +{ + if ( TDEIO::NetAccess::download( mSrc, mDst, this ) ) { + KMessageBox::information( this, + i18n("Successfully downloaded directory server contents!") ); + } else { + KMessageBox::error( this, + i18n("An error occurred downloading directory server contents into file %1.").arg(mDst) ); + } +} diff --git a/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.h b/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.h new file mode 100644 index 000000000..0041946b7 --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/resourceldaptdeioconfig.h @@ -0,0 +1,118 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 - 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCELDAPCONFIG_H +#define RESOURCELDAPCONFIG_H + +#include <tqmap.h> +#include <tqradiobutton.h> +#include <tqcombobox.h> +#include <tqdict.h> + +#include <kdialogbase.h> +#include <tderesources/configwidget.h> +#include <tdeabc/ldif.h> +#include <tdeabc/ldapconfigwidget.h> + + +class TQCheckBox; +class TQPushButton; +class TQSpinBox; +class TQString; + +class KComboBox; +class KLineEdit; + +namespace TDEABC { + +class KABC_EXPORT ResourceLDAPTDEIOConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + public: + ResourceLDAPTDEIOConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + private slots: + void editAttributes(); + void editCache(); + private: + TQPushButton *mEditButton, *mCacheButton; + LdapConfigWidget *cfg; + TQCheckBox *mSubTree; + TQMap<TQString, TQString> mAttributes; + int mRDNPrefix, mCachePolicy; + bool mAutoCache; + TQString mCacheDst; +}; + +class AttributesDialog : public KDialogBase +{ + Q_OBJECT + + public: + AttributesDialog( const TQMap<TQString, TQString> &attributes, int rdnprefix, + TQWidget *parent, const char *name = 0 ); + ~AttributesDialog(); + + TQMap<TQString, TQString> attributes() const; + int rdnprefix() const; + + private slots: + void mapChanged( int pos ); + + private: + enum { UserMap, KolabMap, NetscapeMap, EvolutionMap, OutlookMap }; + + KComboBox *mMapCombo, *mRDNCombo; + TQValueList< TQMap<TQString, TQString> > mMapList; + TQMap<TQString, TQString> mDefaultMap; + TQDict<KLineEdit> mLineEditDict; + TQDict<TQString> mNameDict; +}; + +class OfflineDialog : public KDialogBase +{ + Q_OBJECT + + public: + OfflineDialog( bool autoCache, int cachePolicy, const KURL &src, + const TQString &dst, TQWidget *parent, const char *name = 0 ); + ~OfflineDialog(); + + int cachePolicy() const; + bool autoCache() const; + + private slots: + void loadCache(); + + private: + KURL mSrc; + TQString mDst; + TQButtonGroup *mCacheGroup; + TQCheckBox *mAutoCache; +}; + +} + +#endif diff --git a/tdeabc/plugins/ldaptdeio/resourceldaptdeioplugin.cpp b/tdeabc/plugins/ldaptdeio/resourceldaptdeioplugin.cpp new file mode 100644 index 000000000..dcb373b3c --- /dev/null +++ b/tdeabc/plugins/ldaptdeio/resourceldaptdeioplugin.cpp @@ -0,0 +1,36 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "resourceldaptdeio.h" +#include "resourceldaptdeioconfig.h" + +#include <tdeglobal.h> +#include <tdelocale.h> + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_ldaptdeio() + { + TDEGlobal::locale()->insertCatalogue("tdeabc_ldaptdeio"); + return new KRES::PluginFactory<ResourceLDAPTDEIO, ResourceLDAPTDEIOConfig>(); + } +} diff --git a/tdeabc/plugins/net/CMakeLists.txt b/tdeabc/plugins/net/CMakeLists.txt new file mode 100644 index 000000000..71a5c49df --- /dev/null +++ b/tdeabc/plugins/net/CMakeLists.txt @@ -0,0 +1,73 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdeabc + ${CMAKE_SOURCE_DIR}/tdeabc + + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dcop + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + resourcenet.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### other data ################################ + +install( FILES net.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/tdeabc ) + + +##### tdeabc_net (library) ######################## + +set( target tdeabc_net ) + +set( ${target}_SRCS + resourcenet.cpp resourcenetconfig.cpp +) + +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION 1.0.0 + LINK tdeabc-shared + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### tdeabc_net (module) ######################### + +set( target tdeabc_net ) + +set( ${target}_SRCS + resourcenetplugin.cpp +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdeabc_net-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeabc/plugins/net/Makefile.am b/tdeabc/plugins/net/Makefile.am new file mode 100644 index 000000000..8fd53f34f --- /dev/null +++ b/tdeabc/plugins/net/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = -I$(top_srcdir)/tdeabc -I$(top_builddir)/tdeabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourcenetconfig.h + +lib_LTLIBRARIES = libtdeabc_net.la +libtdeabc_net_la_SOURCES = resourcenet.cpp resourcenetconfig.cpp +libtdeabc_net_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined +libtdeabc_net_la_LIBADD = $(top_builddir)/tdeabc/libkabc.la $(LIB_KIO) +libtdeabc_net_la_COMPILE_FIRST = $(top_builddir)/tdeabc/addressee.h + +kde_module_LTLIBRARIES = tdeabc_net.la +tdeabc_net_la_SOURCES = resourcenetplugin.cpp +tdeabc_net_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -L../../../tdecore/.libs/ -ltdecore +tdeabc_net_la_LIBADD = libtdeabc_net.la + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_net.pot + +kabcincludedir = $(includedir)/tdeabc +kabcinclude_HEADERS = resourcenet.h + +servicedir = $(kde_servicesdir)/tderesources/tdeabc +service_DATA = net.desktop + +resourcenetplugin.lo: ../../addressee.h diff --git a/tdeabc/plugins/net/net.desktop b/tdeabc/plugins/net/net.desktop new file mode 100644 index 000000000..adc7394b5 --- /dev/null +++ b/tdeabc/plugins/net/net.desktop @@ -0,0 +1,90 @@ +[Desktop Entry] +Name=Network +Name[af]=Netwerk +Name[ar]=الشبكة +Name[az]=Şəbəkə +Name[be]=Сетка +Name[bn]=নেটওয়ার্ক +Name[br]=Rouedad +Name[bs]=Mreža +Name[ca]=Xarxa +Name[cs]=Síť +Name[csb]=Sec +Name[cy]=Rhydwaith +Name[da]=Netværk +Name[de]=Netzwerk +Name[el]=Δίκτυο +Name[eo]=Reto +Name[es]=Red +Name[et]=Võrk +Name[eu]=Sarea +Name[fa]=شبکه +Name[fi]=Verkko +Name[fr]=Réseau +Name[fy]=Netwurk +Name[ga]=Líonra +Name[gl]=Rede +Name[he]=רשת +Name[hi]=नेटवर्क +Name[hr]=Mreža +Name[hsb]=Syć +Name[hu]=Hálózat +Name[id]=Jaringan +Name[is]=Net +Name[it]=Rete +Name[ja]=ネットワーク +Name[ka]=ქსელი +Name[kk]=Желі +Name[km]=បណ្តាញ +Name[ko]=네트워크 +Name[ku]=Tor +Name[lb]=Netzwierk +Name[lt]=Tinklas +Name[lv]=Tīkls +Name[mi]=Hao +Name[mk]=Мрежа +Name[mn]=Сүлжээ +Name[ms]=Jaringan +Name[nds]=Nettwark +Name[ne]=सञ्जाल +Name[nl]=Netwerk +Name[nn]=Nettverk +Name[nso]=Kgokagano +Name[oc]=Resèu +Name[pa]=ਨੈੱਟਵਰਕ +Name[pl]=Sieć +Name[pt]=Rede +Name[pt_BR]=Rede +Name[ro]=Reţea +Name[ru]=Сеть +Name[rw]=Urusobe +Name[se]=Fierbmi +Name[sk]=Sieť +Name[sl]=Omrežje +Name[sq]=Rrjeta +Name[sr]=Мрежа +Name[sr@Latn]=Mreža +Name[ss]=Luchungechunge +Name[sv]=Nätverk +Name[ta]=பிணையம் +Name[te]=కలన జాలం +Name[tg]=Шабака +Name[th]=ระบบเครือข่าย +Name[tr]=Ağ +Name[tt]=Çeltär +Name[uk]=Мережа +Name[uz]=Tarmoq +Name[uz@cyrillic]=Tarмоқ +Name[ven]=Vhukwamani +Name[vi]=mạng +Name[wa]=Rantoele +Name[xh]=Umsebenzi womnatha +Name[zh_CN]=网络 +Name[zh_HK]=網絡 +Name[zh_TW]=網路 +Name[zu]=Umsebenzi wokuxhumana okusakazekile +X-TDE-Library=tdeabc_net +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=net diff --git a/tdeabc/plugins/net/resourcenet.cpp b/tdeabc/plugins/net/resourcenet.cpp new file mode 100644 index 000000000..390e84224 --- /dev/null +++ b/tdeabc/plugins/net/resourcenet.cpp @@ -0,0 +1,393 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqfile.h> + +#include <kdebug.h> +#include <tdeio/netaccess.h> +#include <tdeio/scheduler.h> +#include <tdelocale.h> +#include <ksavefile.h> +#include <tdetempfile.h> +#include <kurlrequester.h> + +#include "addressbook.h" +#include "formatfactory.h" +#include "resourcenetconfig.h" +#include "stdaddressbook.h" + +#include "resourcenet.h" + +using namespace TDEABC; + +class ResourceNet::ResourceNetPrivate +{ + public: + TDEIO::Job *mLoadJob; + bool mIsLoading; + + TDEIO::Job *mSaveJob; + bool mIsSaving; + + TQString mLastErrorString; +}; + +ResourceNet::ResourceNet( const TDEConfig *config ) + : Resource( config ), mFormat( 0 ), + mTempFile( 0 ), + d( new ResourceNetPrivate ) +{ + if ( config ) { + init( KURL( config->readPathEntry( "NetUrl" ) ), config->readEntry( "NetFormat" ) ); + } else { + init( KURL(), TQString("vcard").latin1() ); + } +} + +ResourceNet::ResourceNet( const KURL &url, const TQString &format ) + : Resource( 0 ), mFormat( 0 ), + mTempFile( 0 ), + d( new ResourceNetPrivate ) +{ + init( url, format ); +} + +void ResourceNet::init( const KURL &url, const TQString &format ) +{ + d->mLoadJob = 0; + d->mIsLoading = false; + d->mSaveJob = 0; + d->mIsSaving = false; + + mFormatName = format; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); + if ( !mFormat ) { + mFormatName = TQString("vcard").latin1(); + mFormat = factory->format( mFormatName ); + } + + setUrl( url ); +} + +ResourceNet::~ResourceNet() +{ + if ( d->mIsLoading ) + d->mLoadJob->kill(); + if ( d->mIsSaving ) + d->mSaveJob->kill(); + + delete d; + d = 0; + + delete mFormat; + mFormat = 0; + + deleteLocalTempFile(); +} + +void ResourceNet::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + config->writePathEntry( "NetUrl", mUrl.url() ); + config->writeEntry( "NetFormat", mFormatName ); +} + +Ticket *ResourceNet::requestSaveTicket() +{ + kdDebug(5700) << "ResourceNet::requestSaveTicket()" << endl; + + return createTicket( this ); +} + +void ResourceNet::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceNet::doOpen() +{ + return true; +} + +void ResourceNet::doClose() +{ +} + +bool ResourceNet::load() +{ + TQString tempFile; + + if ( !TDEIO::NetAccess::download( mUrl, tempFile, 0 ) ) { + addressBook()->error( i18n( "Unable to download file '%1'." ).arg( mUrl.prettyURL() ) ); + return false; + } + + TQFile file( tempFile ); + if ( !file.open( IO_ReadOnly ) ) { + addressBook()->error( i18n( "Unable to open file '%1'." ).arg( tempFile ) ); + TDEIO::NetAccess::removeTempFile( tempFile ); + return false; + } + + bool result = clearAndLoad( &file ); + if ( !result ) + addressBook()->error( i18n( "Problems during parsing file '%1'." ).arg( tempFile ) ); + + TDEIO::NetAccess::removeTempFile( tempFile ); + + return result; +} + +bool ResourceNet::clearAndLoad( TQFile *file ) +{ + clear(); + return mFormat->loadAll( addressBook(), this, file ); +} + +bool ResourceNet::asyncLoad() +{ + if ( d->mIsLoading ) { + abortAsyncLoading(); + } + + if (d->mIsSaving) { + kdWarning(5700) << "Aborted asyncLoad() because we're still asyncSave()ing!" << endl; + return false; + } + + bool ok = createLocalTempFile(); + if ( ok ) + mTempFile->sync(); + ok = mTempFile->close(); + + if ( !ok ) { + emit loadingError( this, i18n( "Unable to open file '%1'." ).arg( mTempFile->name() ) ); + deleteLocalTempFile(); + return false; + } + + KURL dest; + dest.setPath( mTempFile->name() ); + + TDEIO::Scheduler::checkSlaveOnHold( true ); + d->mLoadJob = TDEIO::file_copy( mUrl, dest, -1, true, false, false ); + d->mIsLoading = true; + connect( d->mLoadJob, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( downloadFinished( TDEIO::Job* ) ) ); + + return true; +} + +void ResourceNet::abortAsyncLoading() +{ + kdDebug(5700) << "ResourceNet::abortAsyncLoading()" << endl; + + if ( d->mLoadJob ) { + d->mLoadJob->kill(); // result not emitted + d->mLoadJob = 0; + } + + deleteLocalTempFile(); + d->mIsLoading = false; +} + +void ResourceNet::abortAsyncSaving() +{ + kdDebug(5700) << "ResourceNet::abortAsyncSaving()" << endl; + + if ( d->mSaveJob ) { + d->mSaveJob->kill(); // result not emitted + d->mSaveJob = 0; + } + + deleteLocalTempFile(); + d->mIsSaving = false; +} + +bool ResourceNet::save( Ticket* ) +{ + kdDebug(5700) << "ResourceNet::save()" << endl; + + if (d->mIsSaving) { + abortAsyncSaving(); + } + + KTempFile tempFile; + tempFile.setAutoDelete( true ); + bool ok = false; + + if ( tempFile.status() == 0 && tempFile.file() ) { + saveToFile( tempFile.file() ); + tempFile.sync(); + ok = tempFile.close(); + } + + if ( !ok ) { + addressBook()->error( i18n( "Unable to save file '%1'." ).arg( tempFile.name() ) ); + return false; + } + + ok = TDEIO::NetAccess::upload( tempFile.name(), mUrl, 0 ); + if ( !ok ) + addressBook()->error( i18n( "Unable to upload to '%1'." ).arg( mUrl.prettyURL() ) ); + + return ok; +} + +bool ResourceNet::asyncSave( Ticket* ) +{ + kdDebug(5700) << "ResourceNet::asyncSave()" << endl; + + if (d->mIsSaving) { + abortAsyncSaving(); + } + + if (d->mIsLoading) { + kdWarning(5700) << "Aborted asyncSave() because we're still asyncLoad()ing!" << endl; + return false; + } + + bool ok = createLocalTempFile(); + if ( ok ) { + saveToFile( mTempFile->file() ); + mTempFile->sync(); + ok = mTempFile->close(); + } + + if ( !ok ) { + emit savingError( this, i18n( "Unable to save file '%1'." ).arg( mTempFile->name() ) ); + deleteLocalTempFile(); + return false; + } + + KURL src; + src.setPath( mTempFile->name() ); + + TDEIO::Scheduler::checkSlaveOnHold( true ); + d->mIsSaving = true; + d->mSaveJob = TDEIO::file_copy( src, mUrl, -1, true, false, false ); + connect( d->mSaveJob, TQT_SIGNAL( result( TDEIO::Job* ) ), + this, TQT_SLOT( uploadFinished( TDEIO::Job* ) ) ); + + return true; +} + +bool ResourceNet::createLocalTempFile() +{ + deleteStaleTempFile(); + mTempFile = new KTempFile(); + mTempFile->setAutoDelete( true ); + return mTempFile->status() == 0; +} + +void ResourceNet::deleteStaleTempFile() +{ + if ( hasTempFile() ) { + kdDebug(5700) << "stale temp file detected " << mTempFile->name() << endl; + deleteLocalTempFile(); + } +} + +void ResourceNet::deleteLocalTempFile() +{ + delete mTempFile; + mTempFile = 0; +} + +void ResourceNet::saveToFile( TQFile *file ) +{ + mFormat->saveAll( addressBook(), this, file ); +} + +void ResourceNet::setUrl( const KURL &url ) +{ + mUrl = url; +} + +KURL ResourceNet::url() const +{ + return mUrl; +} + +void ResourceNet::setFormat( const TQString &name ) +{ + mFormatName = name; + if ( mFormat ) + delete mFormat; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); +} + +TQString ResourceNet::format() const +{ + return mFormatName; +} + +void ResourceNet::downloadFinished( TDEIO::Job* ) +{ + kdDebug(5700) << "ResourceNet::downloadFinished()" << endl; + + d->mIsLoading = false; + + if ( !hasTempFile() || mTempFile->status() != 0 ) { + d->mLastErrorString = i18n( "Download failed: Unable to create temporary file" ); + TQTimer::singleShot( 0, this, TQT_SLOT( signalError() ) ); + return; + } + + TQFile file( mTempFile->name() ); + if ( file.open( IO_ReadOnly ) ) { + if ( clearAndLoad( &file ) ) + emit loadingFinished( this ); + else + emit loadingError( this, i18n( "Problems during parsing file '%1'." ).arg( mTempFile->name() ) ); + } + else { + emit loadingError( this, i18n( "Unable to open file '%1'." ).arg( mTempFile->name() ) ); + } + + deleteLocalTempFile(); +} + +void ResourceNet::uploadFinished( TDEIO::Job *job ) +{ + kdDebug(5700) << "ResourceFile::uploadFinished()" << endl; + + d->mIsSaving = false; + + if ( job->error() ) + emit savingError( this, job->errorString() ); + else + emit savingFinished( this ); + + deleteLocalTempFile(); +} + +void ResourceNet::signalError() +{ + emit loadingError( this, d->mLastErrorString ); + d->mLastErrorString.truncate( 0 ); +} + +#include "resourcenet.moc" diff --git a/tdeabc/plugins/net/resourcenet.h b/tdeabc/plugins/net/resourcenet.h new file mode 100644 index 000000000..18a3b715b --- /dev/null +++ b/tdeabc/plugins/net/resourcenet.h @@ -0,0 +1,117 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCENET_H +#define KABC_RESOURCENET_H + +#include <tdeconfig.h> + +#include <sys/types.h> + +#include <tdeabc/resource.h> + +class TQFile; +class TQTimer; +class KTempFile; + +namespace TDEIO { +class Job; +} + +namespace TDEABC { + +class FormatPlugin; + +/** + @internal +*/ +class KABC_EXPORT ResourceNet : public Resource +{ + Q_OBJECT + + public: + ResourceNet( const TDEConfig* ); + ResourceNet( const KURL &url, const TQString &format ); + ~ResourceNet(); + + virtual void writeConfig( TDEConfig* ); + + virtual bool doOpen(); + virtual void doClose(); + + virtual Ticket *requestSaveTicket(); + virtual void releaseSaveTicket( Ticket* ); + + virtual bool load(); + virtual bool asyncLoad(); + virtual bool save( Ticket* ticket ); + virtual bool asyncSave( Ticket* ticket ); + + /** + Set url of directory to be used for saving. + */ + void setUrl( const KURL & ); + + /** + Return url of directory used for loading and saving the address book. + */ + KURL url() const; + + /** + Sets a new format by name. + */ + void setFormat( const TQString &name ); + + /** + Returns the format name. + */ + TQString format() const; + + protected: + void init( const KURL &url, const TQString &format ); + + private slots: + void downloadFinished( TDEIO::Job* ); + void uploadFinished( TDEIO::Job* ); + void signalError(); + + private: + bool clearAndLoad( TQFile *file ); + void saveToFile( TQFile *file ); + bool hasTempFile() const { return mTempFile != 0; } + void abortAsyncLoading(); + void abortAsyncSaving(); + bool createLocalTempFile(); + void deleteLocalTempFile(); + void deleteStaleTempFile(); + + FormatPlugin *mFormat; + TQString mFormatName; + + KURL mUrl; + KTempFile *mTempFile; + + class ResourceNetPrivate; + ResourceNetPrivate *d; +}; + +} + +#endif diff --git a/tdeabc/plugins/net/resourcenetconfig.cpp b/tdeabc/plugins/net/resourcenetconfig.cpp new file mode 100644 index 000000000..ab3cddf3e --- /dev/null +++ b/tdeabc/plugins/net/resourcenetconfig.cpp @@ -0,0 +1,102 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlabel.h> +#include <tqlayout.h> + +#include <kdebug.h> +#include <tdelocale.h> +#include <kdialog.h> + +#include "formatfactory.h" +#include "resourcenet.h" +#include "stdaddressbook.h" + +#include "resourcenetconfig.h" + +using namespace TDEABC; + +ResourceNetConfig::ResourceNetConfig( TQWidget* parent, const char* name ) + : ConfigWidget( parent, name ), mInEditMode( false ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0, + KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "Format:" ), this ); + mFormatBox = new KComboBox( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mFormatBox, 0, 1 ); + + label = new TQLabel( i18n( "Location:" ), this ); + mUrlEdit = new KURLRequester( this ); + mUrlEdit->setMode( KFile::File ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mUrlEdit, 1, 1 ); + + FormatFactory *factory = FormatFactory::self(); + TQStringList formats = factory->formats(); + TQStringList::Iterator it; + for ( it = formats.begin(); it != formats.end(); ++it ) { + FormatInfo *info = factory->info( *it ); + if ( info ) { + mFormatTypes << (*it); + mFormatBox->insertItem( info->nameLabel ); + } + } +} + +void ResourceNetConfig::setEditMode( bool value ) +{ + mFormatBox->setEnabled( !value ); + mInEditMode = value; +} + +void ResourceNetConfig::loadSettings( KRES::Resource *res ) +{ + ResourceNet *resource = dynamic_cast<ResourceNet*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceNetConfig::loadSettings(): cast failed" << endl; + return; + } + + mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); + + mUrlEdit->setURL( resource->url().url() ); +} + +void ResourceNetConfig::saveSettings( KRES::Resource *res ) +{ + ResourceNet *resource = dynamic_cast<ResourceNet*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceNetConfig::saveSettings(): cast failed" << endl; + return; + } + + if ( !mInEditMode ) + resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); + + resource->setUrl( KURL( mUrlEdit->url() ) ); +} + +#include "resourcenetconfig.moc" diff --git a/tdeabc/plugins/net/resourcenetconfig.h b/tdeabc/plugins/net/resourcenetconfig.h new file mode 100644 index 000000000..f2ba37800 --- /dev/null +++ b/tdeabc/plugins/net/resourcenetconfig.h @@ -0,0 +1,53 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCENETCONFIG_H +#define RESOURCENETCONFIG_H + +#include <kcombobox.h> +#include <kurlrequester.h> + +#include <tderesources/configwidget.h> + +namespace TDEABC { + +class KABC_EXPORT ResourceNetConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + public: + ResourceNetConfig( TQWidget* parent = 0, const char* name = 0 ); + + void setEditMode( bool value ); + + public slots: + void loadSettings( KRES::Resource *resource ); + void saveSettings( KRES::Resource *resource ); + + private: + KComboBox* mFormatBox; + KURLRequester* mUrlEdit; + + TQStringList mFormatTypes; + bool mInEditMode; +}; + +} +#endif diff --git a/tdeabc/plugins/net/resourcenetplugin.cpp b/tdeabc/plugins/net/resourcenetplugin.cpp new file mode 100644 index 000000000..8db397152 --- /dev/null +++ b/tdeabc/plugins/net/resourcenetplugin.cpp @@ -0,0 +1,32 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "resourcenet.h" +#include "resourcenetconfig.h" + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_net() + { + return new KRES::PluginFactory<ResourceNet, ResourceNetConfig>(); + } +} diff --git a/tdeabc/plugins/sql/Makefile.am b/tdeabc/plugins/sql/Makefile.am new file mode 100644 index 000000000..43dd193f6 --- /dev/null +++ b/tdeabc/plugins/sql/Makefile.am @@ -0,0 +1,20 @@ +INCLUDES = -I$(top_srcdir)/tdeabc -I$(top_builddir)/tdeabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourcesql.h resourcesqlconfig.h + +kde_module_LTLIBRARIES = tdeabc_sql.la + +tdeabc_sql_la_SOURCES = resourcesql.cpp resourcesqlconfig.cpp + +tdeabc_sql_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +tdeabc_sql_la_LIBADD = ../../libkabc.la ../../../tdeui/libtdeui.la + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdeabc_sql.pot + +linkdir = $(kde_datadir)/tderesources/contact +link_DATA = sql.desktop +EXTRA_DIST = $(link_DATA) diff --git a/tdeabc/plugins/sql/resourcesql.cpp b/tdeabc/plugins/sql/resourcesql.cpp new file mode 100644 index 000000000..ed284cdc5 --- /dev/null +++ b/tdeabc/plugins/sql/resourcesql.cpp @@ -0,0 +1,338 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqsqldatabase.h> +#include <tqsqlcursor.h> + +#include <kdebug.h> +#include <tdeglobal.h> +#include <klineedit.h> +#include <tdelocale.h> + +#include "resourcesql.h" +#include "resourcesqlconfig.h" + +using namespace TDEABC; + +extern "C" +{ + KDE_EXPORT void *init_tdeabc_sql() + { + return new KRES::PluginFactory<ResourceSql,ResourceSqlConfig>(); + } +} + +ResourceSql::ResourceSql( AddressBook *ab, const TDEConfig *config ) + : Resource( ab ), mDb( 0 ) +{ + TQString user, password, db, host; + + user = config->readEntry( "SqlUser" ); + password = cryptStr( config->readEntry( "SqlPassword " ) ); + db = config->readEntry( "SqlName" ); + host = config->readEntry( "SqlHost" ); + + init( user, password, db, host ); +} + +ResourceSql::ResourceSql( AddressBook *ab, const TQString &user, + const TQString &password, const TQString &db, const TQString &host ) + : Resource( ab ), mDb( 0 ) +{ + init( user, password, db, host ); +} + +void ResourceSql::init( const TQString &user, const TQString &password, + const TQString &db, const TQString &host ) +{ + mUser = user; + mPassword = password; + mDbName = db; + mHost = host; +} + +Ticket *ResourceSql::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +bool ResourceSql::open() +{ + TQStringList drivers = TQSqlDatabase::drivers(); + for ( TQStringList::Iterator it = drivers.begin(); it != drivers.end(); ++it ) { + kdDebug(5700) << "Driver: " << (*it) << endl; + } + + mDb = TQSqlDatabase::addDatabase( "QMYSQL3" ); + + if ( !mDb ) { + kdDebug(5700) << "Error. Unable to connect to database." << endl; + return false; + } + + mDb->setDatabaseName( mDbName ); + mDb->setUserName( mUser ); + mDb->setPassword( mPassword ); + mDb->setHostName( mHost ); + + if ( !mDb->open() ) { + kdDebug(5700) << "Error. Unable to open database '" << mDbName << "'." << endl; + return false; + } + + return true; +} + +void ResourceSql::close() +{ + mDb->close(); +} + +bool ResourceSql::load() +{ + TQSqlQuery query( "select addressId, name, familyName, givenName, " + "additionalName, prefix, suffix, nickname, birthday, " + "mailer, timezone, geo_latitude, geo_longitude, title, " + "role, organization, note, productId, revision, " + "sortString, url from kaddressbook_main_" + mUser ); + + while ( query.next() ) { + TQString addrId = query.value(0).toString(); + + Addressee addr; + addr.setResource( this ); + addr.setUid( addrId ); + addr.setName( query.value(1).toString() ); + addr.setFamilyName( query.value(2).toString() ); + addr.setGivenName( query.value(3).toString() ); + addr.setAdditionalName( query.value(4).toString() ); + addr.setPrefix( query.value(5).toString() ); + addr.setSuffix( query.value(6).toString() ); + addr.setNickName( query.value(7).toString() ); + addr.setBirthday( query.value(8).toDateTime() ); + addr.setMailer( query.value(9).toString() ); + addr.setTimeZone( TimeZone( query.value(10).toInt() ) ); + addr.setGeo( Geo( query.value(11).toDouble(), query.value(12).toDouble() ) ); + addr.setTitle( query.value(13).toString() ); + addr.setRole( query.value(14).toString() ); + addr.setOrganization( query.value(15).toString() ); + addr.setNote( query.value(16).toString() ); + addr.setProductId( query.value(17).toString() ); + addr.setRevision( query.value(18).toDateTime() ); + addr.setSortString( query.value(19).toString() ); + addr.setUrl( query.value(20).toString() ); + + // emails + { + TQSqlQuery emailsQuery( "select email, preferred from kaddressbook_emails " + "where addressId = '" + addrId + "'" ); + while ( emailsQuery.next() ) + addr.insertEmail( emailsQuery.value( 0 ).toString(), + emailsQuery.value( 1 ).toInt() ); + } + + // phones + { + TQSqlQuery phonesQuery( "select number, type from kaddressbook_phones " + "where addressId = '" + addrId + "'" ); + while ( phonesQuery.next() ) + addr.insertPhoneNumber( PhoneNumber( phonesQuery.value( 0 ).toString(), + phonesQuery.value( 1 ).toInt() ) ); + } + + // addresses + { + TQSqlQuery addressesQuery( "select postOfficeBox, extended, street, " + "locality, region, postalCode, country, label, type " + "from kaddressbook_addresses where addressId = '" + addrId + "'" ); + while ( addressesQuery.next() ) { + Address a; + a.setPostOfficeBox( addressesQuery.value(0).toString() ); + a.setExtended( addressesQuery.value(1).toString() ); + a.setStreet( addressesQuery.value(2).toString() ); + a.setLocality( addressesQuery.value(3).toString() ); + a.setRegion( addressesQuery.value(4).toString() ); + a.setPostalCode( addressesQuery.value(5).toString() ); + a.setCountry( addressesQuery.value(6).toString() ); + a.setLabel( addressesQuery.value(7).toString() ); + a.setType( addressesQuery.value(8).toInt() ); + + addr.insertAddress( a ); + } + } + + // categories + { + TQSqlQuery categoriesQuery( "select category from kaddressbook_categories " + "where addressId = '" + addrId + "'" ); + while ( categoriesQuery.next() ) + addr.insertCategory( categoriesQuery.value( 0 ).toString() ); + } + + // customs + { + TQSqlQuery customsQuery( "select app, name, value from kaddressbook_customs " + "where addressId = '" + addrId + "'" ); + while ( customsQuery.next() ) + addr.insertCustom( customsQuery.value( 0 ).toString(), + customsQuery.value( 1 ).toString(), + customsQuery.value( 2 ).toString()); + } + + addressBook()->insertAddressee( addr ); + } + + return true; +} + +bool ResourceSql::save( Ticket * ) +{ + // we have to delete all entries for this user and reinsert them + TQSqlQuery query( "select addressId from kaddressbook_main_" + mUser ); + + while ( query.next() ) { + TQString addrId = query.value( 0 ).toString(); + TQSqlQuery q; + + q.exec( "DELETE FROM kaddressbook_emails WHERE addressId = '" + addrId + "'" ); + q.exec( "DELETE FROM kaddressbook_phones WHERE addressId = '" + addrId + "'" ); + q.exec( "DELETE FROM kaddressbook_addresses WHERE addressId = '" + addrId + "'" ); + q.exec( "DELETE FROM kaddressbook_categories WHERE addressId = '" + addrId + "'" ); + q.exec( "DELETE FROM kaddressbook_customs WHERE addressId = '" + addrId + "'" ); + + q.exec( "DELETE FROM kaddressbook_main_" + mUser + " WHERE addressId = '" + addrId + "'" ); + } + + // let's start... + AddressBook::Iterator it; + for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { + if ( (*it).resource() != this && (*it).resource() != 0 ) // save only my and new entries + continue; + + TQString uid = (*it).uid(); + + query.exec( "INSERT INTO kaddressbook_main_" + mUser + " VALUES ('" + + (*it).uid() + "','" + + (*it).name() + "','" + + (*it).familyName() + "','" + + (*it).givenName() + "','" + + (*it).additionalName() + "','" + + (*it).prefix() + "','" + + (*it).suffix() + "','" + + (*it).nickName() + "','" + + (*it).birthday().toString( Qt::ISODate ) + "','" + + (*it).mailer() + "','" + + TQString::number( (*it).timeZone().offset() ) + "','" + + TQString::number( (*it).geo().latitude() ) + "','" + + TQString::number( (*it).geo().longitude() ) + "','" + + (*it).title() + "','" + + (*it).role() + "','" + + (*it).organization() + "','" + + (*it).note() + "','" + + (*it).productId() + "','" + + (*it).revision().toString( Qt::ISODate ) + "','" + + (*it).sortString() + "','" + + (*it).url().url() + "')" + ); + + // emails + { + TQStringList emails = (*it).emails(); + TQStringList::ConstIterator it; + bool preferred = true; + for( it = emails.begin(); it != emails.end(); ++it ) { + query.exec("INSERT INTO kaddressbook_emails VALUES ('" + + uid + "','" + + (*it) + "','" + + TQString::number(preferred) + "')"); + preferred = false; + } + } + + // phonenumbers + { + PhoneNumber::List phoneNumberList = (*it).phoneNumbers(); + PhoneNumber::List::ConstIterator it; + for( it = phoneNumberList.begin(); it != phoneNumberList.end(); ++it ) { + query.exec("INSERT INTO kaddressbook_phones VALUES ('" + + uid + "','" + + (*it).number() + "','" + + TQString::number( (*it).type() ) + "')"); + } + } + + // postal addresses + { + Address::List addressList = (*it).addresses(); + Address::List::ConstIterator it; + for( it = addressList.begin(); it != addressList.end(); ++it ) { + query.exec("INSERT INTO kaddressbook_addresses VALUES ('" + + uid + "','" + + (*it).postOfficeBox() + "','" + + (*it).extended() + "','" + + (*it).street() + "','" + + (*it).locality() + "','" + + (*it).region() + "','" + + (*it).postalCode() + "','" + + (*it).country() + "','" + + (*it).label() + "','" + + TQString::number( (*it).type() ) + "')"); + } + } + + // categories + { + TQStringList categories = (*it).categories(); + TQStringList::ConstIterator it; + for( it = categories.begin(); it != categories.end(); ++it ) + query.exec("INSERT INTO kaddressbook_categories VALUES ('" + + uid + "','" + + (*it) + "')"); + } + + // customs + { + TQStringList list = (*it).customs(); + TQStringList::ConstIterator it; + for( it = list.begin(); it != list.end(); ++it ) { + int dashPos = (*it).find( '-' ); + int colonPos = (*it).find( ':' ); + TQString app = (*it).left( dashPos ); + TQString name = (*it).mid( dashPos + 1, colonPos - dashPos - 1 ); + TQString value = (*it).right( (*it).length() - colonPos - 1 ); + + query.exec("INSERT INTO kaddressbook_categories VALUES ('" + + uid + "','" + app + "','" + name + "','" + value + "')"); + } + } + } + + return true; +} + +TQString ResourceSql::identifier() const +{ + return mHost + "_" + mDbName; +} diff --git a/tdeabc/plugins/sql/resourcesql.h b/tdeabc/plugins/sql/resourcesql.h new file mode 100644 index 000000000..b7c82e6b0 --- /dev/null +++ b/tdeabc/plugins/sql/resourcesql.h @@ -0,0 +1,63 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCESQL_H +#define KABC_RESOURCESQL_H + +#include <tdeconfig.h> + +#include "addressbook.h" +#include "resource.h" + +class TQSqlDatabase; + +namespace TDEABC { + +class ResourceSql : public Resource +{ +public: + ResourceSql( AddressBook *ab, const TQString &user, const TQString &password, + const TQString &db, const TQString &host ); + ResourceSql( AddressBook *ab, const TDEConfig * ); + + bool open(); + void close(); + + Ticket *requestSaveTicket(); + + bool load(); + bool save( Ticket * ticket ); + + TQString identifier() const; + +private: + void init(const TQString &user, const TQString &password, + const TQString &db, const TQString &host ); + + TQString mUser; + TQString mPassword; + TQString mDbName; + TQString mHost; + + TQSqlDatabase *mDb; +}; + +} +#endif diff --git a/tdeabc/plugins/sql/resourcesqlconfig.cpp b/tdeabc/plugins/sql/resourcesqlconfig.cpp new file mode 100644 index 000000000..34a678aca --- /dev/null +++ b/tdeabc/plugins/sql/resourcesqlconfig.cpp @@ -0,0 +1,95 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqspinbox.h> +#include <tqvbox.h> + +#include <klineedit.h> +#include <tdelocale.h> + +#include "resource.h" +#include "resourcesqlconfig.h" + +using namespace TDEABC; + +ResourceSqlConfig::ResourceSqlConfig( TQWidget* parent, const char* name ) + : ResourceConfigWidget( parent, name ) +{ + resize( 290, 170 ); + + TQGridLayout *mainLayout = new TQGridLayout( this, 4, 2 ); + + TQLabel *label = new TQLabel( i18n( "Username:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mUser, 0, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( KLineEdit::Password ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mPassword, 1, 1 ); + + label = new TQLabel( i18n( "Host:" ), this ); + mHost = new KLineEdit( this ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mHost, 2, 1 ); + + label = new TQLabel( i18n( "Port:" ), this ); + TQVBox *box = new TQVBox(this); + mPort = new TQSpinBox(0, 65535, 1, box ); + mPort->setSizePolicy(TQSizePolicy(TQSizePolicy::Maximum, TQSizePolicy::Preferred)); + mPort->setValue(389); + new TQWidget(box, "dummy"); + + mainLayout->addWidget( label, 3, 0 ); + mainLayout->addWidget( box, 3, 1 ); + + label = new TQLabel( i18n( "Database:" ), this ); + mDbName = new KLineEdit( this ); + + mainLayout->addWidget( label, 4, 0 ); + mainLayout->addWidget( mDbName, 4, 1 ); +} + +void ResourceSqlConfig::loadSettings( TDEConfig *config ) +{ + mUser->setText( config->readEntry( "SqlUser" ) ); + mPassword->setText( TDEABC::Resource::cryptStr( config->readEntry( "SqlPassword" ) ) ); + mDbName->setText( config->readEntry( "SqlName" ) ); + mHost->setText( config->readEntry( "SqlHost" ) ); + mPort->setValue( config->readNumEntry( "SqlPort" ) ); +} + +void ResourceSqlConfig::saveSettings( TDEConfig *config ) +{ + config->writeEntry( "SqlUser", mUser->text() ); + config->writeEntry( "SqlPassword", TDEABC::Resource::cryptStr( mPassword->text() ) ); + config->writeEntry( "SqlName", mDbName->text() ); + config->writeEntry( "SqlHost", mHost->text() ); + config->writeEntry( "SqlPort", mPort->value() ); +} + +#include "resourcesqlconfig.moc" diff --git a/tdeabc/plugins/sql/resourcesqlconfig.h b/tdeabc/plugins/sql/resourcesqlconfig.h new file mode 100644 index 000000000..f9b2c0a61 --- /dev/null +++ b/tdeabc/plugins/sql/resourcesqlconfig.h @@ -0,0 +1,51 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCESQLCONFIG_H +#define RESOURCESQLCONFIG_H + +#include "resourceconfigwidget.h" + +class KLineEdit; +class TQSpinBox; + +namespace TDEABC { + +class ResourceSqlConfig : public ResourceConfigWidget +{ + Q_OBJECT + +public: + ResourceSqlConfig( TQWidget* parent = 0, const char* name = 0 ); + +public slots: + void loadSettings( TDEConfig *config ); + void saveSettings( TDEConfig *config ); + +private: + KLineEdit* mUser; + KLineEdit* mPassword; + KLineEdit* mDbName; + KLineEdit* mHost; + TQSpinBox* mPort; +}; + +} +#endif diff --git a/tdeabc/plugins/sql/sql.desktop b/tdeabc/plugins/sql/sql.desktop new file mode 100644 index 000000000..6881ebebe --- /dev/null +++ b/tdeabc/plugins/sql/sql.desktop @@ -0,0 +1,10 @@ +[Misc] +Name=SQL +Name[bn]=এস-কিউ-এল (SQL) +Name[hi]=एसक्यूएल (SQL) +Name[ss]=I-SQL +Name[te]=ఏస్క్యుఎల్ + +[Plugin] +Type=sql +X-TDE-Library=tdeabc_sql diff --git a/tdeabc/resource.cpp b/tdeabc/resource.cpp new file mode 100644 index 000000000..4128db82c --- /dev/null +++ b/tdeabc/resource.cpp @@ -0,0 +1,351 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <tdelocale.h> + +#include "resource.h" + +using namespace TDEABC; + +Ticket::Ticket( Resource *resource ) + : mResource( resource ) +{ +} + +Ticket::~Ticket() +{ +/* FIXME: avoid cycle deletion + if ( mResource ) + mResource->releaseSaveTicket( this ); +*/ +} + +Resource *Ticket::resource() +{ + return mResource; +} + +struct Resource::Iterator::IteratorData +{ + Addressee::Map::Iterator mIt; +}; + +struct Resource::ConstIterator::ConstIteratorData +{ + Addressee::Map::ConstIterator mIt; +}; + +Resource::Iterator::Iterator() +{ + d = new IteratorData; +} + +Resource::Iterator::Iterator( const Resource::Iterator &i ) +{ + d = new IteratorData; + d->mIt = i.d->mIt; +} + +Resource::Iterator &Resource::Iterator::operator=( const Resource::Iterator &i ) +{ + if ( this == &i ) + return *this; + delete d; + + d = new IteratorData; + d->mIt = i.d->mIt; + return *this; +} + +Resource::Iterator::~Iterator() +{ + delete d; +} + +const Addressee &Resource::Iterator::operator*() const +{ + return d->mIt.data(); +} + +Addressee &Resource::Iterator::operator*() +{ + return d->mIt.data(); +} + +Resource::Iterator &Resource::Iterator::operator++() +{ + (d->mIt)++; + return *this; +} + +Resource::Iterator &Resource::Iterator::operator++( int ) +{ + (d->mIt)++; + return *this; +} + +Resource::Iterator &Resource::Iterator::operator--() +{ + (d->mIt)--; + return *this; +} + +Resource::Iterator &Resource::Iterator::operator--( int ) +{ + (d->mIt)--; + return *this; +} + +bool Resource::Iterator::operator==( const Iterator &it ) +{ + return ( d->mIt == it.d->mIt ); +} + +bool Resource::Iterator::operator!=( const Iterator &it ) +{ + return ( d->mIt != it.d->mIt ); +} + +Resource::ConstIterator::ConstIterator() +{ + d = new ConstIteratorData; +} + +Resource::ConstIterator::ConstIterator( const Resource::ConstIterator &i ) +{ + d = new ConstIteratorData; + d->mIt = i.d->mIt; +} + +Resource::ConstIterator::ConstIterator( const Resource::Iterator &i ) +{ + d = new ConstIteratorData; + d->mIt = i.d->mIt; +} + +Resource::ConstIterator &Resource::ConstIterator::operator=( const Resource::ConstIterator &i ) +{ + if ( this == &i ) + return *this; + delete d; + + d = new ConstIteratorData; + d->mIt = i.d->mIt; + return *this; +} + +Resource::ConstIterator::~ConstIterator() +{ + delete d; +} + +const Addressee &Resource::ConstIterator::operator*() const +{ + return *(d->mIt); +} + +Resource::ConstIterator &Resource::ConstIterator::operator++() +{ + (d->mIt)++; + return *this; +} + +Resource::ConstIterator &Resource::ConstIterator::operator++( int ) +{ + (d->mIt)++; + return *this; +} + +Resource::ConstIterator &Resource::ConstIterator::operator--() +{ + (d->mIt)--; + return *this; +} + +Resource::ConstIterator &Resource::ConstIterator::operator--( int ) +{ + (d->mIt)--; + return *this; +} + +bool Resource::ConstIterator::operator==( const ConstIterator &it ) +{ + return ( d->mIt == it.d->mIt ); +} + +bool Resource::ConstIterator::operator!=( const ConstIterator &it ) +{ + return ( d->mIt != it.d->mIt ); +} + + +Resource::Resource( const TDEConfig *config ) + : KRES::Resource( config ), mAddressBook( 0 ) +{ +} + +Resource::~Resource() +{ +} + +Resource::Iterator Resource::begin() +{ + Iterator it; + it.d->mIt = mAddrMap.begin(); + + return it; +} + +Resource::ConstIterator Resource::begin() const +{ + ConstIterator it; + it.d->mIt = mAddrMap.constBegin(); + return it; +} + +Resource::Iterator Resource::end() +{ + Iterator it; + it.d->mIt = mAddrMap.end(); + + return it; +} + +Resource::ConstIterator Resource::end() const +{ + ConstIterator it; + it.d->mIt = mAddrMap.constEnd(); + return it; +} + +void Resource::writeConfig( TDEConfig *config ) +{ + KRES::Resource::writeConfig( config ); +} + +void Resource::setAddressBook( AddressBook *ab ) +{ + mAddressBook = ab; +} + +AddressBook *Resource::addressBook() +{ + return mAddressBook; +} + +Ticket *Resource::createTicket( Resource *resource ) +{ + return new Ticket( resource ); +} + +void Resource::insertAddressee( const Addressee &addr ) +{ + mAddrMap.insert( addr.uid(), addr ); +} + +void Resource::removeAddressee( const Addressee &addr ) +{ + mAddrMap.erase( addr.uid() ); +} + +Addressee Resource::findByUid( const TQString &uid ) +{ + Addressee::Map::ConstIterator it = mAddrMap.find( uid ); + + if ( it != mAddrMap.end() ) + return it.data(); + + return Addressee(); +} + +Addressee::List Resource::findByName( const TQString &name ) +{ + Addressee::List results; + + ConstIterator it; + for ( it = begin(); it != end(); ++it ) { + if ( name == (*it).name() ) + results.append( *it ); + } + + return results; +} + +Addressee::List Resource::findByEmail( const TQString &email ) +{ + Addressee::List results; + const TQString lowerEmail = email.lower(); + + ConstIterator it; + for ( it = begin(); it != end(); ++it ) { + const TQStringList mailList = (*it).emails(); + for ( TQStringList::ConstIterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { + if ( lowerEmail == (*ite).lower() ) + results.append( *it ); + } + } + + return results; +} + +Addressee::List Resource::findByCategory( const TQString &category ) +{ + Addressee::List results; + + ConstIterator it; + for ( it = begin(); it != end(); ++it ) { + if ( (*it).hasCategory( category) ) { + results.append( *it ); + } + } + + return results; +} + +void Resource::clear() +{ + mAddrMap.clear(); +} + +bool Resource::asyncLoad() +{ + bool ok = load(); + if ( !ok ) + emit loadingError( this, i18n( "Loading resource '%1' failed!" ) + .arg( resourceName() ) ); + else + emit loadingFinished( this ); + + return ok; +} + +bool Resource::asyncSave( Ticket *ticket ) { + bool ok = save( ticket ); + if ( !ok ) + emit savingError( this, i18n( "Saving resource '%1' failed!" ) + .arg( resourceName() ) ); + else + emit savingFinished( this ); + + return ok; +} + +#include "resource.moc" diff --git a/tdeabc/resource.h b/tdeabc/resource.h new file mode 100644 index 000000000..620d9ec47 --- /dev/null +++ b/tdeabc/resource.h @@ -0,0 +1,319 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCE_H +#define KABC_RESOURCE_H + +#include <tderesources/resource.h> + +#include "addressbook.h" +#include "plugin.h" + +namespace TDEABC { + +/** + * @short Helper class for handling coordinated save of address books. + * + * This class is used as helper class for saving address book. + * @see requestSaveTicket(), save(). + */ +class KABC_EXPORT Ticket +{ + friend class Resource; + + public: + ~Ticket(); + + Resource *resource(); + + private: + Ticket( Resource *resource ); + + Resource *mResource; +}; + +/** + * @internal + */ +class KABC_EXPORT Resource : public KRES::Resource +{ + Q_OBJECT + + public: + + /** + @short Resource Iterator + + This class provides an iterator for resource entries. + By default it points to a TQValueList<Addressee>::Iterator, + but you can reimplement this class to fit your own needs. + */ + class KABC_EXPORT Iterator + { + public: + Iterator(); + Iterator( const Iterator & ); + virtual ~Iterator(); + + virtual Iterator &operator=( const Iterator & ); + virtual const Addressee &operator*() const; + virtual Addressee &operator*(); + virtual Iterator &operator++(); + virtual Iterator &operator++( int ); + virtual Iterator &operator--(); + virtual Iterator &operator--( int ); + virtual bool operator==( const Iterator &it ); + virtual bool operator!=( const Iterator &it ); + + struct IteratorData; + IteratorData *d; + }; + + /** + @short Resource Const Iterator + + This class provides a const iterator for resource entries. + */ + class KABC_EXPORT ConstIterator + { + public: + ConstIterator(); + ConstIterator( const ConstIterator & ); + ConstIterator( const Iterator & ); + virtual ~ConstIterator(); + + virtual ConstIterator &operator=( const ConstIterator & ); + virtual const Addressee &operator*() const ; + virtual ConstIterator &operator++(); + virtual ConstIterator &operator++( int ); + virtual ConstIterator &operator--(); + virtual ConstIterator &operator--( int ); + virtual bool operator==( const ConstIterator &it ); + virtual bool operator!=( const ConstIterator &it ); + + struct ConstIteratorData; + ConstIteratorData *d; + }; + + /** + Constructor. + + @param config The config object where the derived classes can + read out their settings. + */ + Resource( const TDEConfig *config ); + + /** + Destructor. + */ + virtual ~Resource(); + + /** + Returns an iterator pointing to the first addressee in the resource. + This iterator equals end() if the resource is empty. + */ + virtual ConstIterator begin() const; + + /** + This is an overloaded member function, provided for convenience. It + behaves essentially like the above function. + */ + virtual Iterator begin(); + + /** + Returns an iterator pointing to the last addressee in the resource. + This iterator equals begin() if the resource is empty. + */ + virtual ConstIterator end() const; + + /** + This is an overloaded member function, provided for convenience. It + behaves essentially like the above function. + */ + virtual Iterator end(); + + /** + Returns a pointer to the addressbook. + */ + AddressBook *addressBook(); + + /** + Writes the resource specific config to file. + */ + virtual void writeConfig( TDEConfig *config ); + + /** + Request a ticket, you have to pass through save() to + allow locking. The resource has to create its locks + in this function. + */ + virtual Ticket *requestSaveTicket() = 0; + + /** + Releases the ticket previousely requested with requestSaveTicket(). + The resource has to remove its locks in this function. + This function is also responsible for deleting the ticket. + */ + virtual void releaseSaveTicket( Ticket* ) = 0; + + /** + Loads all addressees synchronously. + + @returns Whether the loading was successfully. + */ + virtual bool load() = 0; + + /** + Loads all addressees asyncronously. You have to make sure that either + the loadingFinished() or loadingError() signal is emitted from within + this function. + + The default implementation simply calls the synchronous load. + + @return Whether the synchronous part of loading was successfully. + */ + virtual bool asyncLoad(); + + /** + Insert an addressee into the resource. + */ + virtual void insertAddressee( const Addressee& ); + + /** + Removes an addressee from resource. + */ + virtual void removeAddressee( const Addressee& addr ); + + /** + Saves all addressees synchronously. + + @param ticket You have to release the ticket later with + releaseSaveTicket() explicitely. + @return Whether the saving was successfully. + */ + virtual bool save( Ticket *ticket ) = 0; + + /** + Saves all addressees asynchronously. You have to make sure that either + the savingFinished() or savingError() signal is emitted from within + this function. + + The default implementation simply calls the synchronous save. + + @param ticket You have to release the ticket later with + releaseSaveTicket() explicitely. + @return Whether the saving was successfully. + */ + virtual bool asyncSave( Ticket *ticket ); + + /** + Searches an addressee with the specified unique identifier. + + @param uid The unique identifier you are looking for. + @return The addressee with the specified unique identifier or an + empty addressee. + */ + virtual Addressee findByUid( const TQString &uid ); + + /** + Searches all addressees which match the specified name. + + @param name The name you are looking for. + @return A list of all matching addressees. + */ + virtual Addressee::List findByName( const TQString &name ); + + /** + Searches all addressees which match the specified email address. + + @param email The email address you are looking for. + @return A list of all matching addressees. + */ + virtual Addressee::List findByEmail( const TQString &email ); + + /** + Searches all addressees which belongs to the specified category. + + @param category The category you are looking for. + @return A list of all matching addressees. + */ + virtual Addressee::List findByCategory( const TQString &category ); + + /** + Removes all addressees from the resource. + */ + virtual void clear(); + + /** + @internal + + Sets the address book of the resource. + */ + void setAddressBook( AddressBook* ); + + signals: + /** + This signal is emitted when the resource has finished the loading of all + addressees from the backend to the internal cache. + + @param resource The pointer to the resource which emitted this signal. + */ + void loadingFinished( Resource *resource ); + + /** + This signal is emitted when an error occured during loading the + addressees from the backend to the internal cache. + + @param resource The pointer to the resource which emitted this signal. + @param msg A translated error message. + */ + void loadingError( Resource *resource, const TQString &msg ); + + /** + This signal is emitted when the resource has finished the saving of all + addressees from the internal cache to the backend. + + @param resource The pointer to the resource which emitted this signal. + */ + void savingFinished( Resource *resource ); + + /** + This signal is emitted when an error occured during saving the + addressees from the internal cache to the backend. + + @param resource The pointer to the resource which emitted this signal. + @param msg A translated error message. + */ + void savingError( Resource *resource, const TQString &msg ); + + protected: + Ticket *createTicket( Resource * ); + Addressee::Map mAddrMap; + + private: + AddressBook *mAddressBook; + + class ResourcePrivate; + ResourcePrivate *d; +}; + +} + +#endif diff --git a/tdeabc/resourceselectdialog.cpp b/tdeabc/resourceselectdialog.cpp new file mode 100644 index 000000000..1b9d1a40d --- /dev/null +++ b/tdeabc/resourceselectdialog.cpp @@ -0,0 +1,111 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdelocale.h> +#include <kbuttonbox.h> +#include <tdelistbox.h> +#include <kstdguiitem.h> + +#include <tqgroupbox.h> +#include <tqlayout.h> + +#include "resource.h" +#include "addressbook.h" + +#include "resourceselectdialog.h" + +using namespace TDEABC; + +ResourceSelectDialog::ResourceSelectDialog( AddressBook *ab, TQWidget *parent, const char *name ) + : KDialog( parent, name, true ) +{ + setCaption( i18n( "Resource Selection" ) ); + resize( 300, 200 ); + + TQVBoxLayout *mainLayout = new TQVBoxLayout( this ); + mainLayout->setMargin( marginHint() ); + + TQGroupBox *groupBox = new TQGroupBox( 2, Qt::Horizontal, this ); + groupBox->setTitle( i18n( "Resources" ) ); + + mResourceId = new TDEListBox( groupBox ); + + mainLayout->addWidget( groupBox ); + + mainLayout->addSpacing( 10 ); + + KButtonBox *buttonBox = new KButtonBox( this ); + + buttonBox->addStretch(); + buttonBox->addButton( KStdGuiItem::ok(), TQT_TQOBJECT(this), TQT_SLOT( accept() ) ); + buttonBox->addButton( KStdGuiItem::cancel(), TQT_TQOBJECT(this), TQT_SLOT( reject() ) ); + buttonBox->layout(); + + mainLayout->addWidget( buttonBox ); + + // setup listbox + uint counter = 0; + TQPtrList<Resource> list = ab->resources(); + for ( uint i = 0; i < list.count(); ++i ) { + Resource *resource = list.at( i ); + if ( resource && !resource->readOnly() ) { + mResourceMap.insert( counter, resource ); + mResourceId->insertItem( resource->resourceName() ); + counter++; + } + } + + mResourceId->setCurrentItem( 0 ); +} + +Resource *ResourceSelectDialog::resource() +{ + if ( mResourceId->currentItem() != -1 ) + return mResourceMap[ mResourceId->currentItem() ]; + else + return 0; +} + +Resource *ResourceSelectDialog::getResource( AddressBook *ab, TQWidget *parent ) +{ + TQPtrList<Resource> resources = ab->resources(); + if ( resources.count() == 1 ) return resources.first(); + + Resource *found = 0; + Resource *r = resources.first(); + while( r ) { + if ( !r->readOnly() ) { + if ( found ) { + found = 0; + break; + } else { + found = r; + } + } + r = resources.next(); + } + if ( found ) return found; + + ResourceSelectDialog dlg( ab, parent ); + if ( dlg.exec() == KDialog::Accepted ) return dlg.resource(); + else return 0; +} + +#include "resourceselectdialog.moc" diff --git a/tdeabc/resourceselectdialog.h b/tdeabc/resourceselectdialog.h new file mode 100644 index 000000000..5065a3c82 --- /dev/null +++ b/tdeabc/resourceselectdialog.h @@ -0,0 +1,57 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCESELECTDIALOG_H +#define KABC_RESOURCESELECTDIALOG_H + +#include <tqmap.h> + +#include <kdialog.h> +#include <kdemacros.h> + +class TDEListBox; + +namespace TDEABC { + +class AddressBook; +class Resource; + +/** + This class is @deprecated, use KRES::SelectDialog instead. + */ +class KABC_EXPORT_DEPRECATED ResourceSelectDialog : KDialog +{ + Q_OBJECT + + public: + ResourceSelectDialog( AddressBook *ab, TQWidget *parent = 0, + const char *name = 0); + Resource *resource(); + + static Resource *getResource( AddressBook *ab, TQWidget *parent = 0 ); + + private: + TDEListBox *mResourceId; + TQMap<int, Resource*> mResourceMap; +}; + +} + +#endif diff --git a/tdeabc/scripts/Makefile.am b/tdeabc/scripts/Makefile.am new file mode 100644 index 000000000..7715fba5c --- /dev/null +++ b/tdeabc/scripts/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = $(srcdir)/makeaddressee \ + $(srcdir)/addressee.src.cpp \ + $(srcdir)/addressee.src.h \ + $(srcdir)/entrylist \ + $(srcdir)/field.src.cpp + diff --git a/tdeabc/scripts/addressee.src.cpp b/tdeabc/scripts/addressee.src.cpp new file mode 100644 index 000000000..c090f7e4e --- /dev/null +++ b/tdeabc/scripts/addressee.src.cpp @@ -0,0 +1,1127 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + Copyright (c) 2003 Carsten Pfeiffer <[email protected]> + Copyright (c) 2005 Ingo Kloecker <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqregexp.h> + +#include <ksharedptr.h> +#include <kdebug.h> +#include <tdeapplication.h> +#include <tdelocale.h> + +#include "addresseehelper.h" +#include "field.h" +#include "resource.h" +#include "sortmode.h" + +#include "addressee.h" + +using namespace TDEABC; + +static bool matchBinaryPattern( int value, int pattern ); + +template <class L> +static bool listEquals( const TQValueList<L>&, const TQValueList<L>& ); +static bool emailsEquals( const TQStringList&, const TQStringList& ); + +TDEABC::SortMode *Addressee::mSortMode = 0; + +struct Addressee::AddresseeData : public TDEShared +{ + TQString uid; + TQString uri; + --VARIABLES-- + + PhoneNumber::List phoneNumbers; + Address::List addresses; + Key::List keys; + TQStringList emails; + TQStringList categories; + TQStringList custom; + + Resource *resource; + + bool empty :1; + bool changed :1; +}; + +Addressee::AddresseeData* Addressee::shared_null = 0; + +Addressee::AddresseeData* Addressee::makeSharedNull() +{ + Addressee::shared_null = new AddresseeData; + shared_null->_TDEShared_ref(); //just in case (we should add KSD) + shared_null->empty = true; + shared_null->changed = false; + shared_null->resource = 0; + return shared_null; +} + +Addressee::Addressee() +{ + mData = shared_null ? shared_null : makeSharedNull(); +} + +Addressee::~Addressee() +{ +} + +Addressee::Addressee( const Addressee &a ) +{ + mData = a.mData; +} + +Addressee &Addressee::operator=( const Addressee &a ) +{ + if ( this == &a ) + return (*this); + + mData = a.mData; + return (*this); +} + +void Addressee::detach() +{ + if ( mData.data() == shared_null ) { + mData = new AddresseeData; + mData->empty = true; + mData->changed = false; + mData->resource = 0; + mData->uid = TDEApplication::randomString( 10 ); + return; + } else if ( mData.count() == 1 ) return; + + AddresseeData data = *mData; + mData = new AddresseeData( data ); +} + +bool Addressee::operator==( const Addressee &a ) const +{ + if ( uid() != a.uid() ) { + kdDebug(5700) << "uid differs" << endl; + return false; + } + --EQUALSTEST-- + if ( ( mData->url.isValid() || a.mData->url.isValid() ) && + ( mData->url != a.mData->url ) ) { + kdDebug(5700) << "url differs" << endl; + return false; + } + if ( !listEquals( mData->phoneNumbers, a.mData->phoneNumbers ) ) { + kdDebug(5700) << "phoneNumbers differs" << endl; + return false; + } + if ( !listEquals( mData->addresses, a.mData->addresses ) ) { + kdDebug(5700) << "addresses differs" << endl; + return false; + } + if ( !listEquals( mData->keys, a.mData->keys ) ) { + kdDebug(5700) << "keys differs" << endl; + return false; + } + if ( !emailsEquals( mData->emails, a.mData->emails ) ) { + kdDebug(5700) << "emails differs" << endl; + return false; + } + if ( !listEquals( mData->categories, a.mData->categories ) ) { + kdDebug(5700) << "categories differs" << endl; + return false; + } + if ( !listEquals( mData->custom, a.mData->custom ) ) { + kdDebug(5700) << "custom differs" << endl; + return false; + } + + return true; +} + +bool Addressee::operator!=( const Addressee &a ) const +{ + return !( a == *this ); +} + +bool Addressee::isEmpty() const +{ + return mData->empty; +} + +void Addressee::setUid( const TQString &id ) +{ + if ( id == mData->uid ) return; + detach(); + mData->empty = false; + mData->uid = id; +} + +TQString Addressee::uid() const +{ + return mData->uid; +} + +TQString Addressee::uidLabel() +{ + return i18n("Unique Identifier"); +} + +void Addressee::setUri( const TQString &id ) +{ + if ( id == mData->uri ) return; + detach(); + mData->empty = false; + mData->uri = id; +} + +TQString Addressee::uri() const +{ + return mData->uri; +} + +TQString Addressee::uriLabel() +{ + return i18n("Unique Resource Identifier"); +} + +--DEFINITIONS-- + +void Addressee::setNameFromString( const TQString &s ) +{ + TQString str = s; + //remove enclosing quotes from string + if ( str.length() > 1 && s[ 0 ] == '"' && s[ s.length() - 1 ] == '"' ) + str = s.mid( 1, s.length() - 2 ); + + setFormattedName( str ); + setName( str ); + + // clear all name parts + setPrefix( TQString() ); + setGivenName( TQString() ); + setAdditionalName( TQString() ); + setFamilyName( TQString() ); + setSuffix( TQString() ); + + if ( str.isEmpty() ) + return; + + TQString spaceStr = " "; + TQString emptyStr = ""; + AddresseeHelper *helper = AddresseeHelper::self(); + + int i = str.find( ',' ); + if( i < 0 ) { + TQStringList parts = TQStringList::split( spaceStr, str ); + int leftOffset = 0; + int rightOffset = parts.count() - 1; + + TQString suffix; + while ( rightOffset >= 0 ) { + if ( helper->containsSuffix( parts[ rightOffset ] ) ) { + suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? emptyStr : spaceStr)); + rightOffset--; + } else + break; + } + setSuffix( suffix ); + + if ( rightOffset < 0 ) + return; + + TQStringList inclusionList; + for ( int n = 1; (rightOffset - n >= 0) && (n < 4); ++n ) { + if ( helper->containsPrefix( parts[ rightOffset - n ].lower() ) ) { + inclusionList.prepend( parts[ rightOffset - n ] ); + } else + break; + } + + if ( !inclusionList.isEmpty() ) { + setFamilyName( inclusionList.join( " " ) + spaceStr + parts[ rightOffset ] ); + rightOffset -= inclusionList.count(); + } else { + if ( helper->tradeAsFamilyName() ) + setFamilyName( parts[ rightOffset ] ); + else + setGivenName( parts[ rightOffset ] ); + } + + TQString prefix; + while ( leftOffset < rightOffset ) { + if ( helper->containsTitle( parts[ leftOffset ] ) ) { + prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr) + parts[ leftOffset ] ); + leftOffset++; + } else + break; + } + setPrefix( prefix ); + + if ( leftOffset < rightOffset ) { + setGivenName( parts[ leftOffset ] ); + leftOffset++; + } + + TQString additionalName; + while ( leftOffset < rightOffset ) { + additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr) + parts[ leftOffset ] ); + leftOffset++; + } + setAdditionalName( additionalName ); + } else { + TQString part1 = str.left( i ); + TQString part2 = str.mid( i + 1 ); + + TQStringList parts = TQStringList::split( spaceStr, part1 ); + int leftOffset = 0; + int rightOffset = parts.count() - 1; + + if ( parts.count() > 0 ) { + + TQString suffix; + while ( rightOffset >= 0 ) { + if ( helper->containsSuffix( parts[ rightOffset ] ) ) { + suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? emptyStr : spaceStr)); + rightOffset--; + } else + break; + } + setSuffix( suffix ); + + if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 ].lower() ) ) { + setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] ); + rightOffset--; + } else + setFamilyName( parts[ rightOffset ] ); + + TQString prefix; + while ( leftOffset < rightOffset ) { + if ( helper->containsTitle( parts[ leftOffset ] ) ) { + prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr) + parts[ leftOffset ] ); + leftOffset++; + } else + break; + } + } else { + setPrefix( "" ); + setFamilyName( "" ); + setSuffix( "" ); + } + + parts = TQStringList::split( spaceStr, part2 ); + + leftOffset = 0; + rightOffset = parts.count(); + + if ( parts.count() > 0 ) { + + TQString prefix; + while ( leftOffset < rightOffset ) { + if ( helper->containsTitle( parts[ leftOffset ] ) ) { + prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr) + parts[ leftOffset ] ); + leftOffset++; + } else + break; + } + setPrefix( prefix ); + + if ( leftOffset < rightOffset ) { + setGivenName( parts[ leftOffset ] ); + leftOffset++; + } + + TQString additionalName; + while ( leftOffset < rightOffset ) { + additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr) + parts[ leftOffset ] ); + leftOffset++; + } + setAdditionalName( additionalName ); + } else { + setGivenName( "" ); + setAdditionalName( "" ); + } + } +} + +TQString Addressee::realName() const +{ + TQString n( formattedName() ); + if ( !n.isEmpty() ) + return n; + + n = assembledName(); + if ( !n.isEmpty() ) + return n; + + n = name(); + if ( !n.isEmpty() ) + return n; + + return organization(); +} + +TQString Addressee::assembledName() const +{ + TQString name = prefix() + " " + givenName() + " " + additionalName() + " " + + familyName() + " " + suffix(); + + return name.simplifyWhiteSpace(); +} + +TQString Addressee::fullEmail( const TQString &email ) const +{ + TQString e; + if ( email.isNull() ) { + e = preferredEmail(); + } else { + e = email; + } + if ( e.isEmpty() ) return TQString(); + + TQString text; + if ( realName().isEmpty() ) + text = e; + else { + TQRegExp needQuotes( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ); + if ( realName().find( needQuotes ) != -1 ) { + TQString name = realName(); + name.replace( "\"", "\\\"" ); + text = "\"" + name + "\" <" + e + ">"; + } else + text = realName() + " <" + e + ">"; + } + + return text; +} + +void Addressee::insertEmail( const TQString &email, bool preferred ) +{ + if ( email.simplifyWhiteSpace().isEmpty() ) + return; + + detach(); + mData->empty = false; + + TQStringList::Iterator it = mData->emails.find( email ); + + if ( it != mData->emails.end() ) { + if ( !preferred || it == mData->emails.begin() ) return; + mData->emails.remove( it ); + mData->emails.prepend( email ); + } else { + if ( preferred ) { + mData->emails.prepend( email ); + } else { + mData->emails.append( email ); + } + } +} + +void Addressee::removeEmail( const TQString &email ) +{ + detach(); + + TQStringList::Iterator it = mData->emails.find( email ); + if ( it == mData->emails.end() ) return; + + mData->emails.remove( it ); +} + +TQString Addressee::preferredEmail() const +{ + if ( mData->emails.count() == 0 ) return TQString(); + else return mData->emails.first(); +} + +TQStringList Addressee::emails() const +{ + return mData->emails; +} +void Addressee::setEmails( const TQStringList& emails ) { + detach(); + + mData->emails = emails; +} +void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) +{ + detach(); + mData->empty = false; + + PhoneNumber::List::Iterator it; + for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { + if ( (*it).id() == phoneNumber.id() ) { + *it = phoneNumber; + return; + } + } + if ( !phoneNumber.number().simplifyWhiteSpace().isEmpty() ) + mData->phoneNumbers.append( phoneNumber ); +} + +void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) +{ + detach(); + + PhoneNumber::List::Iterator it; + for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { + if ( (*it).id() == phoneNumber.id() ) { + mData->phoneNumbers.remove( it ); + return; + } + } +} + +PhoneNumber Addressee::phoneNumber( int type ) const +{ + PhoneNumber phoneNumber( "", type ); + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.constBegin(); it != mData->phoneNumbers.constEnd(); ++it ) { + if ( matchBinaryPattern( (*it).type(), type ) ) { + if ( (*it).type() & PhoneNumber::Pref ) + return (*it); + else if ( phoneNumber.number().isEmpty() ) + phoneNumber = (*it); + } + } + + return phoneNumber; +} + +PhoneNumber::List Addressee::phoneNumbers() const +{ + return mData->phoneNumbers; +} + +PhoneNumber::List Addressee::phoneNumbers( int type ) const +{ + PhoneNumber::List list; + + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.constBegin(); it != mData->phoneNumbers.constEnd(); ++it ) { + if ( matchBinaryPattern( (*it).type(), type ) ) { + list.append( *it ); + } + } + return list; +} + +PhoneNumber Addressee::findPhoneNumber( const TQString &id ) const +{ + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.constBegin(); it != mData->phoneNumbers.constEnd(); ++it ) { + if ( (*it).id() == id ) { + return *it; + } + } + return PhoneNumber(); +} + +void Addressee::insertKey( const Key &key ) +{ + detach(); + mData->empty = false; + + Key::List::Iterator it; + for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { + if ( (*it).id() == key.id() ) { + *it = key; + return; + } + } + mData->keys.append( key ); +} + +void Addressee::removeKey( const Key &key ) +{ + detach(); + + Key::List::Iterator it; + for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { + if ( (*it).id() == key.id() ) { + mData->keys.remove( key ); + return; + } + } +} + +Key Addressee::key( int type, TQString customTypeString ) const +{ + Key::List::ConstIterator it; + for( it = mData->keys.constBegin(); it != mData->keys.constEnd(); ++it ) { + if ( (*it).type() == type ) { + if ( type == Key::Custom ) { + if ( customTypeString.isEmpty() ) { + return *it; + } else { + if ( (*it).customTypeString() == customTypeString ) + return (*it); + } + } else { + return *it; + } + } + } + return Key( TQString(), type ); +} + +void Addressee::setKeys( const Key::List& list ) +{ + detach(); + mData->keys = list; +} + +Key::List Addressee::keys() const +{ + return mData->keys; +} + +Key::List Addressee::keys( int type, TQString customTypeString ) const +{ + Key::List list; + + Key::List::ConstIterator it; + for( it = mData->keys.constBegin(); it != mData->keys.constEnd(); ++it ) { + if ( (*it).type() == type ) { + if ( type == Key::Custom ) { + if ( customTypeString.isEmpty() ) { + list.append( *it ); + } else { + if ( (*it).customTypeString() == customTypeString ) + list.append( *it ); + } + } else { + list.append( *it ); + } + } + } + return list; +} + +Key Addressee::findKey( const TQString &id ) const +{ + Key::List::ConstIterator it; + for( it = mData->keys.constBegin(); it != mData->keys.constEnd(); ++it ) { + if ( (*it).id() == id ) { + return *it; + } + } + return Key(); +} + +TQString Addressee::asString() const +{ + return "Smith, agent Smith..."; +} + +void Addressee::dump() const +{ + kdDebug(5700) << "Addressee {" << endl; + + kdDebug(5700) << " Uid: '" << uid() << "'" << endl; + + --DEBUG-- + + kdDebug(5700) << " Emails {" << endl; + const TQStringList e = emails(); + TQStringList::ConstIterator it; + for( it = e.begin(); it != e.end(); ++it ) { + kdDebug(5700) << " " << (*it) << endl; + } + kdDebug(5700) << " }" << endl; + + kdDebug(5700) << " PhoneNumbers {" << endl; + const PhoneNumber::List p = phoneNumbers(); + PhoneNumber::List::ConstIterator it2; + for( it2 = p.begin(); it2 != p.end(); ++it2 ) { + kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; + } + kdDebug(5700) << " }" << endl; + + const Address::List a = addresses(); + Address::List::ConstIterator it3; + for( it3 = a.begin(); it3 != a.end(); ++it3 ) { + (*it3).dump(); + } + + kdDebug(5700) << " Keys {" << endl; + const Key::List k = keys(); + Key::List::ConstIterator it4; + for( it4 = k.begin(); it4 != k.end(); ++it4 ) { + kdDebug(5700) << " Type: " << int((*it4).type()) << + " Key: " << (*it4).textData() << + " CustomString: " << (*it4).customTypeString() << endl; + } + kdDebug(5700) << " }" << endl; + + kdDebug(5700) << "}" << endl; +} + + +void Addressee::insertAddress( const Address &address ) +{ + if ( address.isEmpty() ) + return; + + detach(); + mData->empty = false; + + Address::List::Iterator it; + for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { + if ( (*it).id() == address.id() ) { + *it = address; + return; + } + } + + mData->addresses.append( address ); +} + +void Addressee::removeAddress( const Address &address ) +{ + detach(); + + Address::List::Iterator it; + for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { + if ( (*it).id() == address.id() ) { + mData->addresses.remove( it ); + return; + } + } +} + +Address Addressee::address( int type ) const +{ + Address address( type ); + Address::List::ConstIterator it; + for( it = mData->addresses.constBegin(); it != mData->addresses.constEnd(); ++it ) { + if ( matchBinaryPattern( (*it).type(), type ) ) { + if ( (*it).type() & Address::Pref ) + return (*it); + else if ( address.isEmpty() ) + address = (*it); + } + } + + return address; +} + +Address::List Addressee::addresses() const +{ + return mData->addresses; +} + +Address::List Addressee::addresses( int type ) const +{ + Address::List list; + + Address::List::ConstIterator it; + for( it = mData->addresses.constBegin(); it != mData->addresses.constEnd(); ++it ) { + if ( matchBinaryPattern( (*it).type(), type ) ) { + list.append( *it ); + } + } + + return list; +} + +Address Addressee::findAddress( const TQString &id ) const +{ + Address::List::ConstIterator it; + for( it = mData->addresses.constBegin(); it != mData->addresses.constEnd(); ++it ) { + if ( (*it).id() == id ) { + return *it; + } + } + return Address(); +} + +void Addressee::insertCategory( const TQString &c ) +{ + detach(); + mData->empty = false; + + if ( mData->categories.findIndex( c ) != -1 ) return; + + mData->categories.append( c ); +} + +void Addressee::removeCategory( const TQString &c ) +{ + detach(); + + TQStringList::Iterator it = mData->categories.find( c ); + if ( it == mData->categories.end() ) return; + + mData->categories.remove( it ); +} + +bool Addressee::hasCategory( const TQString &c ) const +{ + return ( mData->categories.findIndex( c ) != -1 ); +} + +void Addressee::setCategories( const TQStringList &c ) +{ + detach(); + mData->empty = false; + + mData->categories = c; +} + +TQStringList Addressee::categories() const +{ + return mData->categories; +} + +void Addressee::insertCustom( const TQString &app, const TQString &name, + const TQString &value ) +{ + if ( value.isEmpty() || name.isEmpty() || app.isEmpty() ) return; + + detach(); + mData->empty = false; + + TQString qualifiedName = app + "-" + name + ":"; + + TQStringList::Iterator it; + for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { + if ( (*it).startsWith( qualifiedName ) ) { + (*it) = qualifiedName + value; + return; + } + } + + mData->custom.append( qualifiedName + value ); +} + +void Addressee::removeCustom( const TQString &app, const TQString &name) +{ + detach(); + + TQString qualifiedName = app + "-" + name + ":"; + + TQStringList::Iterator it; + for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { + if ( (*it).startsWith( qualifiedName ) ) { + mData->custom.remove( it ); + return; + } + } +} + +TQString Addressee::custom( const TQString &app, const TQString &name ) const +{ + TQString qualifiedName = app + "-" + name + ":"; + TQString value; + + TQStringList::ConstIterator it; + for( it = mData->custom.constBegin(); it != mData->custom.constEnd(); ++it ) { + if ( (*it).startsWith( qualifiedName ) ) { + value = (*it).mid( (*it).find( ":" ) + 1 ); + break; + } + } + + return value; +} + +void Addressee::setCustoms( const TQStringList &l ) +{ + detach(); + mData->empty = false; + + mData->custom = l; +} + +TQStringList Addressee::customs() const +{ + return mData->custom; +} + +void Addressee::parseEmailAddress( const TQString &rawEmail, TQString &fullName, + TQString &email) +{ + // This is a simplified version of KPIM::splitAddress(). + + fullName = ""; + email = ""; + if ( rawEmail.isEmpty() ) + return; // KPIM::AddressEmpty; + + // The code works on 8-bit strings, so convert the input to UTF-8. + TQCString address = rawEmail.utf8(); + + TQCString displayName; + TQCString addrSpec; + TQCString comment; + + // The following is a primitive parser for a mailbox-list (cf. RFC 2822). + // The purpose is to extract a displayable string from the mailboxes. + // Comments in the addr-spec are not handled. No error checking is done. + + enum { TopLevel, InComment, InAngleAddress } context = TopLevel; + bool inQuotedString = false; + int commentLevel = 0; + bool stop = false; + + for ( char* p = address.data(); *p && !stop; ++p ) { + switch ( context ) { + case TopLevel : { + switch ( *p ) { + case '"' : inQuotedString = !inQuotedString; + displayName += *p; + break; + case '(' : if ( !inQuotedString ) { + context = InComment; + commentLevel = 1; + } + else + displayName += *p; + break; + case '<' : if ( !inQuotedString ) { + context = InAngleAddress; + } + else + displayName += *p; + break; + case '\\' : // quoted character + displayName += *p; + ++p; // skip the '\' + if ( *p ) + displayName += *p; + else + //return KPIM::UnexpectedEnd; + goto ABORT_PARSING; + break; + case ',' : if ( !inQuotedString ) { + //if ( allowMultipleAddresses ) + // stop = true; + //else + // return KPIM::UnexpectedComma; + goto ABORT_PARSING; + } + else + displayName += *p; + break; + default : displayName += *p; + } + break; + } + case InComment : { + switch ( *p ) { + case '(' : ++commentLevel; + comment += *p; + break; + case ')' : --commentLevel; + if ( commentLevel == 0 ) { + context = TopLevel; + comment += ' '; // separate the text of several comments + } + else + comment += *p; + break; + case '\\' : // quoted character + comment += *p; + ++p; // skip the '\' + if ( *p ) + comment += *p; + else + //return KPIM::UnexpectedEnd; + goto ABORT_PARSING; + break; + default : comment += *p; + } + break; + } + case InAngleAddress : { + switch ( *p ) { + case '"' : inQuotedString = !inQuotedString; + addrSpec += *p; + break; + case '>' : if ( !inQuotedString ) { + context = TopLevel; + } + else + addrSpec += *p; + break; + case '\\' : // quoted character + addrSpec += *p; + ++p; // skip the '\' + if ( *p ) + addrSpec += *p; + else + //return KPIM::UnexpectedEnd; + goto ABORT_PARSING; + break; + default : addrSpec += *p; + } + break; + } + } // switch ( context ) + } + +ABORT_PARSING: + displayName = displayName.stripWhiteSpace(); + comment = comment.stripWhiteSpace(); + addrSpec = addrSpec.stripWhiteSpace(); + + fullName = TQString::fromUtf8( displayName ); + email = TQString::fromUtf8( addrSpec ); + + // check for errors + if ( inQuotedString ) + return; // KPIM::UnbalancedQuote; + if ( context == InComment ) + return; // KPIM::UnbalancedParens; + if ( context == InAngleAddress ) + return; // KPIM::UnclosedAngleAddr; + + if ( addrSpec.isEmpty() ) { + if ( displayName.isEmpty() ) + return; // KPIM::NoAddressSpec; + else { + //addrSpec = displayName; + //displayName.truncate( 0 ); + // Address of the form "foo@bar" or "foo@bar (Name)". + email = fullName; + fullName = TQString::fromUtf8( comment ); + } + } + + // Check that we do not have any extra characters on the end of the + // strings + unsigned int len = fullName.length(); + if ( fullName[ 0 ] == '"' && fullName[ len - 1 ] == '"' ) + fullName = fullName.mid( 1, len - 2 ); +} + +void Addressee::setResource( Resource *resource ) +{ + detach(); + mData->resource = resource; +} + +Resource *Addressee::resource() const +{ + return mData->resource; +} + +void Addressee::setChanged( bool value ) +{ + detach(); + mData->changed = value; +} + +bool Addressee::changed() const +{ + return mData->changed; +} + +void Addressee::setSortMode( TDEABC::SortMode *mode ) +{ + mSortMode = mode; +} + +bool Addressee::operator< ( const Addressee &addr ) +{ + if ( !mSortMode ) + return false; + else + return mSortMode->lesser( *this, addr ); +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Addressee &a ) +{ + if (!a.mData) return s; + + s << a.uid(); + + --STREAMOUT-- + s << a.mData->phoneNumbers; + s << a.mData->addresses; + s << a.mData->emails; + s << a.mData->categories; + s << a.mData->custom; + s << a.mData->keys; + return s; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Addressee &a ) +{ + if (!a.mData) + return s; + + a.detach(); + + s >> a.mData->uid; + + --STREAMIN-- + s >> a.mData->phoneNumbers; + s >> a.mData->addresses; + s >> a.mData->emails; + s >> a.mData->categories; + s >> a.mData->custom; + s >> a.mData->keys; + + a.mData->empty = false; + + return s; +} + +bool matchBinaryPattern( int value, int pattern ) +{ + /** + We want to match all telephonnumbers/addresses which have the bits in the + pattern set. More are allowed. + if pattern == 0 we have a special handling, then we want only those with + exactly no bit set. + */ + if ( pattern == 0 ) + return ( value == 0 ); + else + return ( pattern == ( pattern & value ) ); +} + +template <class L> +bool listEquals( const TQValueList<L> &list, const TQValueList<L> &pattern ) +{ + if ( list.count() != pattern.count() ) + return false; + + for ( uint i = 0; i < list.count(); ++i ) + if ( pattern.find( list[ i ] ) == pattern.end() ) + return false; + + return true; +} + +bool emailsEquals( const TQStringList &list, const TQStringList &pattern ) +{ + if ( list.count() != pattern.count() ) + return false; + + if ( list.first() != pattern.first() ) + return false; + + TQStringList::ConstIterator it; + for ( it = list.begin(); it != list.end(); ++it ) + if ( pattern.find( *it ) == pattern.end() ) + return false; + + return true; +} diff --git a/tdeabc/scripts/addressee.src.h b/tdeabc/scripts/addressee.src.h new file mode 100644 index 000000000..aa449112e --- /dev/null +++ b/tdeabc/scripts/addressee.src.h @@ -0,0 +1,407 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_ADDRESSEE_H +#define KABC_ADDRESSEE_H + +#include <tqdatetime.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> + +#include <ksharedptr.h> +#include <kurl.h> + +#include "address.h" +#include "agent.h" +#include "geo.h" +#include "key.h" +#include "phonenumber.h" +#include "picture.h" +#include "secrecy.h" +#include "sound.h" +#include "timezone.h" + +namespace TDEABC { + +class Resource; +class Field; +class SortMode; + +/** + @short address book entry + + This class represents an entry in the address book. + + The data of this class is implicitly shared. You can pass this class by value. + + If you need the name of a field for presenting it to the user you should use + the functions ending in Label(). They return a translated string which can be + used as label for the corresponding field. + + About the name fields: + + givenName() is the first name and familyName() the last name. In some + countries the family name comes first, that's the reason for the + naming. formattedName() is the full name with the correct formatting. + It is used as an override, when the correct formatting can't be generated + from the other name fields automatically. + + realName() returns a fully formatted name(). It uses formattedName, if set, + otherwise it constucts the name from the name fields. As fallback, if + nothing else is set it uses name(). + + name() is the NAME type of RFC2426. It can be used as internal name for the + data enty, but shouldn't be used for displaying the data to the user. + */ +class KABC_EXPORT Addressee +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Addressee & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Addressee & ); + + public: + typedef TQValueList<Addressee> List; + typedef TQMap<TQString, Addressee> Map; + + /** + Construct an empty address book entry. + */ + Addressee(); + ~Addressee(); + + Addressee( const Addressee & ); + Addressee &operator=( const Addressee & ); + + bool operator==( const Addressee & ) const; + bool operator!=( const Addressee & ) const; + + /** + Return, if the address book entry is empty. + */ + bool isEmpty() const; + + /** + Set unique identifier. + */ + void setUid( const TQString &uid ); + /** + Return unique identifier. + */ + TQString uid() const; + /** + Return translated label for uid field. + */ + static TQString uidLabel(); + + /** + Set unique resource identifier. + */ + void setUri( const TQString &uid ); + /** + Return unique resource identifier. + */ + TQString uri() const; + /** + Return translated label for uri field. + */ + static TQString uriLabel(); + + --DECLARATIONS-- + /** + Set name fields by parsing the given string and trying to associate the + parts of the string with according fields. This function should probably + be a bit more clever. + */ + void setNameFromString( const TQString & ); + + /** + Return the name of the addressee. This is calculated from all the name + fields. + */ + TQString realName() const; + + /** + Return the name that consists of all name parts. + */ + TQString assembledName() const; + + /** + Return email address including real name. + + @param email Email address to be used to construct the full email string. + If this is TQString::null the preferred email address is used. + */ + TQString fullEmail( const TQString &email=TQString::null ) const; + + /** + Insert an email address. If the email address already exists in this + addressee it is not duplicated. + + @param email Email address + @param preferred Set to true, if this is the preferred email address of + the addressee. + */ + void insertEmail( const TQString &email, bool preferred=false ); + + /** + Remove email address. If the email address doesn't exist, nothing happens. + */ + void removeEmail( const TQString &email ); + + /** + Return preferred email address. This is the first email address or the + last one added with insertEmail() with a set preferred parameter. + */ + TQString preferredEmail() const; + + /** + Return list of all email addresses. + */ + TQStringList emails() const; + + /** + Set the emails to @p list. + The first email address gets the preferred one! + @param list The list of email addresses. + */ + void setEmails( const TQStringList& list); + + /** + Insert a phone number. If a phone number with the same id already exists + in this addressee it is not duplicated. + */ + void insertPhoneNumber( const PhoneNumber &phoneNumber ); + + /** + Remove phone number. If no phone number with the given id exists for this + addresse nothing happens. + */ + void removePhoneNumber( const PhoneNumber &phoneNumber ); + + /** + Return phone number, which matches the given type. + */ + PhoneNumber phoneNumber( int type ) const; + + /** + Return list of all phone numbers. + */ + PhoneNumber::List phoneNumbers() const; + + /** + Return list of phone numbers with a special type. + */ + PhoneNumber::List phoneNumbers( int type ) const; + + /** + Return phone number with the given id. + */ + PhoneNumber findPhoneNumber( const TQString &id ) const; + + /** + Insert a key. If a key with the same id already exists + in this addressee it is not duplicated. + */ + void insertKey( const Key &key ); + + /** + Remove a key. If no key with the given id exists for this + addresse nothing happens. + */ + void removeKey( const Key &key ); + + /** + Return key, which matches the given type. + If @p type == Key::Custom you can specify a string + that should match. If you leave the string empty, the first + key with a custom value is returned. + */ + Key key( int type, TQString customTypeString = TQString::null ) const; + + /** + Return list of all keys. + */ + Key::List keys() const; + + /** + Set the list of keys + @param keys The keys to be set. + */ + void setKeys( const Key::List& keys); + + /** + Return list of keys with a special type. + If @p type == Key::Custom you can specify a string + that should match. If you leave the string empty, all custom + keys will be returned. + */ + Key::List keys( int type, TQString customTypeString = TQString::null ) const; + + /** + Return key with the given id. + */ + Key findKey( const TQString &id ) const; + + /** + Insert an address. If an address with the same id already exists + in this addressee it is not duplicated. + */ + void insertAddress( const Address &address ); + + /** + Remove address. If no address with the given id exists for this + addresse nothing happens. + */ + void removeAddress( const Address &address ); + + /** + Return address, which matches the given type. + */ + Address address( int type ) const; + + /** + Return list of all addresses. + */ + Address::List addresses() const; + + /** + Return list of addresses with a special type. + */ + Address::List addresses( int type ) const; + + /** + Return address with the given id. + */ + Address findAddress( const TQString &id ) const; + + /** + Insert category. If the category already exists it is not duplicated. + */ + void insertCategory( const TQString & ); + + /** + Remove category. + */ + void removeCategory( const TQString & ); + + /** + Return, if addressee has the given category. + */ + bool hasCategory( const TQString & ) const; + + /** + Set categories to given value. + */ + void setCategories( const TQStringList & ); + + /** + Return list of all set categories. + */ + TQStringList categories() const; + + /** + Insert custom entry. The entry is identified by the name of the inserting + application and a unique name. If an entry with the given app and name + already exists its value is replaced with the new given value. + + An empty value isn't allowed (nothing happens if this is called with + any of the three arguments being empty) + */ + void insertCustom( const TQString &app, const TQString &name, + const TQString &value ); + + /** + Remove custom entry. + */ + void removeCustom( const TQString &app, const TQString &name ); + + /** + Return value of custom entry, identified by app and entry name. + */ + TQString custom( const TQString &app, const TQString &name ) const; + + /** + Set all custom entries. + */ + void setCustoms( const TQStringList & ); + + /** + Return list of all custom entries. + */ + TQStringList customs() const; + + /** + Parse full email address. The result is given back in fullName and email. + */ + static void parseEmailAddress( const TQString &rawEmail, TQString &fullName, + TQString &email ); + + /** + Debug output. + */ + void dump() const; + + /** + Returns string representation of the addressee. + */ + TQString asString() const; + + /** + Set resource where the addressee is from. + */ + void setResource( Resource *resource ); + + /** + Return pointer to resource. + */ + Resource *resource() const; + + /** + Mark addressee as changed. + */ + void setChanged( bool value ); + + /** + Return whether the addressee is changed. + */ + bool changed() const; + + static void setSortMode( TDEABC::SortMode *mode ); + + bool operator< ( const Addressee &addr ); + + private: + void detach(); + + struct AddresseeData; + mutable TDESharedPtr<AddresseeData> mData; + + private: + static AddresseeData* shared_null; + static AddresseeData* makeSharedNull(); + static TDEABC::SortMode *mSortMode; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Addressee & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Addressee & ); + +} + +#endif diff --git a/tdeabc/scripts/createisomap.pl b/tdeabc/scripts/createisomap.pl new file mode 100755 index 000000000..897cd4896 --- /dev/null +++ b/tdeabc/scripts/createisomap.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl +# +# Create a translation table countryname->iso-code from the entry.desktop +# files in tdebase/l10n/*/ +# +# USAGE EXAMPLE: +# ./createisomap.pl $TDEDIR/share/locale/l10n > countrytransl.map +# +# Don't laugh at me. I put this together with an old perl book, perl +# being a language I've never used before. + +@entries = <$ARGV[0]/*/entry.desktop>; +chomp @entries; +foreach $entry (@entries) { + local ( $entryiso, @entryfile, @mappings ); + # print "--> $entry\n"; + $entryiso = $entry; + $entryiso =~ s/$ARGV[0]\///; + $entryiso =~ s/\/entry\.desktop//; + # print " $entryiso\n"; + open (IN, $entry); + @entryfile = <IN>; + close IN; + chomp @entryfile; + foreach $entryfileline (@entryfile) { + if ( $entryfileline =~ /^Name.*=(.*)$/ ) { + # push (@mappings, $1 . "\t" . $entryiso ); + print "$1\t$entryiso\n"; + } + } +} + +# add some convenience entries which aren't part of the entry.desktop files + +print "Czech Republic\tcz\n"; diff --git a/tdeabc/scripts/entrylist b/tdeabc/scripts/entrylist new file mode 100644 index 000000000..87c342a06 --- /dev/null +++ b/tdeabc/scripts/entrylist @@ -0,0 +1,82 @@ +# This file describes the fields of an address book entry. +# +# The following comma-separated fields are used: +# +# Control: A generates accessor functions. +# L generates a static function for returning a tranlsated label +# F generates a Field id and object for generic field handling +# E generate an equality test in Addressee::operator==(). +# Field Name : A descriptive name which is shown to the user. +# Comment : A comment helping translators to understand the field name +# Type : C++ type of field. +# Identifier : A string used in code as variable name etc. +# Field Category : Categories the field belongs to (see Field::FieldCategory). +# Output function: Function used to convert type to string for debug output (optional) + +ALE,name,,TQString,name + +ALFE,formatted name,,TQString,formattedName,Frequent + +ALFE,family name,,TQString,familyName,Frequent +ALFE,given name,,TQString,givenName,Frequent +ALFE,additional names,,TQString,additionalName +ALFE,honorific prefixes,,TQString,prefix +ALFE,honorific suffixes,,TQString,suffix + +ALFE,nick name,,TQString,nickName,Personal + +ALFE,birthday,,TQDateTime,birthday,Personal,.toString() + +#Address address +LF,home address street,,TQString,homeAddressStreet,Address|Personal +LF,home address city,,TQString,homeAddressLocality,Address|Personal +LF,home address state,,TQString,homeAddressRegion,Address|Personal +LF,home address zip code,,TQString,homeAddressPostalCode,Address|Personal +LF,home address country,,TQString,homeAddressCountry,Address|Personal +LF,home address label,,TQString,homeAddressLabel,Address|Personal + +LF,business address street,,TQString,businessAddressStreet,Address|Organization +LF,business address city,,TQString,businessAddressLocality,Address|Organization +LF,business address state,,TQString,businessAddressRegion,Address|Organization +LF,business address zip code,,TQString,businessAddressPostalCode,Address|Organization +LF,business address country,,TQString,businessAddressCountry,Address|Organization +LF,business address label,,TQString,businessAddressLabel,Address|Organization + +#phoneNumbers +LF,home phone,,TQString,homePhone,Personal|Frequent +LF,business phone,,TQString,businessPhone,Organization|Frequent +LF,mobile phone,,TQString,mobilePhone,Frequent +LF,home fax,,TQString,homeFax +LF,business fax,,TQString,businessFax +LF,car phone,,TQString,carPhone +LF,ISDN,,TQString,isdn +LF,pager,,TQString,pager + +#emails +LF,email address,,TQString,email,Email|Frequent + +ALFE,mail client,,TQString,mailer,Email + +ALE,time zone,,TimeZone,timeZone,,.asString() +ALE,geographic position,,Geo,geo,,.asString() + +ALFE,title,person,TQString,title,Organization +ALFE,role,person in organization,TQString,role,Organization +ALFE,organization,,TQString,organization,Organization +ALFE,department,,TQString,department,Organization + +ALFE,note,,TQString,note + +ALE,product identifier,,TQString,productId +ALE,revision date,,TQDateTime,revision,,.toString() + +ALE,sort string,,TQString,sortString + +ALF,homepage,,KURL,url,,.url() + +ALE,security class,,Secrecy,secrecy,,.asString() + +ALE,logo,,Picture,logo,,.asString() +ALE,photo,,Picture,photo,,.asString() +ALE,sound,,Sound,sound,,.asString() +ALE,agent,,Agent,agent,,.asString() diff --git a/tdeabc/scripts/field.src.cpp b/tdeabc/scripts/field.src.cpp new file mode 100644 index 000000000..a87d00679 --- /dev/null +++ b/tdeabc/scripts/field.src.cpp @@ -0,0 +1,512 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdelocale.h> +#include <tdeconfig.h> +#include <tdeglobal.h> + +#include "field.h" +#include "address.h" + +using namespace TDEABC; + +class Field::FieldImpl +{ + public: + FieldImpl( int fieldId, int category = 0, + const TQString &label = TQString::null, + const TQString &key = TQString::null, + const TQString &app = TQString::null ) + : mFieldId( fieldId ), mCategory( category ), mLabel( label ), + mKey( key ), mApp( app ) {} + + enum FieldId + { + CustomField, + --ENUMS-- + }; + + int fieldId() { return mFieldId; } + int category() { return mCategory; } + + TQString label() { return mLabel; } + TQString key() { return mKey; } + TQString app() { return mApp; } + + private: + int mFieldId; + int mCategory; + + TQString mLabel; + TQString mKey; + TQString mApp; +}; + + +Field::List Field::mAllFields; +Field::List Field::mDefaultFields; +Field::List Field::mCustomFields; + + +Field::Field( FieldImpl *impl ) +{ + mImpl = impl; +} + +Field::~Field() +{ + delete mImpl; +} + +TQString Field::label() +{ + switch ( mImpl->fieldId() ) { + --CASELABEL-- + case FieldImpl::CustomField: + return mImpl->label(); + default: + return i18n("Unknown Field"); + } +} + +int Field::category() +{ + return mImpl->category(); +} + +TQString Field::categoryLabel( int category ) +{ + switch ( category ) { + case All: + return i18n("All"); + case Frequent: + return i18n("Frequent"); + case Address: + return i18n("street/postal","Address"); + case Email: + return i18n("Email"); + case Personal: + return i18n("Personal"); + case Organization: + return i18n("Organization"); + case CustomCategory: + return i18n("Custom"); + default: + return i18n("Undefined"); + } +} + +TQString Field::value( const TDEABC::Addressee &a ) +{ + switch ( mImpl->fieldId() ) { + --CASEVALUE-- + case FieldImpl::Email: + return a.preferredEmail(); + case FieldImpl::Birthday: + if ( a.birthday().isValid() ) + return a.birthday().date().toString( Qt::ISODate ); + else + return TQString::null; + case FieldImpl::Url: + return a.url().prettyURL(); + case FieldImpl::HomePhone: + { + PhoneNumber::List::ConstIterator it; + + { + // check for preferred number + const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home | PhoneNumber::Pref ); + for ( it = list.begin(); it != list.end(); ++it ) + if ( ((*it).type() & ~(PhoneNumber::Pref)) == PhoneNumber::Home ) + return (*it).number(); + } + + { + // check for normal home number + const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home ); + for ( it = list.begin(); it != list.end(); ++it ) + if ( ((*it).type() & ~(PhoneNumber::Pref)) == PhoneNumber::Home ) + return (*it).number(); + } + + return TQString::null; + } + case FieldImpl::BusinessPhone: + { + PhoneNumber::List::ConstIterator it; + + { + // check for preferred number + const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work | PhoneNumber::Pref ); + for ( it = list.begin(); it != list.end(); ++it ) + if ( ((*it).type() & ~(PhoneNumber::Pref)) == PhoneNumber::Work ) + return (*it).number(); + } + + { + // check for normal work number + const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work ); + for ( it = list.begin(); it != list.end(); ++it ) + if ( ((*it).type() & ~(PhoneNumber::Pref)) == PhoneNumber::Work ) + return (*it).number(); + } + + return TQString::null; + } + case FieldImpl::MobilePhone: + return a.phoneNumber( PhoneNumber::Cell ).number(); + case FieldImpl::HomeFax: + return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); + case FieldImpl::BusinessFax: + return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); + case FieldImpl::CarPhone: + return a.phoneNumber( PhoneNumber::Car ).number(); + case FieldImpl::Isdn: + return a.phoneNumber( PhoneNumber::Isdn ).number(); + case FieldImpl::Pager: + return a.phoneNumber( PhoneNumber::Pager ).number(); + case FieldImpl::HomeAddressStreet: + return a.address( Address::Home ).street(); + case FieldImpl::HomeAddressLocality: + return a.address( Address::Home ).locality(); + case FieldImpl::HomeAddressRegion: + return a.address( Address::Home ).region(); + case FieldImpl::HomeAddressPostalCode: + return a.address( Address::Home ).postalCode(); + case FieldImpl::HomeAddressCountry: + return a.address( Address::Home ).country(); + case FieldImpl::HomeAddressLabel: + return a.address( Address::Home ).label(); + case FieldImpl::BusinessAddressStreet: + return a.address( Address::Work ).street(); + case FieldImpl::BusinessAddressLocality: + return a.address( Address::Work ).locality(); + case FieldImpl::BusinessAddressRegion: + return a.address( Address::Work ).region(); + case FieldImpl::BusinessAddressPostalCode: + return a.address( Address::Work ).postalCode(); + case FieldImpl::BusinessAddressCountry: + return a.address( Address::Work ).country(); + case FieldImpl::BusinessAddressLabel: + return a.address( Address::Work ).label(); + case FieldImpl::CustomField: + return a.custom( mImpl->app(), mImpl->key() ); + default: + return TQString::null; + } +} + +bool Field::setValue( TDEABC::Addressee &a, const TQString &value ) +{ + switch ( mImpl->fieldId() ) { + --CASESETVALUE-- + case FieldImpl::MobilePhone: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Cell ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::HomeFax: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::BusinessFax: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::CarPhone: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Car ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::Isdn: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Isdn ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::Pager: + { + PhoneNumber number = a.phoneNumber( PhoneNumber::Pager ); + number.setNumber( value ); + a.insertPhoneNumber( number ); + return true; + } + case FieldImpl::HomeAddressStreet: + { + TDEABC::Address address = a.address( Address::Home ); + address.setStreet( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::HomeAddressLocality: + { + TDEABC::Address address = a.address( Address::Home ); + address.setLocality( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::HomeAddressRegion: + { + TDEABC::Address address = a.address( Address::Home ); + address.setRegion( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::HomeAddressPostalCode: + { + TDEABC::Address address = a.address( Address::Home ); + address.setPostalCode( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::HomeAddressCountry: + { + TDEABC::Address address = a.address( Address::Home ); + address.setCountry( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::HomeAddressLabel: + { + TDEABC::Address address = a.address( Address::Home ); + address.setLabel( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressStreet: + { + TDEABC::Address address = a.address( Address::Work ); + address.setStreet( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressLocality: + { + TDEABC::Address address = a.address( Address::Work ); + address.setLocality( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressRegion: + { + TDEABC::Address address = a.address( Address::Work ); + address.setRegion( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressPostalCode: + { + TDEABC::Address address = a.address( Address::Work ); + address.setPostalCode( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressCountry: + { + TDEABC::Address address = a.address( Address::Work ); + address.setCountry( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::BusinessAddressLabel: + { + TDEABC::Address address = a.address( Address::Work ); + address.setLabel( value ); + a.insertAddress( address ); + return true; + } + case FieldImpl::Birthday: + a.setBirthday( TQT_TQDATE_OBJECT(TQDate::fromString( value, Qt::ISODate )) ); + return true; + case FieldImpl::CustomField: + a.insertCustom( mImpl->app(), mImpl->key(), value ); + return true; + default: + return false; + } +} + +TQString Field::sortKey( const TDEABC::Addressee &a ) +{ + switch ( mImpl->fieldId() ) { + --CASEVALUE-- + case FieldImpl::Birthday: + if ( a.birthday().isValid() ) { + TQDate date = TQT_TQDATE_OBJECT(a.birthday().date()); + TQString key; + key.sprintf( "%02d-%02d", date.month(), date.day() ); + return key; + } else + return TQString( "00-00" ); + default: + return value( a ).lower(); + } +} + +bool Field::isCustom() +{ + return mImpl->fieldId() == FieldImpl::CustomField; +} + +Field::List Field::allFields() +{ + if ( mAllFields.isEmpty() ) { + --CREATEFIELDS-- + } + + return mAllFields; +} + +Field::List Field::defaultFields() +{ + if ( mDefaultFields.isEmpty() ) { + createDefaultField( FieldImpl::FormattedName ); + createDefaultField( FieldImpl::Email ); + } + + return mDefaultFields; +} + +void Field::createField( int id, int category ) +{ + mAllFields.append( new Field( new FieldImpl( id, category ) ) ); +} + +void Field::createDefaultField( int id, int category ) +{ + mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); +} + +void Field::deleteFields() +{ + Field::List::ConstIterator it; + + for ( it = mAllFields.constBegin(); it != mAllFields.constEnd(); ++it ) { + delete (*it); + } + mAllFields.clear(); + + for ( it = mDefaultFields.constBegin(); it != mDefaultFields.constEnd(); ++it ) { + delete (*it); + } + mDefaultFields.clear(); + + for ( it = mCustomFields.constBegin(); it != mCustomFields.constEnd(); ++it ) { + delete (*it); + } + mCustomFields.clear(); +} + +void Field::saveFields( const TQString &identifier, + const Field::List &fields ) +{ + TDEConfig *cfg = TDEGlobal::config(); + TDEConfigGroupSaver( cfg, "KABCFields" ); + + saveFields( cfg, identifier, fields ); +} + +void Field::saveFields( TDEConfig *cfg, const TQString &identifier, + const Field::List &fields ) +{ + TQValueList<int> fieldIds; + + int custom = 0; + Field::List::ConstIterator it; + for( it = fields.begin(); it != fields.end(); ++it ) { + fieldIds.append( (*it)->mImpl->fieldId() ); + if( (*it)->isCustom() ) { + TQStringList customEntry; + customEntry << (*it)->mImpl->label(); + customEntry << (*it)->mImpl->key(); + customEntry << (*it)->mImpl->app(); + cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + + TQString::number( custom++ ), customEntry ); + } + } + + cfg->writeEntry( identifier, fieldIds ); +} + +Field::List Field::restoreFields( const TQString &identifier ) +{ + TDEConfig *cfg = TDEGlobal::config(); + TDEConfigGroupSaver( cfg, "KABCFields" ); + + return restoreFields( cfg, identifier ); +} + +Field::List Field::restoreFields( TDEConfig *cfg, const TQString &identifier ) +{ + const TQValueList<int> fieldIds = cfg->readIntListEntry( identifier ); + + Field::List fields; + + int custom = 0; + TQValueList<int>::ConstIterator it; + for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { + FieldImpl *f = 0; + if ( (*it) == FieldImpl::CustomField ) { + TQStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + + identifier + "_" + + TQString::number( custom++ ) ); + f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], + customEntry[ 1 ], customEntry[ 2 ] ); + } else { + f = new FieldImpl( *it ); + } + fields.append( new Field( f ) ); + } + + return fields; +} + +bool Field::equals( Field *field ) +{ + bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); + + if ( !sameId ) return false; + + if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; + + return mImpl->key() == field->mImpl->key(); +} + +Field *Field::createCustomField( const TQString &label, int category, + const TQString &key, const TQString &app ) +{ + Field *field = new Field( new FieldImpl( FieldImpl::CustomField, + category | CustomCategory, + label, key, app ) ); + mCustomFields.append( field ); + + return field; +} diff --git a/tdeabc/scripts/makeaddressee b/tdeabc/scripts/makeaddressee new file mode 100755 index 000000000..fa955b0bf --- /dev/null +++ b/tdeabc/scripts/makeaddressee @@ -0,0 +1,215 @@ +#!/usr/bin/perl + +my $srcdir; +$srcdir = `dirname $0` || die "Can't determine \$srcdir."; +chomp $srcdir; + +if (!open( ENTRIES, "$srcdir/entrylist" ) ) { + print "Can't open $srcdir/entrylist\n"; + exit 1; +} + + while(<ENTRIES>) { + if (/^#/) { next; } + chop; + @entries = split /,/; + if (!/^.+,(\w+),(\w+)/) { next; } + push @entryCtrl, @entries[0]; + push @entryRealNames, @entries[1]; + push @entryComments, @entries[2]; + push @entryTypes, @entries[3]; + push @entryNames, @entries[4]; + push @entryCategory, @entries[5]; + push @entryDebug, @entries[6]; + } + +close ENTRIES; + +if (!open( H_IN, "$srcdir/addressee.src.h" ) ) { + print "Can't open $srcdir/addressee.src.h\n"; + exit 1; +} +if (!open( H_OUT, ">../addressee.h" ) ) { + print "Can't open addressee.h\n"; + exit 1; +} + print H_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n"; + + while( <H_IN> ) { + if (/--DECLARATIONS--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] =~ /A/ ) { + print H_OUT " /**\n"; + print H_OUT " Set $entryRealNames[$i].\n"; + print H_OUT " */\n"; + print H_OUT " void set" . ucfirst($entryNames[$i]); + print H_OUT "( const $entryTypes[$i] &$entryNames[$i] );\n"; + + print H_OUT " /**\n"; + print H_OUT " Return $entryRealNames[$i].\n"; + print H_OUT " */\n"; + print H_OUT " $entryTypes[$i] $entryNames[$i]() const;\n"; + } + + if ( $entryCtrl[$i] !~ /L/ ) { next; } + print H_OUT " /**\n"; + print H_OUT " Return translated label for $entryNames[$i] field.\n"; + print H_OUT " */\n"; + print H_OUT " static TQString $entryNames[$i]Label();\n\n"; + } + } else { + print H_OUT; + } + } + +close H_OUT; +close H_IN; + +if (!open( CPP_IN, "$srcdir/addressee.src.cpp" ) ) { + print "Can't open $srcdir/addressee.src.cpp\n"; + exit 1; +} +if (!open( CPP_OUT, ">../addressee.cpp" ) ) { + print "Can't open addressee.cpp\n"; + exit 1; +} + print CPP_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n"; + + while( <CPP_IN> ) { + if (/--VARIABLES--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /A/ ) { next; } + print CPP_OUT " $entryTypes[$i] $entryNames[$i];\n"; + } + } elsif (/--DEFINITIONS--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] =~ /A/ ) { + print CPP_OUT "void Addressee::set" . ucfirst($entryNames[$i]); + print CPP_OUT "( const $entryTypes[$i] &$entryNames[$i] )\n{\n"; + print CPP_OUT " if ( $entryNames[$i] == mData->$entryNames[$i] ) return;\n"; + print CPP_OUT " detach();\n mData->empty = false;\n"; + print CPP_OUT " mData->$entryNames[$i] = $entryNames[$i];\n}\n\n"; + + print CPP_OUT "$entryTypes[$i] Addressee::$entryNames[$i]() const\n{\n"; + print CPP_OUT " return mData->$entryNames[$i];\n}\n\n"; + } + + if ( $entryCtrl[$i] !~ /L/ ) { next; } + @labelwords = split ' ', $entryRealNames[$i]; + for( $j=0; $j < @labelwords; ++$j ) { + $labelwords[$j] = ucfirst $labelwords[$j]; + } + $label = join ' ', @labelwords; + print CPP_OUT "TQString Addressee::$entryNames[$i]Label()\n{\n"; + if ( $entryComments[$i] ) { + print CPP_OUT " return i18n(\"$entryComments[$i]\",\"$label\");\n"; + } else { + print CPP_OUT " return i18n(\"$label\");\n"; + } + print CPP_OUT "}\n\n\n"; + } + } elsif (/--EQUALSTEST--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] =~ /E/ ) { + if ( $entryNames[$i] !~ "revision" ) { + if ( $entryTypes[$i] =~ "TQString" ) { + print CPP_OUT " if ( mData->$entryNames[$i] != a.mData->$entryNames[$i] &&\n"; + print CPP_OUT " !( mData->$entryNames[$i].isEmpty() && a.mData->$entryNames[$i].isEmpty() ) ) {\n"; + print CPP_OUT " kdDebug(5700) << \"$entryNames[$i] differs\" << endl;\n"; + print CPP_OUT " return false;\n"; + print CPP_OUT " }\n"; + } else { + print CPP_OUT " if ( mData->$entryNames[$i] != a.mData->$entryNames[$i] ) {\n"; + print CPP_OUT " kdDebug(5700) << \"$entryNames[$i] differs\" << endl;\n"; + print CPP_OUT " return false;\n"; + print CPP_OUT " }\n"; + } + } + } + } + } elsif (/--STREAMOUT--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] =~ /A/ ) { + print CPP_OUT " s << a.mData->$entryNames[$i];\n"; + } + } + } elsif (/--STREAMIN--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] =~ /A/ ) { + print CPP_OUT " s >> a.mData->$entryNames[$i];\n"; + } + } + } elsif (/--DEBUG--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /A/ ) { next; } + print CPP_OUT " kdDebug(5700) << \" " . ucfirst($entryNames[$i]); + print CPP_OUT ": '\" << $entryNames[$i]()$entryDebug[$i] << \"'\" << endl;\n"; + } + } else { + print CPP_OUT; + } + } + +close CPP_OUT; +close CPP_IN; + +if (!open( CPP_IN, "$srcdir/field.src.cpp" ) ) { + print "Can't open $srcdir/field.src.cpp\n"; + exit 1; +} +if (!open( CPP_OUT, ">../field.cpp" ) ) { + print "Can't open field.cpp\n"; + exit 1; +} + print CPP_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n"; + + while( <CPP_IN> ) { + if (/--ENUMS--/) { + $first = 1; + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /F/ ) { next; } + if ( $first ) { $first = 0; } + else { print CPP_OUT ",\n"; } + print CPP_OUT " " . ucfirst($entryNames[$i]); + } + print CPP_OUT "\n"; + } elsif (/--CASELABEL--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /F/ ) { next; } + if ( $entryCtrl[$i] !~ /L/ ) { next; } + print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n"; + print CPP_OUT " return Addressee::$entryNames[$i]Label();\n"; + } + } elsif (/--CASEVALUE--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /A/ ) { next; } + if ( $entryCtrl[$i] !~ /F/ ) { next; } + if ( $entryTypes[$i] ne "TQString" ) { next; } + print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n"; + print CPP_OUT " return a.$entryNames[$i]();\n"; + } + } elsif (/--CASESETVALUE--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /A/ ) { next; } + if ( $entryCtrl[$i] !~ /F/ ) { next; } + if ( $entryTypes[$i] ne "TQString" ) { next; } + print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n"; + print CPP_OUT " a.set" . ucfirst($entryNames[$i]) . "( value );\n"; + print CPP_OUT " return true;\n"; + } + } elsif (/--CREATEFIELDS--/) { + for( $i=0; $i<@entryNames; ++$i ) { + if ( $entryCtrl[$i] !~ /F/ ) { next; } + print CPP_OUT " createField( FieldImpl::" . ucfirst($entryNames[$i]); + if ( $entryCategory[$i] ) { + print CPP_OUT ", $entryCategory[$i]"; + } + print CPP_OUT " );\n"; + } + } else { + print CPP_OUT; + } + } + +close CPP_OUT; +close CPP_IN; diff --git a/tdeabc/secrecy.cpp b/tdeabc/secrecy.cpp new file mode 100644 index 000000000..3fe33f17d --- /dev/null +++ b/tdeabc/secrecy.cpp @@ -0,0 +1,100 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdelocale.h> + +#include "secrecy.h" + +using namespace TDEABC; + +Secrecy::Secrecy( int type ) + : mType( type ) +{ +} + +bool Secrecy::operator==( const Secrecy &s ) const +{ + return ( mType == s.mType ); +} + +bool Secrecy::operator!=( const Secrecy &s ) const +{ + return !( *this == s ); +} + +bool Secrecy::isValid() const +{ + return mType != Invalid; +} + +void Secrecy::setType( int type ) +{ + mType = type; +} + +int Secrecy::type() const +{ + return mType; +} + +Secrecy::TypeList Secrecy::typeList() +{ + static TypeList list; + + if ( list.isEmpty() ) + list << Public << Private << Confidential; + + return list; +} + +TQString Secrecy::typeLabel( int type ) +{ + switch ( type ) { + case Public: + return i18n( "Public" ); + break; + case Private: + return i18n( "Private" ); + break; + case Confidential: + return i18n( "Confidential" ); + break; + default: + return i18n( "Unknown type" ); + break; + } +} + +TQString Secrecy::asString() const +{ + return typeLabel( mType ); +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Secrecy &secrecy ) +{ + return s << secrecy.mType; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Secrecy &secrecy ) +{ + s >> secrecy.mType; + + return s; +} diff --git a/tdeabc/secrecy.h b/tdeabc/secrecy.h new file mode 100644 index 000000000..596d1b675 --- /dev/null +++ b/tdeabc/secrecy.h @@ -0,0 +1,100 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_SECRECY_H +#define KABC_SECRECY_H + +#include <tqvaluelist.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +class KABC_EXPORT Secrecy +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Secrecy & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Secrecy & ); + +public: + typedef TQValueList<int> TypeList; + + /** + * Secrecy types + * + * @li Public - for public access + * @li Private - only private access + * @li Confidential - access for confidential persons + */ + enum Types { + Public, + Private, + Confidential, + Invalid + }; + + /** + * Constructor. + * + * @param type The secrecy type, see Types. + */ + Secrecy( int type = Invalid ); + + bool operator==( const Secrecy & ) const; + bool operator!=( const Secrecy & ) const; + + /** + Returns if the Secrecy object has a valid value. + */ + bool isValid() const; + + /** + * Sets the type, see Types. + */ + void setType( int type ); + + /** + * Returns the type, see Types. + */ + int type() const; + + /** + * Returns a list of all available secrecy types. + */ + static TypeList typeList(); + + /** + * Returns a translated label for a given secrecy type. + */ + static TQString typeLabel( int type ); + + /** + * For debug. + */ + TQString asString() const; + +private: + int mType; +}; + +KABC_EXPORT TQDataStream& operator<<( TQDataStream &s, const Secrecy &secrecy ); +KABC_EXPORT TQDataStream& operator>>( TQDataStream &s, Secrecy &secrecy ); + +} +#endif diff --git a/tdeabc/sortmode.cpp b/tdeabc/sortmode.cpp new file mode 100644 index 000000000..1fef420eb --- /dev/null +++ b/tdeabc/sortmode.cpp @@ -0,0 +1,79 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdeabc/field.h> + +#include "sortmode.h" + +using namespace TDEABC; + +NameSortMode::NameSortMode() + : mNameType( FormattedName ), mAscendingOrder( true ), d( 0 ) +{ + mNameType = FormattedName; +} + +NameSortMode::NameSortMode( NameType type, bool ascending ) + : mNameType( type ), mAscendingOrder( ascending ), d( 0 ) +{ +} + +bool NameSortMode::lesser( const TDEABC::Addressee &first, const TDEABC::Addressee &second ) const +{ + bool lesser = false; + + switch ( mNameType ) { + case FormattedName: + lesser = TQString::localeAwareCompare( first.formattedName(), second.formattedName() ) < 0; + break; + case FamilyName: + lesser = TQString::localeAwareCompare( first.familyName(), second.familyName() ) < 0; + break; + case GivenName: + lesser = TQString::localeAwareCompare( first.givenName(), second.givenName() ) < 0; + break; + default: + lesser = false; + break; + } + + if ( !mAscendingOrder ) + lesser = !lesser; + + return lesser; +} + +FieldSortMode::FieldSortMode( TDEABC::Field *field, bool ascending ) + : mField( field ), mAscendingOrder( ascending ), d( 0 ) +{ +} + +bool FieldSortMode::lesser( const TDEABC::Addressee &first, const TDEABC::Addressee &second ) const +{ + if ( !mField ) + return false; + else { + bool lesser = TQString::localeAwareCompare( mField->value( first ), mField->value( second ) ) < 0; + if ( !mAscendingOrder ) + lesser = !lesser; + + return lesser; + } +} diff --git a/tdeabc/sortmode.h b/tdeabc/sortmode.h new file mode 100644 index 000000000..49f3490ba --- /dev/null +++ b/tdeabc/sortmode.h @@ -0,0 +1,114 @@ +/* + This file is part of libkabc. + Copyright (c) 2004 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_SORTMODE_H +#define KABC_SORTMODE_H + +#include <tdelibs_export.h> + +#include <tdeabc/addressee.h> + +namespace TDEABC { + +/** + @short Sort method for sorting an addressee list. + + This interface should be reimplemented by classes which shall act as + SortModes for TDEABC::AddresseeList. +*/ +class KABC_EXPORT SortMode +{ + public: + /** + Reimplement this method and return whether the first contact is 'smaller' + than the second. + */ + virtual bool lesser( const TDEABC::Addressee &first, const TDEABC::Addressee &second ) const = 0; +}; + +class KABC_EXPORT NameSortMode : public SortMode +{ + public: + enum NameType + { + FormattedName, + FamilyName, + GivenName + }; + + /** + Constructor. + + Creates a NameSortMethod with FormattedName as name type set. + */ + NameSortMode(); + + /** + Constructor. + + Creates a NameSortMethod with the specified name type. + + @param type The name type. + @param ascending true for ascending sort, false for descending. + */ + NameSortMode( NameType type, bool ascending = true ); + + /** + Returns whether the first contact is 'smaller' then the second. + */ + virtual bool lesser( const TDEABC::Addressee&, const TDEABC::Addressee& ) const; + + private: + NameType mNameType; + bool mAscendingOrder; + + class NameSortModePrivate; + NameSortModePrivate *d; +}; + +class KABC_EXPORT FieldSortMode : public SortMode +{ + public: + /** + Constructor. + + Creates a FieldSortMethod with the specified field. + + @param field The field. + @param ascending true for ascending sort, false for descending. + */ + FieldSortMode( TDEABC::Field *field, bool ascending = true ); + + /** + Returns whether the first contact is 'smaller' then the second. + */ + virtual bool lesser( const TDEABC::Addressee&, const TDEABC::Addressee& ) const; + + private: + TDEABC::Field *mField; + bool mAscendingOrder; + + class FieldSortModePrivate; + FieldSortModePrivate *d; +}; + +} + +#endif diff --git a/tdeabc/sound.cpp b/tdeabc/sound.cpp new file mode 100644 index 000000000..fbdadd2d2 --- /dev/null +++ b/tdeabc/sound.cpp @@ -0,0 +1,118 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "sound.h" + +#include <tqdatastream.h> + +using namespace TDEABC; + +Sound::Sound() + : mIntern( false ) +{ +} + +Sound::Sound( const TQString &url ) + : mUrl( url ), mIntern( false ) +{ +} + +Sound::Sound( const TQByteArray &data ) + : mData( data ), mIntern( true ) +{ +} + +Sound::~Sound() +{ +} + +bool Sound::operator==( const Sound &s ) const +{ + if ( mIntern != s.mIntern ) return false; + + if ( mIntern ) { + if ( mData != s.mData ) + return false; + } else { + if ( mUrl != s.mUrl ) + return false; + } + + return true; +} + +bool Sound::operator!=( const Sound &s ) const +{ + return !( s == *this ); +} + +void Sound::setUrl( const TQString &url ) +{ + mUrl = url; + mIntern = false; +} + +void Sound::setData( const TQByteArray &data ) +{ + mData = data; + mIntern = true; +} + +bool Sound::isIntern() const +{ + return mIntern; +} + +bool Sound::isEmpty() const +{ + return (!mIntern) && mUrl.isEmpty(); + +} + +TQString Sound::url() const +{ + return mUrl; +} + +TQByteArray Sound::data() const +{ + return mData; +} + +TQString Sound::asString() const +{ + if ( mIntern ) + return "intern sound"; + else + return mUrl; +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const Sound &sound ) +{ + return s << sound.mIntern << sound.mUrl; +// return s << sound.mIntern << sound.mUrl << sound.mData; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, Sound &sound ) +{ + s >> sound.mIntern >> sound.mUrl; +// s >> sound.mIntern >> sound.mUrl >> sound.mData; + return s; +} diff --git a/tdeabc/sound.h b/tdeabc/sound.h new file mode 100644 index 000000000..4602c9ed6 --- /dev/null +++ b/tdeabc/sound.h @@ -0,0 +1,153 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_SOUND_H +#define KABC_SOUND_H + +#include <tqcstring.h> +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** @short Class that holds a Sound clip for a contact. + * + * The sound can be played doing something like this: + * + * \code + * KTempFile tmp; + * if(sound.isIntern()) { + * tmp.file()->tqwriteBlock( sound.data() ); + * tmp.close(); + * KAudioPlayer::play( tmp.name() ); + * } else if(!sound.url().isEmpty()) { + * TQString tmpFile; + * if(!TDEIO::NetAccess::download(KURL(themeURL.url()), tmpFile, NULL)) + * { + * KMessageBox::error(0L, + * TDEIO::NetAccess::lastErrorString(), + * i18n("Failed to download sound file"), + * KMessageBox::Notify + * ); + * return; + * } + * KAudioPlayer::play( tmpFile ); + * } + * \endcode + * + * Unfortunetly KAudioPlayer::play is ASync, so to delete the temporary file, the best you can really do is set a timer. + * + */ +class KABC_EXPORT Sound +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Sound & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Sound & ); + +public: + + /** + * Consturctor. Creates an empty object. + */ + Sound(); + + /** + * Consturctor. + * + * @param url A URL that describes the position of the sound file. + */ + Sound( const TQString &url ); + + /** + * Consturctor. + * + * @param data The raw data of the sound. + */ + Sound( const TQByteArray &data ); + + /** + * Destructor. + */ + ~Sound(); + + + bool operator==( const Sound & ) const; + bool operator!=( const Sound & ) const; + + /** + * Sets a URL for the location of the sound file. When using this + * function, isIntern() will return 'false' until you use + * setData(). + * + * @param url The location URL of the sound file. + */ + void setUrl( const TQString &url ); + + /** + * Test if this sound file has been set. + * Just does: !isIntern() && url.isEmpty() + * @since 3.4 + */ + bool isEmpty() const; + + /** + * Sets the raw data of the sound. When using this function, + * isIntern() will return 'true' until you use setUrl(). + * + * @param data The raw data of the sound. + */ + void setData( const TQByteArray &data ); + + /** + * Returns whether the sound is described by a URL (extern) or + * by the raw data (intern). + * When this method returns 'true' you can use data() to + * get the raw data. Otherwise you can request the URL of this + * sound by url() and load the raw data from that location. + */ + bool isIntern() const; + + /** + * Returns the location URL of this sound. + */ + TQString url() const; + + /** + * Returns the raw data of this sound. + */ + TQByteArray data() const; + + /** + * Returns string representation of the sound. + */ + TQString asString() const; + +private: + TQString mUrl; + TQByteArray mData; + + int mIntern; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const Sound & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, Sound & ); + +} +#endif diff --git a/tdeabc/stdaddressbook.cpp b/tdeabc/stdaddressbook.cpp new file mode 100644 index 000000000..c0789f215 --- /dev/null +++ b/tdeabc/stdaddressbook.cpp @@ -0,0 +1,203 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <stdlib.h> + +#include <tdeapplication.h> +#include <kcrash.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tderesources/manager.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> +#include <kstaticdeleter.h> + +#include "resource.h" + +#include "stdaddressbook.h" + +using namespace TDEABC; + +StdAddressBook *StdAddressBook::mSelf = 0; +bool StdAddressBook::mAutomaticSave = true; + +static KStaticDeleter<StdAddressBook> addressBookDeleter; + +TQString StdAddressBook::fileName() +{ + return locateLocal( "data", "tdeabc/std.vcf" ); +} + +TQString StdAddressBook::directoryName() +{ + return locateLocal( "data", "tdeabc/stdvcf" ); +} + +void StdAddressBook::handleCrash() +{ +} + +StdAddressBook *StdAddressBook::self() +{ + if ( !mSelf ) + addressBookDeleter.setObject( mSelf, new StdAddressBook ); + + return mSelf; +} + +StdAddressBook *StdAddressBook::self( bool asynchronous ) +{ + if ( !mSelf ) + addressBookDeleter.setObject( mSelf, new StdAddressBook( asynchronous ) ); + + return mSelf; +} + +StdAddressBook::StdAddressBook() + : AddressBook( "" ) +{ + kdDebug(5700) << "StdAddressBook::StdAddressBook()" << endl; + + init( false ); +} + +StdAddressBook::StdAddressBook( bool asynchronous ) + : AddressBook( "" ) +{ + kdDebug(5700) << "StdAddressBook::StdAddressBook( bool )" << endl; + + init( asynchronous ); +} + +StdAddressBook::~StdAddressBook() +{ + if ( mAutomaticSave ) + saveAll(); +} + +void StdAddressBook::init( bool asynchronous ) +{ + KRES::Manager<Resource> *manager = resourceManager(); + + KRES::Manager<Resource>::ActiveIterator it; + for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { + (*it)->setAddressBook( this ); + if ( !(*it)->open() ) { + error( TQString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); + continue; + } + connect( *it, TQT_SIGNAL( loadingFinished( Resource* ) ), + this, TQT_SLOT( resourceLoadingFinished( Resource* ) ) ); + connect( *it, TQT_SIGNAL( savingFinished( Resource* ) ), + this, TQT_SLOT( resourceSavingFinished( Resource* ) ) ); + + connect( *it, TQT_SIGNAL( loadingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceLoadingError( Resource*, const TQString& ) ) ); + connect( *it, TQT_SIGNAL( savingError( Resource*, const TQString& ) ), + this, TQT_SLOT( resourceSavingError( Resource*, const TQString& ) ) ); + } + + Resource *res = standardResource(); + if ( !res ) { + res = manager->createResource( "file" ); + if ( res ) + addResource( res ); + else + kdDebug(5700) << "No resource available!!!" << endl; + } + + setStandardResource( res ); + manager->writeConfig(); + + if ( asynchronous ) + asyncLoad(); + else + load(); +} + +bool StdAddressBook::saveAll() +{ + kdDebug(5700) << "StdAddressBook::saveAll()" << endl; + bool ok = true; + + deleteRemovedAddressees(); + + KRES::Manager<Resource>::ActiveIterator it; + KRES::Manager<Resource> *manager = resourceManager(); + for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { + if ( !(*it)->readOnly() && (*it)->isOpen() ) { + Ticket *ticket = requestSaveTicket( *it ); + if ( !ticket ) { + error( i18n( "Unable to save to resource '%1'. It is locked." ) + .arg( (*it)->resourceName() ) ); + return false; + } + + if ( !AddressBook::save( ticket ) ) { + ok = false; + releaseSaveTicket( ticket ); + } + } + } + + return ok; +} + +bool StdAddressBook::save() +{ + kdDebug(5700) << "StdAddressBook::save()" << endl; + + if ( mSelf ) + return mSelf->saveAll(); + else + return true; +} + +void StdAddressBook::close() +{ + addressBookDeleter.destructObject(); +} + +void StdAddressBook::setAutomaticSave( bool enable ) +{ + mAutomaticSave = enable; +} + +bool StdAddressBook::automaticSave() +{ + return mAutomaticSave; +} + +// should get const for 4.X +Addressee StdAddressBook::whoAmI() +{ + TDEConfig config( "kabcrc" ); + config.setGroup( "General" ); + + return findByUid( config.readEntry( "WhoAmI" ) ); +} + +void StdAddressBook::setWhoAmI( const Addressee &addr ) +{ + TDEConfig config( "kabcrc" ); + config.setGroup( "General" ); + + config.writeEntry( "WhoAmI", addr.uid() ); +} diff --git a/tdeabc/stdaddressbook.h b/tdeabc/stdaddressbook.h new file mode 100644 index 000000000..86804a91e --- /dev/null +++ b/tdeabc/stdaddressbook.h @@ -0,0 +1,153 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_STDADDRESSBOOK_H +#define KABC_STDADDRESSBOOK_H + +#include "addressbook.h" + +namespace TDEABC { + +/** + Standard KDE address book + + This class provides access to the standard KDE address book shared by all + applications. + + It's implemented as a singleton. Use self() to get the address book + object. On the first self() call the address book also gets loaded. + + Example: + + \code + TDEABC::AddressBook *ab = TDEABC::StdAddressBook::self(); + + AddressBook::Ticket *ticket = ab->requestSaveTicket(); + + if ( ticket ) { + TDEABC::AddressBook::Iterator it; + for ( it = ab->begin(); it != ab->end(); ++it ) { + kdDebug() << "UID=" << (*it).uid() << endl; + + // do some other stuff + } + + TDEABC::StdAddressBook::save( ticket ); + } + \endcode +*/ +class KABC_EXPORT StdAddressBook : public AddressBook +{ + public: + + /** + Destructor. + */ + ~StdAddressBook(); + + /** + Returns the standard addressbook object. It also loads all resources of + the users standard address book synchronously. + */ + static StdAddressBook *self(); + + /** + This is the same as above, but with specified behaviour of resource loading. + + @param asynchronous When true, the resources are loaded asynchronous, that + means you have the data foremost the addressBookChanged() + signal has been emitted. So connect to this signal when + using this method! + */ + static StdAddressBook *self( bool asynchronous ); + + /** + Saves the standard address book to disk. + + @deprecated Use AddressBook::save( Ticket* ) instead + */ + static bool save() KDE_DEPRECATED; + + /** + @deprecated There is no need to call this function anymore. + */ + static void handleCrash() KDE_DEPRECATED; + + /** + Returns the default file name for vcard-based addressbook + */ + static TQString fileName(); + + /** + Returns the default directory name for vcard-based addressbook + */ + static TQString directoryName(); + + /** + Sets the automatic save property of the address book. + + @param state If true, the address book is saved automatically + at destruction time, otherwise you have to call + AddressBook::save( Ticket* ). + */ + static void setAutomaticSave( bool state ); + + /** + Closes the address book. Depending on automaticSave() it will + save the address book first. + */ + static void close(); + + /** + Returns whether the address book is saved at destruction time. + See also setAutomaticSave(). + */ + static bool automaticSave(); + + /** + Returns the contact, that is associated with the owner of the + address book. This contact should be used by other programs + to access user specific data. + */ + Addressee whoAmI(); + + /** + Sets the users contact. See whoAmI() for more information. + + @param addr The users contact. + */ + void setWhoAmI( const Addressee &addr ); + + protected: + StdAddressBook(); + StdAddressBook( bool asynchronous ); + + void init( bool asynchronous ); + bool saveAll(); + + private: + static StdAddressBook *mSelf; + static bool mAutomaticSave; +}; + +} + +#endif + diff --git a/tdeabc/tdeab2tdeabc.cpp b/tdeabc/tdeab2tdeabc.cpp new file mode 100644 index 000000000..20aef735c --- /dev/null +++ b/tdeabc/tdeab2tdeabc.cpp @@ -0,0 +1,476 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqfile.h> +#include <tqtextstream.h> + +#include <kabapi.h> +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <tdemessagebox.h> +#include <kstandarddirs.h> + +#include "addressbook.h" +#include "stdaddressbook.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + { "disable-autostart", I18N_NOOP( "Disable automatic startup on login" ), 0 }, + { "quiet", "", 0 }, + { "o", 0, 0 }, + { "override", I18N_NOOP( "Override existing entries" ), "1" }, + TDECmdLineLastOption +}; + +void readKMailEntry( const TQString &kmailEntry, TDEABC::AddressBook *ab ) +{ + kdDebug() << "KMAILENTRY: " << kmailEntry << endl; + + TQString entry = kmailEntry.simplifyWhiteSpace(); + if ( entry.isEmpty() ) return; + + TQString email; + TQString name; + TQString comment; + + if ( entry.at( entry.length() -1 ) == ')' ) { + int br = entry.findRev( '(' ); + if ( br >= 0 ) { + comment = entry.mid( br + 1, entry.length() - br - 2 ); + entry.truncate( br ); + if ( entry.at( entry.length() - 1 ).isSpace() ) { + entry.truncate( br - 1 ); + } + } + } + + int posSpace = entry.findRev( ' ' ); + if ( posSpace < 0 ) { + email = entry; + if ( !comment.isEmpty() ) { + name = comment; + comment = ""; + } + } else { + email = entry.mid( posSpace + 1 ); + name = entry.left( posSpace ); + } + + if ( email.at( 0 ) == '<' && email.at( email.length() - 1) == '>' ) { + email = email.mid( 1, email.length() - 2 ); + } + if ( name.at( 0 ) == '"' && name.at( name.length() - 1) == '"' ) { + name = name.mid( 1, name.length() - 2 ); + } + if ( name.at( 0 ) == '\'' && name.at( name.length() - 1) == '\'' ) { + name = name.mid( 1, name.length() - 2 ); + } + + if ( name.at( name.length() -1 ) == ')' ) { + int br = name.findRev( '(' ); + if ( br >= 0 ) { + comment = name.mid( br + 1, name.length() - br - 2 ) + " " + comment; + name.truncate( br ); + if ( name.at( name.length() - 1 ).isSpace() ) { + name.truncate( br - 1 ); + } + } + } + + kdDebug() << " EMAIL : " << email << endl; + kdDebug() << " NAME : " << name << endl; + kdDebug() << " COMMENT : " << comment << endl; + + TDEABC::Addressee::List al = ab->findByEmail( email ); + if ( al.isEmpty() ) { + TDEABC::Addressee a; + a.setNameFromString( name ); + a.insertEmail( email ); + a.setNote( comment ); + + ab->insertAddressee( a ); + + kdDebug() << "--INSERTED: " << a.realName() << endl; + } +} + +void importKMailAddressBook( TDEABC::AddressBook *ab ) +{ + TQString fileName = locateLocal( "data", "kmail/addressbook" ); + TQString kmailConfigName = locate( "config", "kmailrc" ); + if ( !kmailConfigName.isEmpty() ) { + TDEConfig cfg( kmailConfigName ); + cfg.setGroup( "Addressbook" ); + fileName = cfg.readPathEntry( "default", fileName ); + } + if ( !TDEStandardDirs::exists( fileName ) ) { + kdDebug(5700) << "Couldn't find KMail addressbook." << endl; + return; + } + + TQFile f( fileName ); + if ( !f.open(IO_ReadOnly) ) { + kdDebug(5700) << "Couldn't open file '" << fileName << "'" << endl; + return; + } + + TQStringList kmailEntries; + + TQTextStream t( &f ); + while ( !t.eof() ) { + kmailEntries.append( t.readLine() ); + } + f.close(); + + TQStringList::ConstIterator it; + for ( it = kmailEntries.begin(); it != kmailEntries.end(); ++it ) { + if ( (*it).at( 0 ) == '#' ) continue; + bool insideQuote = false; + int end = (*it).length() - 1; + for ( int i = end; i; i-- ) { + if ( (*it).at( i ) == '"' ) { + if ( insideQuote ) + insideQuote = false; + else + insideQuote = true; + } else if ( (*it).at( i ) == ',' && !insideQuote ) { + readKMailEntry( (*it).mid( i + 1, end - i ), ab ); + end = i - 1; + } + } + + readKMailEntry( (*it).mid( 0, end + 1 ), ab ); + } +} + +void readKAddressBookEntries( const TQString &dataString, Addressee &a ) +{ + // Strip "KMail:1.0" prefix and "[EOS]" suffix. + TQString str = dataString.mid( 11, dataString.length() - 24 ); + + TQStringList entries = TQStringList::split( "\n[EOR]\n ", str ); + + Address homeAddress( Address::Home ); + Address businessAddress( Address::Work ); + Address otherAddress; + + TQStringList::ConstIterator it; + for ( it = entries.begin(); it != entries.end(); ++it ) { + int pos = (*it).find( "\n" ); + TQString fieldName = (*it).left( pos ); + TQString fieldValue = (*it).mid( pos + 2 ); + + if ( fieldName == "X-HomeFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home | + PhoneNumber::Fax ) ); + } else if ( fieldName == "X-OtherPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, 0 ) ); + } else if ( fieldName == "X-PrimaryPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pref ) ); + } else if ( fieldName == "X-BusinessFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work | + PhoneNumber::Fax ) ); + } else if ( fieldName == "X-CarPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Car ) ); + } else if ( fieldName == "X-MobilePhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Cell ) ); + } else if ( fieldName == "X-ISDN" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Isdn ) ); + } else if ( fieldName == "X-OtherFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Fax ) ); + } else if ( fieldName == "X-Pager" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pager ) ); + } else if ( fieldName == "X-BusinessPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work ) ); + } else if ( fieldName == "X-HomePhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home ) ); + } else if ( fieldName == "X-HomeAddress" ) { + homeAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-HomeAddressStreet" ) { + homeAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-HomeAddressCity" ) { + homeAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-HomeAddressPostalCode" ) { + homeAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-HomeAddressState" ) { + homeAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-HomeAddressCountry" ) { + homeAddress.setCountry( fieldValue ); + } else if ( fieldName == "X-BusinessAddress" ) { + businessAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-BusinessAddressStreet" ) { + businessAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-BusinessAddressCity" ) { + businessAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-BusinessAddressPostalCode" ) { + businessAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-BusinessAddressState" ) { + businessAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-BusinessAddressCountry" ) { + businessAddress.setCountry( fieldValue ); + } else if ( fieldName == "X-OtherAddress" ) { + otherAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-OtherAddressStreet" ) { + otherAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-OtherAddressCity" ) { + otherAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-OtherAddressPostalCode" ) { + otherAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-OtherAddressState" ) { + otherAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-OtherAddressCountry" ) { + otherAddress.setCountry( fieldValue ); + } else if ( fieldName == "NICKNAME" ) { + a.setNickName( fieldValue ); + } else if ( fieldName == "ORG" ) { + a.setOrganization( fieldValue ); + } else if ( fieldName == "ROLE" ) { + a.setRole( fieldValue ); + } else if ( fieldName == "BDAY" ) { + a.setBirthday( TDEGlobal::locale()->readDate( fieldValue ) ); + } else if ( fieldName == "WEBPAGE" ) { + a.setUrl( KURL( fieldValue ) ); + } else if ( fieldName == "N" ) { + } else if ( fieldName == "X-FirstName" ) { + } else if ( fieldName == "X-MiddleName" ) { + } else if ( fieldName == "X-LastName" ) { + } else if ( fieldName == "X-Title" ) { + } else if ( fieldName == "X-Suffix" ) { + } else if ( fieldName == "X-FileAs" ) { + } else if ( fieldName == "EMAIL" ) { + a.insertEmail( fieldValue, true ); + } else if ( fieldName == "X-E-mail2" ) { + a.insertEmail( fieldValue ); + } else if ( fieldName == "X-E-mail3" ) { + a.insertEmail( fieldValue ); + } else if ( fieldName == "X-Notes" ) { + } else { + a.insertCustom( "KADDRESSBOOK", fieldName, fieldValue ); + } + } + + if ( !homeAddress.isEmpty() ) a.insertAddress( homeAddress ); + if ( !businessAddress.isEmpty() ) a.insertAddress( businessAddress ); + if ( !otherAddress.isEmpty() ) a.insertAddress( otherAddress ); +} + +void importKab( TDEABC::AddressBook *ab, bool override, bool quiet ) +{ + TQString fileName = TDEGlobal::dirs()->saveLocation( "data", "kab/" ); + fileName += "addressbook.kab"; + if ( !TQFile::exists( fileName ) ) { + if ( !quiet ) { + KMessageBox::error( 0, "<qt>" + i18n( "Address book file <b>%1</b> not found! Make sure the old address book is located there and you have read permission for this file." ) + .arg( fileName ) + "</qt>" ); + } + kdDebug(5700) << "No KDE 2 addressbook found." << endl; + return; + } + + kdDebug(5700) << "Converting old-style kab addressbook to " + "new-style kabc addressbook." << endl; + + KabAPI kab( 0 ); + if ( kab.init() != ::AddressBook::NoError ) { + kdDebug(5700) << "Error initing kab" << endl; + exit( 1 ); + } + + KabKey key; + ::AddressBook::Entry entry; + + int num = kab.addressbook()->noOfEntries(); + + kdDebug(5700) << "kab Addressbook has " << num << " entries." << endl; + + for ( int i = 0; i < num; ++i ) { + if ( ::AddressBook::NoError != kab.addressbook()->getKey( i, key ) ) { + kdDebug(5700) << "Error getting key for index " << i << " from kab." << endl; + continue; + } + if ( ::AddressBook::NoError != kab.addressbook()->getEntry( key, entry ) ) { + kdDebug(5700) << "Error getting entry for index " << i << " from kab." << endl; + continue; + } + + Addressee a; + + // Convert custom entries + int count = 0; + bool idFound = false; + TQStringList::ConstIterator customIt; + for ( customIt = entry.custom.begin(); customIt != entry.custom.end(); ++customIt ) { + if ( (*customIt).startsWith( "X-KABC-UID:" ) ) { + a.setUid( (*customIt).mid( (*customIt).find( ":" ) + 1 ) ); + idFound = true; + } else if ( (*customIt).startsWith( "KMail:1.0\n" ) ) { + readKAddressBookEntries( *customIt, a ); + } else { + a.insertCustom( "tdeab2tdeabc", TQString::number( count++ ), *customIt ); + } + } + if ( idFound ) { + if ( !override ) continue; + } else { + entry.custom << "X-KABC-UID:" + a.uid(); + ::AddressBook::ErrorCode error = kab.addressbook()->change( key, entry ); + if ( error != ::AddressBook::NoError ) { + kdDebug(5700) << "kab.change returned with error " << error << endl; + } else { + kdDebug(5700) << "Wrote back to kab uid " << a.uid() << endl; + } + } + + a.setTitle( entry.title ); + a.setFormattedName( entry.fn ); + a.setPrefix( entry.nameprefix ); + a.setGivenName( entry.firstname ); + a.setAdditionalName( entry.middlename ); + a.setFamilyName( entry.lastname ); + a.setBirthday( entry.birthday ); + + TQStringList::ConstIterator emailIt; + for ( emailIt = entry.emails.begin(); emailIt != entry.emails.end(); ++emailIt ) + a.insertEmail( *emailIt ); + + TQStringList::ConstIterator phoneIt; + for ( phoneIt = entry.telephone.begin(); phoneIt != entry.telephone.end(); ++phoneIt ) { + int kabType = (*phoneIt++).toInt(); + if ( phoneIt == entry.telephone.end() ) break; + TQString number = *phoneIt; + int type = 0; + if ( kabType == ::AddressBook::Fixed ) type = PhoneNumber::Voice; + else if ( kabType == ::AddressBook::Mobile ) type = PhoneNumber::Cell | PhoneNumber::Voice; + else if ( kabType == ::AddressBook::Fax ) type = PhoneNumber::Fax; + else if ( kabType == ::AddressBook::Modem ) type = PhoneNumber::Modem; + a.insertPhoneNumber( PhoneNumber( number, type ) ); + } + + if ( entry.URLs.count() > 0 ) { + a.setUrl( KURL( entry.URLs.first() ) ); + if ( entry.URLs.count() > 1 ) { + kdWarning() << "More than one URL. Ignoring all but the first." << endl; + } + } + + int noAdr = entry.noOfAddresses(); + for ( int j = 0; j < noAdr; ++j ) { + ::AddressBook::Entry::Address kabAddress; + entry.getAddress( j, kabAddress ); + + Address adr; + + adr.setStreet( kabAddress.address ); + adr.setPostalCode( kabAddress.zip ); + adr.setLocality( kabAddress.town ); + adr.setCountry( kabAddress.country ); + adr.setRegion( kabAddress.state ); + + TQString label; + if ( !kabAddress.headline.isEmpty() ) label += kabAddress.headline + "\n"; + if ( !kabAddress.position.isEmpty() ) label += kabAddress.position + "\n"; + if ( !kabAddress.org.isEmpty() ) label += kabAddress.org + "\n"; + if ( !kabAddress.orgUnit.isEmpty() ) label += kabAddress.orgUnit + "\n"; + if ( !kabAddress.orgSubUnit.isEmpty() ) label += kabAddress.orgSubUnit + "\n"; + if ( !kabAddress.deliveryLabel.isEmpty() ) label += kabAddress.deliveryLabel + "\n"; + adr.setLabel( label ); + + a.insertAddress( adr ); + } + + TQString note = entry.comment; + + if ( !entry.user1.isEmpty() ) note += "\nUser1: " + entry.user1; + if ( !entry.user2.isEmpty() ) note += "\nUser2: " + entry.user2; + if ( !entry.user3.isEmpty() ) note += "\nUser3: " + entry.user3; + if ( !entry.user4.isEmpty() ) note += "\nUser4: " + entry.user4; + + if ( !entry.keywords.count() == 0 ) note += "\nKeywords: " + entry.keywords.join( ", " ); + + TQStringList::ConstIterator talkIt; + for ( talkIt = entry.talk.begin(); talkIt != entry.talk.end(); ++talkIt ) { + note += "\nTalk: " + (*talkIt); + } + + a.setNote( note ); + + a.setPrefix( entry.rank + a.prefix() ); // Add rank to prefix + + a.setCategories( entry.categories ); + + kdDebug(5700) << "Addressee: " << a.familyName() << endl; + + ab->insertAddressee( a ); + } + + kab.save( true ); +} + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "tdeab2tdeabc", I18N_NOOP( "Kab to Kabc Converter" ), "0.1" ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + bool override = false; + + if ( args->isSet( "override" ) ) { + kdDebug() << "Override existing entries." << endl; + + override = true; + } + + bool quiet = false; + + if ( args->isSet( "quiet" ) ) + quiet = true; + + if ( args->isSet( "disable-autostart" ) ) { + kdDebug() << "Disable autostart." << endl; + + TDEConfig *config = app.config(); + config->setGroup( "Startup" ); + config->writeEntry( "EnableAutostart", false ); + } + + TDEABC::AddressBook *kabcBook = StdAddressBook::self(); + + importKMailAddressBook( kabcBook ); + + importKab( kabcBook, override, quiet ); + + StdAddressBook::save(); + + kdDebug(5700) << "Saved kabc addressbook to '" << kabcBook->identifier() << "'" << endl; +} + diff --git a/tdeabc/tdeab2tdeabc.desktop b/tdeabc/tdeab2tdeabc.desktop new file mode 100644 index 000000000..ef7641b23 --- /dev/null +++ b/tdeabc/tdeab2tdeabc.desktop @@ -0,0 +1,105 @@ +[Desktop Entry] +Name=tdeab2tdeabc +Name[af]=kab-na-kabc +Name[csb]=Kònwersëjô adresowi knéżczi +Name[eo]=Konvertilo de "kab" al "kabc" +Name[fr]=KAB2KABC +Name[fy]=Kab2kabc +Name[hu]=Kab2kabc +Name[it]=Kab2Kabc +Name[nl]=Kab2kabc +Name[pl]=Konwersja książki adresowej +Name[pt_BR]=Conversão de kab para kabc +Name[ro]=Kab2kabc +Name[sv]=Kab2kabc +Name[te]=కెఎబి2కెఎబిసి +Name[zu]=i-tdeab2tdeabc +Exec=tdeab2tdeabc --disable-autostart --quiet +Icon=misc +Type=Application +Comment=libkab to libkabc conversion tool. +Comment[af]=libkab na libkabc omskakeling program. +Comment[ar]=أداة تحويل libkab إلى libkabc. +Comment[az]=libkab - libkabc dönüşdürmə vasitəsi. +Comment[be]=Інструмент пераўтварэння libkab у libkabc. +Comment[bg]=Програма за конвертиране на libkab до libkabc. +Comment[bn]=libkab থেকে libtdeabc-তে পরিবর্তন করার প্রোগ্রাম। +Comment[bs]=alat za pretvaranje libkab u libkabc. +Comment[ca]=Eina de conversió de libkab a libkabc. +Comment[cs]=Převod dat z libkab do libkabc. +Comment[csb]=Nôrzãdze do kònwersëji z libkab do libkabc. +Comment[cy]=erfyn trosi libkab i libkabc +Comment[da]=libkab-til-libtdeabc-konverteringsværktøj. +Comment[de]=Konvertierung von libkab in libkabc +Comment[el]=Εργαλείο μετατροπής από το libkab στο libkabc. +Comment[eo]=Konvertilo de "libkab" al "libkabc" +Comment[es]=Conversor libkab a libkabc. +Comment[et]=libkab -> libkabc teisendamine +Comment[eu]=libkab-etik libtdeabc-era bihurtzeko tresna. +Comment[fa]=ابزار تبدیل libkab به libcabc. +Comment[fi]=libkab-libkabc -muunnin +Comment[fr]=Outil de conversion de libkab vers libkabc. +Comment[fy]=Konversjeprogramma fan libkab nei libkabc. +Comment[ga]=Uirlis tiontaithe ó libkab go libkabc. +Comment[gl]=Ferramenta de conversión de libkab a libkabc. +Comment[he]=כלי המרה מ־libkab ל־libkabc +Comment[hi]=libkab से libkabc बदलने वाला औजार +Comment[hr]=Alat za pretvaranje iz libkab u libkabc +Comment[hsb]=libkab -> libkabc konwerter +Comment[hu]=libkab -> libkabc konvertáló. +Comment[id]=konverter libkab ke libkabc. +Comment[is]=libkab í libkabc breytingatól. +Comment[it]=Strumento di conversione da libkab a libkabc. +Comment[ja]=libkab から libkabc への変換ツール +Comment[ka]=libkab => libkabc გარდაქმნის ხელსაწყო. +Comment[kk]=libkab дегеннен libkabc дегенге айналдыру құралы. +Comment[km]=ឧបករណ៍បម្លែងពី libkab ទៅ libkabc +Comment[ko]=libkab을 libkabc로 바꿔주는 연장. +Comment[lb]=libkab op libkabc Konvertéierungs-Hëllefsmëttel. +Comment[lt]=libkab į libkabc konvertavimo įrankis. +Comment[lv]=libkab uz libkabc kovertēšanas rīks. +Comment[mk]=алатка за претворање од libkab во libkabc. +Comment[mn]=libkab-аас libtdeabc-руу хөрвүүлэгч +Comment[ms]=perkakasan penukaran libkab to libkabc. +Comment[mt]=Għodda għall-konverżjoni libkab għal libkabc +Comment[nb]=libkab til libkabc konverteringsverktøy. +Comment[nds]=Warktüüch för't Ümwanneln vun libkab na libkabc. +Comment[ne]=libkab to libkabc रूपान्तरण उपकरण । +Comment[nl]=Conversieprogramma van libkab naar libkabc. +Comment[nn]=Konverterer libkab til libkabc +Comment[nso]=Sebereka sa phetosetso ya libkab go libkabc +Comment[pa]=libkab ਤੋ libkabc ਤਬਦੀਲੀ ਸੰਦ। +Comment[pl]=Narzędzie do konwersji z libkab do libkabc. +Comment[pt]=Ferramenta de conversão de libkab para libkabc. +Comment[pt_BR]=Ferramenta de conversão de libkab para libkabc. +Comment[ro]=Utilitar de conversie de la "libkab" la "libkabc". +Comment[ru]=утилита преобразования libkab в libkabc. +Comment[rw]=Igikoresho cy'ihindura libkab muri libkabc. +Comment[se]=konverterenreaidu libkab:as libkabc:ai +Comment[sk]=Prevod dát z libkab do libkabc. +Comment[sl]=Orodje za pretvorbo iz libkab v libkabc +Comment[sq]=Vegla për shëndrimin e libkab në libkabc. +Comment[sr]=Алат за конверзију из libkab-а у libkabc. +Comment[sr@Latn]=Alat za konverziju iz libkab-a u libkabc. +Comment[ss]=Lithulusi lekutjintja le-libkab kuya ku-libkabc. +Comment[sv]=Konverteringsverktyg från libkab till libkabc +Comment[ta]=libkab இலிருந்து libkabc க்கு மாற்றும் கருவி. +Comment[te]=libkab నుంచి libkabc కు మార్చు పనిముట్టు +Comment[tg]=асбоби дигаргунсози libkab ба libkabc +Comment[th]=เครื่องมือเปลี่ยน libkab เป็น libkabc +Comment[tr]=libkab' tan libkabc' ye dönüştürme aracı +Comment[tt]=libkab-›libkabc äyländerü qoralı. +Comment[uk]=Засіб перетворення libkab до libkabc. +Comment[uz]=libkab'ni libkabc'ga aylantiradigan vosita. +Comment[uz@cyrillic]=libkab'ни libkabc'га айлантирадиган восита. +Comment[ven]=Tshishumiswa tsha u shandukisa libkab itshi ya kha libkabc +Comment[vi]=Công cụ chuyển đổi libkab sang libkabc. +Comment[xh]=libkab kwi libkabc isixhobo sokuguqulela. +Comment[zh_CN]=libkab 到 libkabc 的转换工具。 +Comment[zh_HK]=libkab 至 libkabc 的轉換工具 +Comment[zh_TW]=libkab 至 libkabc 轉換工具 +Comment[zu]=Ithuluzi lokuguqula le-libkab kuyaku-libkabc +Terminal=false +NoDisplay=true +X-TDE-autostart-condition=tdeab2tdeabcrc:Startup:EnableAutostart:true +OnlyShowIn=TDE; diff --git a/tdeabc/tdeabc_manager.desktop b/tdeabc/tdeabc_manager.desktop new file mode 100644 index 000000000..0af910f52 --- /dev/null +++ b/tdeabc/tdeabc_manager.desktop @@ -0,0 +1,76 @@ +[Desktop Entry] +Name=Contacts +Name[af]=Kontakte +Name[ar]=المراسلين +Name[be]=Кантакты +Name[br]=Darempredoù +Name[bs]=Kontakti +Name[ca]=Contactes +Name[cs]=Kontakty +Name[csb]=Łączbë +Name[cy]=Cysylltau +Name[da]=Kontakter +Name[de]=Kontakte +Name[el]=Επαφές +Name[eo]=Kontaktoj +Name[es]=Contactos +Name[et]=Kontaktid +Name[eu]=Kontaktuak +Name[fa]=تماسها +Name[fi]=Yhteystiedot +Name[fy]=Kontakten +Name[ga]=Teagmhálacha +Name[gl]=Contactos +Name[he]=אנשי קשר +Name[hi]=सम्पर्क +Name[hr]=Kontakti +Name[hsb]=Adresy +Name[hu]=Névjegyek +Name[id]=Kontak +Name[is]=Tengiliðir +Name[it]=Contatti +Name[ja]=コンタクト +Name[ka]=კონტაქტები +Name[kk]=Контакттар +Name[km]=ទំនាក់ទំនង +Name[ku]=Tekilî +Name[lb]=Kontakter +Name[lt]=Kontaktai +Name[lv]=Kontakti +Name[mk]=Контакти +Name[ms]=Hubungan +Name[nb]=Kontakter +Name[nds]=Kontakten +Name[ne]=सम्पर्क +Name[nl]=Contactpersonen +Name[nn]=Kontaktar +Name[pa]=ਸੰਪਰਕ +Name[pl]=Kontakty +Name[pt]=Contactos +Name[pt_BR]=Contatos +Name[ro]=Contacte +Name[ru]=Контакты +Name[rw]=Amaderesi +Name[se]=Oktavuođat +Name[sk]=Kontakty +Name[sl]=Stiki +Name[sr]=Контакти +Name[sr@Latn]=Kontakti +Name[sv]=Kontakter +Name[ta]=தொடர்புகள் +Name[te]=సంప్రదింపులు +Name[tg]=Алоқаҳо +Name[th]=รายชื่อติดต่อ +Name[tr]=Bağlantılar +Name[tt]=Elemtälär +Name[uk]=Контакти +Name[uz]=Aloqalar +Name[uz@cyrillic]=Алоқалар +Name[vi]=Liên lạc +Name[zh_CN]=联系人 +Name[zh_HK]=聯絡人 +Name[zh_TW]=聯絡人 +Type=Service +ServiceTypes=KResources/Manager + +X-TDE-ResourceFamily=contact diff --git a/tdeabc/tests/Makefile.am b/tdeabc/tests/Makefile.am new file mode 100644 index 000000000..aca0597ad --- /dev/null +++ b/tdeabc/tests/Makefile.am @@ -0,0 +1,55 @@ +# Make sure $(all_includes) remains last! +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc -I$(top_srcdir)/kab \ + -I$(srcdir)/../vcardparser/ -I$(srcdir)/../vcard/include \ + -I$(srcdir)/../vcard/include/generated \ + -I$(srcdir)/../vcardparser $(all_includes) +LDADD = ../libkabc.la + +METASOURCES = AUTO + +check_PROGRAMS = testlock testldapclient + +testlock_LDFLAGS = $(all_libraries) +testlock_SOURCES = testlock.cpp + +testldapclient_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testldapclient_SOURCES = testldapclient.cpp + +EXTRA_PROGRAMS = testkabc testkabcdlg testdistlist bigread bigwrite testdb \ + testaddressee testaddresseelist testaddressfmt kabcargl testaddresslineedit + +testtdeabc_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testtdeabc_SOURCES = testkabc.cpp + +testaddressee_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testaddressee_SOURCES = testaddressee.cpp + +testaddresseelist_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testaddresseelist_SOURCES = testaddresseelist.cpp + +testaddressfmt_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testaddressfmt_SOURCES = testaddressfmt.cpp + +testkabcdlg_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testkabcdlg_SOURCES = testkabcdlg.cpp + +testdistlist_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testdistlist_SOURCES = testdistlist.cpp + +testaddresslineedit_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testaddresslineedit_SOURCES = testaddresslineedit.cpp + +bigread_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +bigread_LDADD = ../libkabc.la $(top_builddir)/tdeabc/plugins/file/libtdeabc_file.la +bigread_SOURCES = bigread.cpp + +bigwrite_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +bigwrite_LDADD = ../libkabc.la $(top_builddir)/tdeabc/plugins/file/libtdeabc_file.la +bigwrite_SOURCES = bigwrite.cpp + +testdb_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testdb_SOURCES = testdb.cpp + +kabcargl_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +kabcargl_SOURCES = kabcargl.cpp + diff --git a/tdeabc/tests/bigread.cpp b/tdeabc/tests/bigread.cpp new file mode 100644 index 000000000..a2c9da070 --- /dev/null +++ b/tdeabc/tests/bigread.cpp @@ -0,0 +1,65 @@ +#include <sys/times.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "addressbook.h" +#include "vcardformat.h" +#include "plugins/file/resourcefile.h" +#if 0 +#include "resourcesql.h" +#endif + +using namespace TDEABC; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("bigread","BigReadKabc","0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + + TDEApplication app( false, false ); + + AddressBook ab; + + ResourceFile r( "my.kabc", "vcard2" ); + ab.addResource( &r ); + +#if 0 + ResourceSql rsql( &ab, "root", "kde4ever", "localhost" ); + ab.addResource( &rsql ); +#endif + + struct tms start; + + times( &start ); + +#if 0 + kdDebug() << "utime : " << int( start.tms_utime ) << endl; + kdDebug() << "stime : " << int( start.tms_stime ) << endl; + kdDebug() << "cutime: " << int( start.tms_cutime ) << endl; + kdDebug() << "cstime: " << int( start.tms_cstime ) << endl; +#endif + + kdDebug() << "Start load" << endl; + ab.load(); + kdDebug() << "Finished load" << endl; + + struct tms end; + + times( &end ); + +#if 0 + kdDebug() << "utime : " << int( end.tms_utime ) << endl; + kdDebug() << "stime : " << int( end.tms_stime ) << endl; + kdDebug() << "cutime: " << int( end.tms_cutime ) << endl; + kdDebug() << "cstime: " << int( end.tms_cstime ) << endl; +#endif + + kdDebug() << "UTime: " << int( end.tms_utime ) - int( start.tms_utime ) << endl; + kdDebug() << "STime: " << int( end.tms_stime ) - int( start.tms_stime ) << endl; + +// ab.dump(); +} diff --git a/tdeabc/tests/bigwrite.cpp b/tdeabc/tests/bigwrite.cpp new file mode 100644 index 000000000..ab7fec7cf --- /dev/null +++ b/tdeabc/tests/bigwrite.cpp @@ -0,0 +1,70 @@ +#include <sys/times.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "addressbook.h" +#include "vcardformat.h" +#include "plugins/file/resourcefile.h" + +using namespace TDEABC; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("bigwrite","BigWriteKabc","0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + + TDEApplication app( false, false ); + + AddressBook ab; + ResourceFile r( "my.kabc", "vcard" ); + ab.addResource( &r ); + + for( int i = 0; i < 5000; ++i ) { + Addressee a; + a.setGivenName( "number" + TQString::number( i ) ); + a.setFamilyName( "Name" ); + a.insertEmail( TQString::number( i ) + "@domain" ); + + ab.insertAddressee( a ); + } + printf( "\n" ); + + Ticket *t = ab.requestSaveTicket( &r ); + if ( t ) { + struct tms start; + + times( &start ); + +#if 0 + kdDebug() << "utime : " << int( start.tms_utime ) << endl; + kdDebug() << "stime : " << int( start.tms_stime ) << endl; + kdDebug() << "cutime: " << int( start.tms_cutime ) << endl; + kdDebug() << "cstime: " << int( start.tms_cstime ) << endl; +#endif + + if ( !ab.save( t ) ) { + kdDebug() << "Can't save." << endl; + } + + struct tms end; + + times( &end ); + +#if 0 + kdDebug() << "utime : " << int( end.tms_utime ) << endl; + kdDebug() << "stime : " << int( end.tms_stime ) << endl; + kdDebug() << "cutime: " << int( end.tms_cutime ) << endl; + kdDebug() << "cstime: " << int( end.tms_cstime ) << endl; +#endif + + kdDebug() << "UTime: " << int( end.tms_utime ) - int( start.tms_utime ) << endl; + kdDebug() << "STime: " << int( end.tms_stime ) - int( start.tms_stime ) << endl; + + } else { + kdDebug() << "No ticket for save." << endl; + } +} diff --git a/tdeabc/tests/kabcargl.cpp b/tdeabc/tests/kabcargl.cpp new file mode 100644 index 000000000..d3a71890e --- /dev/null +++ b/tdeabc/tests/kabcargl.cpp @@ -0,0 +1,70 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqfile.h> +#include <tqtextstream.h> +#include <tqregexp.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdecmdlineargs.h> +#include <tdeglobal.h> +#include <kstandarddirs.h> + +#include "stdaddressbook.h" + +using namespace TDEABC; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("kabcargl","Fix broken pre3.0rc3 format","0.1"); + aboutData.addAuthor("Cornelius Schumacher", 0, "[email protected]"); + + TDECmdLineArgs::init(argc,argv,&aboutData); + + TDEApplication app; + + TQString filename = StdAddressBook::fileName(); + + TQFile f( filename ); + if ( !f.open( IO_ReadOnly ) ) { + kdDebug() << "Error opening file '" << filename << "' for reading." << endl; + return 1; + } + + TQTextStream t( &f ); + t.setEncoding(TQTextStream::UnicodeUTF8); + TQString text = t.read(); + f.close(); + + text = TQString::fromUtf8( text.local8Bit() ); + text.replace( "\n", "\r\n" ); + + if ( !f.open( IO_WriteOnly ) ) { + kdDebug() << "Error opening file '" << filename << "' for writing." << endl; + return 1; + } + + TQTextStream t2( &f ); + t2.setEncoding(TQTextStream::UnicodeUTF8); + t2 << text; + f.close(); +} diff --git a/tdeabc/tests/testaddressee.cpp b/tdeabc/tests/testaddressee.cpp new file mode 100644 index 000000000..96989a06d --- /dev/null +++ b/tdeabc/tests/testaddressee.cpp @@ -0,0 +1,57 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> +#include <kstandarddirs.h> + +#include "addressbook.h" +#include "plugins/file/resourcefile.h" +#include "formats/binaryformat.h" +#include "vcardformat.h" +#include "phonenumber.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + { "save", "", 0 }, + { "number", "", 0 }, + TDECmdLineLastOption +}; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testaddressee","TestAddressee","0.1"); + TDECmdLineArgs::init(argc, argv, &aboutData); + TDECmdLineArgs::addCmdLineOptions(options); + + TDEApplication app; + TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs(); + + kdDebug() << "Creating a" << endl; + Addressee a; + + kdDebug() << "tick1" << endl; + a.setGivenName("Hans"); + kdDebug() << "tick2" << endl; + a.setPrefix("Dr."); + + kdDebug() << "Creating b" << endl; + Addressee b( a ); + + kdDebug() << "tack1" << endl; + a.setFamilyName("Wurst"); + kdDebug() << "tack2" << endl; + a.setNickName("hansi"); + + kdDebug() << "Creating c" << endl; + Addressee c = a; + + kdDebug() << "tock1" << endl; + c.setGivenName("Eberhard"); + + a.dump(); + b.dump(); + c.dump(); +} diff --git a/tdeabc/tests/testaddresseelist.cpp b/tdeabc/tests/testaddresseelist.cpp new file mode 100644 index 000000000..12964a687 --- /dev/null +++ b/tdeabc/tests/testaddresseelist.cpp @@ -0,0 +1,196 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> +#include <kstandarddirs.h> + +#include "addressbook.h" +#include "addresseelist.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + { "save", "", 0 }, + { "number", "", 0 }, + TDECmdLineLastOption +}; + +int main(int /*argc*/,char /* **argv*/) +{ +/* TDEAboutData aboutData("testaddresseelist","TestAddresseeList","0.1"); + TDECmdLineArgs::init(argc, argv, &aboutData); + TDECmdLineArgs::addCmdLineOptions(options); + + TDEApplication app; + TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs(); */ + + kdDebug() << "Creating addressees" << endl; + Addressee a, b, c, d, e, f; + a.setGivenName ("Peter"); + a.setFamilyName("Pan"); + a.setFormattedName("Pan, Peter"); + a.setUid("Asdf"); + b.setGivenName ("Phileas"); + b.setFamilyName("Fogg"); + b.setFormattedName("Fogg, Phileas"); + b.setUid("Rsdf"); + c.setGivenName ("Jim"); + c.setFamilyName("Hawkins"); + c.setFormattedName("Hawkins, Jim"); + c.setUid("Fhwn"); + d.setGivenName ("John"); + d.setFamilyName("Silver"); + d.setPrefix ("Long"); + d.setFormattedName("Long John Silver"); + d.setUid("Z2hk"); + e.setGivenName ("Alice"); + e.setFamilyName("Liddel"); + e.setFormattedName("Liddel, Alice"); + e.setUid("kk45"); + f.setGivenName ("Edmond"); + f.setFamilyName("Dantes"); + f.setFormattedName("Dantes, Edmond"); + f.setUid("78ze"); + + kdDebug() << "Adding to list" << endl; + AddresseeList list; + list.append(a); + list.append(b); + list.append(c); + list.append(d); + list.append(e); + list.append(f); + + list.sortBy(FamilyName); + if ( !( (*list.at(0)).uid()=="78ze" + && (*list.at(1)).uid()=="Rsdf" + && (*list.at(2)).uid()=="Fhwn" + && (*list.at(3)).uid()=="kk45" + && (*list.at(4)).uid()=="Asdf" + && (*list.at(5)).uid()=="Z2hk" + ) ) { + kdError() << "SORTING BY FAMILY NAME NOT CORRECT!" << endl; + kdDebug() << "list sorted by family name:" << endl; + list.dump(); + } else { + kdDebug() << "Sorting by family name correct." << endl; + } + list.setReverseSorting(true); + list.sort(); + if ( !( (*list.at(5)).uid()=="78ze" + && (*list.at(4)).uid()=="Rsdf" + && (*list.at(3)).uid()=="Fhwn" + && (*list.at(2)).uid()=="kk45" + && (*list.at(1)).uid()=="Asdf" + && (*list.at(0)).uid()=="Z2hk" + ) ) { + kdError() << "REVERSE SORTING BY FAMILY NAME NOT CORRECT!" << endl; + kdDebug() << "list reverse sorted by family name:" << endl; + list.dump(); + } else { + kdDebug() << "Reverse sorting by family name correct." << endl; + } + + list.setReverseSorting(false); + list.sortBy(FormattedName); + if ( !( (*list.at(0)).uid()=="78ze" + && (*list.at(1)).uid()=="Rsdf" + && (*list.at(2)).uid()=="Fhwn" + && (*list.at(3)).uid()=="kk45" + && (*list.at(4)).uid()=="Z2hk" + && (*list.at(5)).uid()=="Asdf" + ) ) { + kdError() << "SORTING BY FORMATTED NAME NOT CORRECT!" << endl; + kdDebug() << "list sorted by formatted name:" << endl; + list.dump(); + } else { + kdDebug() << "Sorting by formatted name correct." << endl; + } + list.setReverseSorting(true); + list.sort(); + if ( !( (*list.at(5)).uid()=="78ze" + && (*list.at(4)).uid()=="Rsdf" + && (*list.at(3)).uid()=="Fhwn" + && (*list.at(2)).uid()=="kk45" + && (*list.at(1)).uid()=="Z2hk" + && (*list.at(0)).uid()=="Asdf" + ) ) { + kdError() << "REVERSE SORTING BY FORMATTED NAME NOT CORRECT!" << endl; + kdDebug() << "list reverse sorted by formatted name:" << endl; + list.dump(); + } else { + kdDebug() << "Reverse sorting by formatted name correct." << endl; + } + + + list.setReverseSorting(false); + list.sortBy(Uid); + if ( !( (*list.at(0)).uid()=="78ze" + && (*list.at(1)).uid()=="Asdf" + && (*list.at(2)).uid()=="Fhwn" + && (*list.at(3)).uid()=="Rsdf" + && (*list.at(4)).uid()=="Z2hk" + && (*list.at(5)).uid()=="kk45" + ) ) { + kdError() << "SORTING BY UID NOT CORRECT!" << endl; + kdDebug() << "list sorted by Uid:" << endl; + list.dump(); + } else { + kdDebug() << "Sorting by Uid correct." << endl; + } + list.setReverseSorting(true); + list.sortBy(Uid); + if ( !( (*list.at(5)).uid()=="78ze" + && (*list.at(4)).uid()=="Asdf" + && (*list.at(3)).uid()=="Fhwn" + && (*list.at(2)).uid()=="Rsdf" + && (*list.at(1)).uid()=="Z2hk" + && (*list.at(0)).uid()=="kk45" + ) ) { + kdError() << "REVERSE SORTING BY UID NOT CORRECT!" << endl; + kdDebug() << "list sorted by Uid:" << endl; + list.dump(); + } else { + kdDebug() << "Reverse sorting by Uid correct." << endl; + } + + // zero, one or two entries might give errors in a poor sorting + // implementation + kdDebug() << "sorting empty list" << endl; + AddresseeList list2; + list2.sort(); + + kdDebug() << "sorting one entry list" << endl; + list2.append(a); + list2.sort(); + + kdDebug() << "sorting two entry list" << endl; + list2.append(f); + list2.setReverseSorting(false); + list2.sort(); + if ( !( (*list2.at(0)).uid()=="78ze" + && (*list2.at(1)).uid()=="Asdf" + ) ) { + kdError() << "SORTING BY FORMATTED NAME IN A TWO ENTRY LIST NOT CORRECT!" << endl; + kdDebug() << "list sorted by formatted name, two entries:" << endl; + list2.dump(); + } else { + kdDebug() << "Sorting by FormattedName in a two entry list correct." << endl; + } + list2.setReverseSorting(true); + list2.sort(); + if ( !( (*list2.at(1)).uid()=="78ze" + && (*list2.at(0)).uid()=="Asdf" + ) ) { + kdError() << "REVERSE SORTING BY FORMATTED NAME IN A TWO ENTRY LIST NOT CORRECT!" << endl; + kdDebug() << "list reverse sorted by formatted name, two entries:" << endl; + list2.dump(); + } else { + kdDebug() << "Reverse sorting by FormattedName in a two entry list correct." << endl; + } + +} + + diff --git a/tdeabc/tests/testaddressfmt.cpp b/tdeabc/tests/testaddressfmt.cpp new file mode 100644 index 000000000..79545f6f9 --- /dev/null +++ b/tdeabc/tests/testaddressfmt.cpp @@ -0,0 +1,63 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> +#include <kstandarddirs.h> + +#include "addressbook.h" +#include "address.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + { "save", "", 0 }, + { "number", "", 0 }, + TDECmdLineLastOption +}; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testaddressfmt","TestAddressFormat","0.1"); + TDECmdLineArgs::init(argc, argv, &aboutData); + TDECmdLineArgs::addCmdLineOptions(options); + + TDEApplication app; + + Address a; + a.setStreet("Lummerlandstr. 1"); + a.setPostalCode("12345"); + a.setLocality("Lummerstadt"); + a.setCountry ("Germany"); + + Address b; + b.setStreet("457 Foobar Ave"); + b.setPostalCode("1A2B3C"); + b.setLocality("Nervousbreaktown"); + b.setRegion("DC"); + b.setCountry("United States of America"); + + Address c; + c.setStreet("Lummerlandstr. 1"); + c.setPostalCode("12345"); + c.setLocality("Lummerstadt"); + c.setCountry ("Deutschland"); + + Address d; + d.setStreet("Lummerlandstr. 1"); + d.setPostalCode("12345"); + d.setLocality("Lummerstadt"); + d.setCountry (""); + + tqDebug( "-------------------------------------\nShould have german address formatting, local country formatting\n" ); + tqDebug( a.formattedAddress("Jim Knopf").latin1() ); + tqDebug( "-------------------------------------\nShould have US address formatting, local country formatting\n" ); + tqDebug( b.formattedAddress("Huck Finn").latin1() ); + tqDebug( "-------------------------------------\nShould have german address formatting, local country formatting\n" ); + tqDebug( c.formattedAddress("Jim Knopf").latin1() ); + tqDebug( "-------------------------------------\nShould have local address formatting, local country formatting\n" ); + tqDebug( d.formattedAddress("Jim Knopf").latin1() ); +} + + diff --git a/tdeabc/tests/testaddresslineedit.cpp b/tdeabc/tests/testaddresslineedit.cpp new file mode 100644 index 000000000..80bd311da --- /dev/null +++ b/tdeabc/tests/testaddresslineedit.cpp @@ -0,0 +1,29 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "addresslineedit.h" + +using namespace TDEABC; + +int main( int argc,char **argv ) +{ + TDEAboutData aboutData( "testaddresslineedit", + I18N_NOOP( "Test Address LineEdit" ), "0.1" ); + TDECmdLineArgs::init( argc, argv, &aboutData ); + + TDEApplication app; + + AddressLineEdit *lineEdit = new AddressLineEdit( 0 ); + + lineEdit->show(); + app.setMainWidget( lineEdit ); + + TQObject::connect( &app, TQT_SIGNAL( lastWindowClosed() ), &app, TQT_SLOT( quit() ) ); + + app.exec(); + + delete lineEdit; +} diff --git a/tdeabc/tests/testdb.cpp b/tdeabc/tests/testdb.cpp new file mode 100644 index 000000000..c6b02c14a --- /dev/null +++ b/tdeabc/tests/testdb.cpp @@ -0,0 +1,33 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "addressbook.h" +#include "vcardformat.h" +#include "resourcesql.h" + +using namespace TDEABC; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testdb","TestKabcDB","0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + +// TDEApplication app( false, false ); + TDEApplication app; + + AddressBook ab; + + ResourceSql r( &ab, "root", "kde4ever", "localhost" ); + if ( ! r.open() ) { + kdDebug() << "Failed to open resource." << endl; + } + + r.load( &ab ); + + r.close(); + + ab.dump(); +} diff --git a/tdeabc/tests/testdistlist.cpp b/tdeabc/tests/testdistlist.cpp new file mode 100644 index 000000000..833dca84e --- /dev/null +++ b/tdeabc/tests/testdistlist.cpp @@ -0,0 +1,59 @@ +#include <tqwidget.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "stdaddressbook.h" + +#include "distributionlisteditor.h" +#include "distributionlist.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + {"list <listname>", I18N_NOOP("Show distribution list with name <listname>"), 0}, + TDECmdLineLastOption +}; + + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testdistlist",I18N_NOOP("Test Distribution Lists"),"0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + if (args->isSet("list")) { + TQString name = args->getOption("list"); + + DistributionListManager *manager = + new DistributionListManager( StdAddressBook::self() ); + manager->load(); + DistributionList *list = manager->list( name ); + if ( !list ) { + kdDebug() << "No list with name '" << name << "'" << endl; + return 1; + } else { + kdDebug() << "RESULT: " << list->emails().join(", ") << endl; + return 0; + } + } + + DistributionListEditor *editor = + new DistributionListEditor( StdAddressBook::self(), 0 ); + + editor->show(); + app.setMainWidget(editor); + + TQObject::connect( &app, TQT_SIGNAL( lastWindowClosed() ), &app, TQT_SLOT( quit() ) ); + + app.exec(); + + delete editor; +} diff --git a/tdeabc/tests/testkabc.cpp b/tdeabc/tests/testkabc.cpp new file mode 100644 index 000000000..2cc7effb4 --- /dev/null +++ b/tdeabc/tests/testkabc.cpp @@ -0,0 +1,62 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> +#include <kstandarddirs.h> + +#include <tqfile.h> +#include <tqimage.h> + +#include "geo.h" +#include "secrecy.h" +#include "stdaddressbook.h" +#include "timezone.h" +#include "key.h" +#include "agent.h" +#include "vcardconverter.h" + +using namespace TDEABC; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testkabc",I18N_NOOP("TestKabc"),"0.1"); + TDECmdLineArgs::init(argc, argv, &aboutData); + + TDEApplication app( false, false ); + AddressBook *ab = StdAddressBook::self(); + +#define READ + +#ifdef READ + AddressBook::Iterator it; + for ( it = ab->begin(); it != ab->end(); ++it ) { + TQString vcard; + VCardConverter converter; + converter.addresseeToVCard( *it, vcard ); + kdDebug() << "card=" << vcard << endl; + } +#else + Addressee addr; + + addr.setGivenName("Tobias"); + addr.setFamilyName("Koenig"); + + + Picture pic; + TQImage img; + img.load("/home/tobias/test.png"); +/* + pic.setData(img); + pic.setType(TQImage::imageFormat("/home/tobias/test.png")); +*/ + pic.setUrl("http://www.mypict.de"); + addr.setLogo( pic ); + + ab->insertAddressee( addr ); + + StdAddressBook::save(); +#endif + + return 0; +} diff --git a/tdeabc/tests/testkabcdlg.cpp b/tdeabc/tests/testkabcdlg.cpp new file mode 100644 index 000000000..7b4b18e3e --- /dev/null +++ b/tdeabc/tests/testkabcdlg.cpp @@ -0,0 +1,45 @@ +#include <tqwidget.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include "addresseedialog.h" + +using namespace TDEABC; + +static const TDECmdLineOptions options[] = +{ + {"multiple", I18N_NOOP("Allow selection of multiple addressees"), 0}, + TDECmdLineLastOption +}; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testkabcdlg",I18N_NOOP("TestKabc"),"0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + if (args->isSet("multiple")) { + Addressee::List al = AddresseeDialog::getAddressees( 0 ); + Addressee::List::ConstIterator it; + kdDebug() << "Selected Addressees:" << endl; + for( it = al.begin(); it != al.end(); ++it ) { + kdDebug() << " " << (*it).fullEmail() << endl; + } + } else { + Addressee a = AddresseeDialog::getAddressee( 0 ); + + if ( !a.isEmpty() ) { + kdDebug() << "Selected Addressee:" << endl; + a.dump(); + } else { + kdDebug() << "No Addressee selected." << endl; + } + } +} diff --git a/tdeabc/tests/testldapclient.cpp b/tdeabc/tests/testldapclient.cpp new file mode 100644 index 000000000..71a34ee5e --- /dev/null +++ b/tdeabc/tests/testldapclient.cpp @@ -0,0 +1,161 @@ +/* This file is part of the KDE project + Copyright (C) 2005 David Faure <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "testldapclient.h" + +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdecmdlineargs.h> + +#include <tqeventloop.h> + +#include <assert.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) +{ + TDEApplication::disableAutoDcopRegistration(); + TDECmdLineArgs::init(argc,argv,"testldapclient", 0, 0, 0, 0); + TDEApplication app; + + TestLDAPClient test; + test.setup(); + test.runAll(); + test.cleanup(); + kdDebug() << "All tests OK." << endl; + return 0; +} + +void TestLDAPClient::setup() +{ +} + +void TestLDAPClient::runAll() +{ + testIntevation(); +} + +bool TestLDAPClient::check(const TQString& txt, TQString a, TQString b) +{ + if (a.isEmpty()) + a = TQString::null; + if (b.isEmpty()) + b = TQString::null; + if (a == b) { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; + } + else { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; + cleanup(); + exit(1); + } + return true; +} + +void TestLDAPClient::cleanup() +{ + mClient = 0; +} + +void TestLDAPClient::testIntevation() +{ + kdDebug() << k_funcinfo << endl; + mClient = new LdapClient( this ); + + mClient->setHost( "ca.intevation.de" ); + mClient->setPort( "389" ); + mClient->setBase( "o=Intevation GmbH,c=de" ); + + // Same list as in kaddressbook's ldapsearchdialog + TQStringList attrs; + attrs << "l" << "Company" << "co" << "department" << "description" << "mail" << "facsimileTelephoneNumber" << "cn" << "homePhone" << "mobile" << "o" << "pager" << "postalAddress" << "st" << "street" << "title" << "uid" << "telephoneNumber" << "postalCode" << "objectClass"; + // the list from ldapclient.cpp + //attrs << "cn" << "mail" << "givenname" << "sn" << "objectClass"; + mClient->setAttrs( attrs ); + + // Taken from LdapSearch + //TQString mSearchText = TQString::fromUtf8( "Till" ); + //TQString filter = TQString( "&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))(|(cn=%1*)(mail=%2*)(givenName=%3*)(sn=%4*))" ) + // .arg( mSearchText ).arg( mSearchText ).arg( mSearchText ).arg( mSearchText ); + + // For some reason a fromUtf8 broke the search for me (no results). + // But this certainly looks fishy, it might break on non-utf8 systems. + TQString filter = "&(|(objectclass=person)(objectclass=groupofnames)(mail=*))(|(cn=*�gypten MDK*)(sn=*�gypten MDK*))"; + + connect( mClient, TQT_SIGNAL( result( const TDEABC::LdapObject& ) ), + this, TQT_SLOT( slotLDAPResult( const TDEABC::LdapObject& ) ) ); + connect( mClient, TQT_SIGNAL( done() ), + this, TQT_SLOT( slotLDAPDone() ) ); + connect( mClient, TQT_SIGNAL( error( const TQString& ) ), + this, TQT_SLOT( slotLDAPError( const TQString& ) ) ); + mClient->startQuery( filter ); + kapp->eventLoop()->enterLoop(); + delete mClient; mClient = 0; +} + +// from kaddressbook... ugly though... +static TQString asUtf8( const TQByteArray &val ) +{ + if ( val.isEmpty() ) + return TQString::null; + + const char *data = val.data(); + + //TQString::fromUtf8() bug workaround + if ( data[ val.size() - 1 ] == '\0' ) + return TQString::fromUtf8( data, val.size() - 1 ); + else + return TQString::fromUtf8( data, val.size() ); +} + +static TQString join( const TDEABC::LdapAttrValue& lst, const TQString& sep ) +{ + TQString res; + bool already = false; + for ( TDEABC::LdapAttrValue::ConstIterator it = lst.begin(); it != lst.end(); ++it ) { + if ( already ) + res += sep; + already = TRUE; + res += asUtf8( *it ); + } + return res; +} + +void TestLDAPClient::slotLDAPResult( const TDEABC::LdapObject& obj ) +{ + TQString cn = join( obj.attrs[ "cn" ], ", " ); + kdDebug() << " cn:" << cn << endl; + assert( !obj.attrs[ "mail" ].isEmpty() ); + TQString mail = join( obj.attrs[ "mail" ], ", " ); + kdDebug() << " mail:" << mail << endl; + assert( mail.contains( '@' ) ); +} + +void TestLDAPClient::slotLDAPError( const TQString& err ) +{ + kdDebug() << k_funcinfo << err << endl; + ::exit( 1 ); +} + +void TestLDAPClient::slotLDAPDone() +{ + kdDebug() << k_funcinfo << endl; + kapp->eventLoop()->exitLoop(); +} + +#include "testldapclient.moc" diff --git a/tdeabc/tests/testldapclient.h b/tdeabc/tests/testldapclient.h new file mode 100644 index 000000000..502115b07 --- /dev/null +++ b/tdeabc/tests/testldapclient.h @@ -0,0 +1,51 @@ +/* This file is part of the KDE project + Copyright (C) 2005 David Faure <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef TESTLDAPCLIENT_H +#define TESTLDAPCLIENT_H + +#include <tqobject.h> + +#include "../ldapclient.h" +typedef TDEABC::LdapClient LdapClient; + +class TestLDAPClient : public TQObject +{ + Q_OBJECT + +public: + TestLDAPClient() {} + void setup(); + void runAll(); + void cleanup(); + + // tests + void testIntevation(); + +private slots: + void slotLDAPResult( const TDEABC::LdapObject& ); + void slotLDAPError( const TQString& ); + void slotLDAPDone(); + +private: + bool check(const TQString& txt, TQString a, TQString b); + + LdapClient* mClient; +}; + +#endif diff --git a/tdeabc/tests/testlock.cpp b/tdeabc/tests/testlock.cpp new file mode 100644 index 000000000..7f3cf634b --- /dev/null +++ b/tdeabc/tests/testlock.cpp @@ -0,0 +1,206 @@ +/* + This file is part of libkabc. + + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "testlock.h" + +#include "stdaddressbook.h" + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> +#include <kdirwatch.h> + +#include <tdemessagebox.h> +#include <kdialog.h> + +#include <tqwidget.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqlistview.h> +#include <tqdir.h> + +#include <iostream> + +#include <sys/types.h> +#include <unistd.h> + +using namespace TDEABC; + +LockWidget::LockWidget( const TQString &identifier ) +{ + TQVBoxLayout *topLayout = new TQVBoxLayout( this ); + topLayout->setMargin( KDialog::marginHint() ); + topLayout->setSpacing( KDialog::spacingHint() ); + + if ( identifier.isEmpty() ) { + mLock = 0; + } else { + mLock = new Lock( identifier ); + + int pid = getpid(); + + TQLabel *pidLabel = new TQLabel( "Process ID: " + TQString::number( pid ), + this ); + topLayout->addWidget( pidLabel ); + + TQHBoxLayout *identifierLayout = new TQHBoxLayout( topLayout ); + + TQLabel *resourceLabel = new TQLabel( "Identifier:", this ); + identifierLayout->addWidget( resourceLabel ); + + TQLabel *resourceIdentifier = new TQLabel( identifier, this ); + identifierLayout->addWidget( resourceIdentifier ); + + mStatus = new TQLabel( "Status: Unlocked", this ); + topLayout->addWidget( mStatus ); + + TQPushButton *button = new TQPushButton( "Lock", this ); + topLayout->addWidget( button ); + connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( lock() ) ); + + button = new TQPushButton( "Unlock", this ); + topLayout->addWidget( button ); + connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( unlock() ) ); + } + + mLockView = new TQListView( this ); + topLayout->addWidget( mLockView ); + mLockView->addColumn( "Lock File" ); + mLockView->addColumn( "PID" ); + mLockView->addColumn( "Locking App" ); + + updateLockView(); + + TQPushButton *quitButton = new TQPushButton( "Quit", this ); + topLayout->addWidget( quitButton ); + connect( quitButton, TQT_SIGNAL( clicked() ), TQT_SLOT( close() ) ); + + KDirWatch *watch = KDirWatch::self(); + connect( watch, TQT_SIGNAL( dirty( const TQString & ) ), + TQT_SLOT( updateLockView() ) ); + connect( watch, TQT_SIGNAL( created( const TQString & ) ), + TQT_SLOT( updateLockView() ) ); + connect( watch, TQT_SIGNAL( deleted( const TQString & ) ), + TQT_SLOT( updateLockView() ) ); + watch->addDir( Lock::locksDir() ); + watch->startScan(); +} + +LockWidget::~LockWidget() +{ + delete mLock; +} + +void LockWidget::updateLockView() +{ + mLockView->clear(); + + TQDir dir( Lock::locksDir() ); + + TQStringList files = dir.entryList( "*.lock" ); + + TQStringList::ConstIterator it; + for( it = files.begin(); it != files.end(); ++it ) { + if ( *it == "." || *it == ".." ) continue; + + TQString app; + int pid; + if ( !Lock::readLockFile( dir.filePath( *it ), pid, app ) ) { + kdWarning() << "Unable to open lock file '" << *it << "'" << endl; + } else { + new TQListViewItem( mLockView, *it, TQString::number( pid ), app ); + } + } +} + +void LockWidget::lock() +{ + if ( !mLock->lock() ) { + KMessageBox::sorry( this, mLock->error() ); + } else { + mStatus->setText( "Status: Locked" ); + } +} + +void LockWidget::unlock() +{ + if ( !mLock->unlock() ) { + KMessageBox::sorry( this, mLock->error() ); + } else { + mStatus->setText( "Status: Unlocked" ); + } +} + + +static const TDECmdLineOptions options[] = +{ + { "a", 0, 0 }, + { "addressbook", "Standard address book", 0 }, + { "d", 0, 0 }, + { "diraddressbook", "Standard address book directory resource", 0 }, + { "+identifier", "Identifier of resource to be locked, e.g. filename", 0 }, + TDECmdLineLastOption +}; + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testlock",I18N_NOOP("Test libkabc Lock"),"0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TQString identifier; + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + if ( args->count() == 1 ) { + identifier = args->arg( 0 ); + } else if ( args->count() != 0 ) { + std::cerr << "Usage: testlock <identifier>" << std::endl; + return 1; + } + + if ( args->isSet( "addressbook" ) ) { + if ( args->count() == 1 ) { + std::cerr << "Ignoring resource identifier" << std::endl; + } + identifier = StdAddressBook::fileName(); + } + + if ( args->isSet( "diraddressbook" ) ) { + if ( args->count() == 1 ) { + std::cerr << "Ignoring resource identifier" << std::endl; + } + identifier = StdAddressBook::directoryName(); + } + + LockWidget mainWidget( identifier ); + + kapp->setMainWidget( &mainWidget ); + mainWidget.show(); + + return app.exec(); +} + +#include "testlock.moc" diff --git a/tdeabc/tests/testlock.h b/tdeabc/tests/testlock.h new file mode 100644 index 000000000..01d07fc47 --- /dev/null +++ b/tdeabc/tests/testlock.h @@ -0,0 +1,51 @@ +/* + This file is part of libkabc. + + Copyright (c) 2003 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_TESTLOCK_H +#define KABC_TESTLOCK_H + +#include "lock.h" + +#include <tqwidget.h> + +class TQLabel; +class TQListView; + +class KABC_EXPORT LockWidget : public TQWidget +{ + Q_OBJECT + public: + LockWidget( const TQString &identifier ); + ~LockWidget(); + + protected slots: + void lock(); + void unlock(); + + void updateLockView(); + + private: + TDEABC::Lock *mLock; + + TQLabel *mStatus; + TQListView *mLockView; +}; + +#endif diff --git a/tdeabc/timezone.cpp b/tdeabc/timezone.cpp new file mode 100644 index 000000000..7b773db63 --- /dev/null +++ b/tdeabc/timezone.cpp @@ -0,0 +1,85 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqdatastream.h> + +#include "timezone.h" + +using namespace TDEABC; + +TimeZone::TimeZone() : + mOffset( 0 ), mValid( false ) +{ +} + +TimeZone::TimeZone( int offset ) : + mOffset( offset ), mValid( true ) +{ +} + +void TimeZone::setOffset( int offset ) +{ + mOffset = offset; + mValid = true; +} + +int TimeZone::offset() const +{ + return mOffset; +} + +bool TimeZone::isValid() const +{ + return mValid; +} + +bool TimeZone::operator==( const TimeZone &t ) const +{ + if ( !t.isValid() && !isValid() ) return true; + if ( !t.isValid() || !isValid() ) return false; + if ( t.mOffset == mOffset ) return true; + return false; +} + +bool TimeZone::operator!=( const TimeZone &t ) const +{ + if ( !t.isValid() && !isValid() ) return false; + if ( !t.isValid() || !isValid() ) return true; + if ( t.mOffset != mOffset ) return true; + return false; +} + +TQString TimeZone::asString() const +{ + return TQString::number( mOffset ); +} + +TQDataStream &TDEABC::operator<<( TQDataStream &s, const TimeZone &zone ) +{ + return s << zone.mOffset; +} + +TQDataStream &TDEABC::operator>>( TQDataStream &s, TimeZone &zone ) +{ + s >> zone.mOffset; + zone.mValid = true; + + return s; +} diff --git a/tdeabc/timezone.h b/tdeabc/timezone.h new file mode 100644 index 000000000..b53df7728 --- /dev/null +++ b/tdeabc/timezone.h @@ -0,0 +1,89 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_TIMEZONE_H +#define KABC_TIMEZONE_H + +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace TDEABC { + +/** + * @short Time zone information. + * + * This class stores information about a time zone. + */ +class KABC_EXPORT TimeZone +{ + friend KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const TimeZone & ); + friend KABC_EXPORT TQDataStream &operator>>( TQDataStream &, TimeZone & ); + +public: + + /** + * Construct invalid time zone. + */ + TimeZone(); + + /** + * Construct time zone. + * + * @param offset Offset in minutes relative to UTC. + */ + TimeZone( int offset ); + + /** + * Set time zone offset relative to UTC. + * + * @param offset Offset in minutes. + */ + void setOffset( int offset ); + + /** + * Return offset in minutes relative to UTC. + */ + int offset() const; + + /** + * Return, if this time zone object is valid. + */ + bool isValid() const; + + bool operator==( const TimeZone & ) const; + bool operator!=( const TimeZone & ) const; + + /** + * Return string representation of time zone offset. + */ + TQString asString() const; + +private: + int mOffset; // Offset in minutes + + bool mValid; +}; + +KABC_EXPORT TQDataStream &operator<<( TQDataStream &, const TimeZone & ); +KABC_EXPORT TQDataStream &operator>>( TQDataStream &, TimeZone & ); + +} +#endif diff --git a/tdeabc/vcard/AdrParam.cpp b/tdeabc/vcard/AdrParam.cpp new file mode 100644 index 000000000..5ad56f4fb --- /dev/null +++ b/tdeabc/vcard/AdrParam.cpp @@ -0,0 +1,126 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardRToken.h> +#include <VCardAdrParam.h> +#include <VCardParam.h> + +using namespace VCARD; + +AdrParam::AdrParam() + : Param() +{ +} + +AdrParam::AdrParam(const AdrParam & x) + : Param(x), + adrTypeList_ (x.adrTypeList_) +{ +} + +AdrParam::AdrParam(const TQCString & s) + : Param(s) +{ +} + + AdrParam & +AdrParam::operator = (AdrParam & x) +{ + if (*this == x) return *this; + + adrTypeList_ = x.adrTypeList(); + textParam_ = x.textParam(); + + Param::operator = (x); + return *this; +} + + AdrParam & +AdrParam::operator = (const TQCString & s) +{ + Param::operator = (s); + + adrTypeList_.clear(); + textParam_.truncate(0); + + return *this; +} + + bool +AdrParam::operator == (AdrParam & x) +{ + parse(); + + if (!x.textParam().isEmpty()) + return (x.textParam_ == textParam_); + + if (x.adrTypeList().count() != adrTypeList_.count()) + return false; + + TQStrListIterator it(x.adrTypeList_); + + for (; it.current(); ++it) + if (!adrTypeList_.find(it.current())) + return false; + + return true; +} + +AdrParam::~AdrParam() +{ +} + + void +AdrParam::_parse() +{ + adrTypeList_.clear(); + + if (strRep_.left(4) != "TYPE") { + textParam_ = strRep_; + return; + } + + if (!strRep_.contains('=')) + return; + + RTokenise(strRep_, ",", adrTypeList_); +} + + void +AdrParam::_assemble() +{ + if (!textParam_.isEmpty()) { + strRep_ = textParam_; + return; + } + + TQStrListIterator it(adrTypeList_); + + for (; it.current(); ++it) { + + strRep_ += it.current(); + + if (it.current() != adrTypeList_.last()) + strRep_ += ','; + } +} diff --git a/tdeabc/vcard/AdrValue.cpp b/tdeabc/vcard/AdrValue.cpp new file mode 100644 index 000000000..535ba6980 --- /dev/null +++ b/tdeabc/vcard/AdrValue.cpp @@ -0,0 +1,140 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardRToken.h> +#include <VCardAdrValue.h> +#include <VCardValue.h> +#include <VCardDefines.h> + +using namespace VCARD; + +AdrValue::AdrValue() + : Value() +{ +} + +AdrValue::AdrValue(const AdrValue & x) + : Value(x), + poBox_ (x.poBox_), + extAddress_ (x.extAddress_), + street_ (x.street_), + locality_ (x.locality_), + region_ (x.region_), + postCode_ (x.postCode_), + countryName_ (x.countryName_) +{ +} + +AdrValue::AdrValue(const TQCString & s) + : Value(s) +{ +} + + AdrValue & +AdrValue::operator = (AdrValue & x) +{ + if (*this == x) return *this; + + poBox_ = x.poBox_; + extAddress_ = x.extAddress_; + street_ = x.street_; + locality_ = x.locality_; + region_ = x.region_; + postCode_ = x.postCode_; + countryName_ = x.countryName_; + + Value::operator = (x); + return *this; +} + + AdrValue & +AdrValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +AdrValue::operator == (AdrValue & x) +{ + parse(); + x.parse(); + + return ( + poBox_ == x.poBox_ && + extAddress_ == x.extAddress_ && + street_ == x.street_ && + locality_ == x.locality_ && + region_ == x.region_ && + postCode_ == x.postCode_ && + countryName_ == x.countryName_); +} + +AdrValue::~AdrValue() +{ +} + + AdrValue * +AdrValue::clone() +{ + return new AdrValue( *this ); +} + + void +AdrValue::_parse() +{ + vDebug("AdrValue::_parse()"); + + TQStrList l; + RTokenise(strRep_, ";", l); + + for (unsigned int i = 0; i < l.count(); i++) { + + switch (i) { + + case 0: poBox_ = l.at(0); break; + case 1: extAddress_ = l.at(1); break; + case 2: street_ = l.at(2); break; + case 3: locality_ = l.at(3); break; + case 4: region_ = l.at(4); break; + case 5: postCode_ = l.at(5); break; + case 6: countryName_ = l.at(6); break; + default: break; + } + } +} + + void +AdrValue::_assemble() +{ + vDebug("AdrValue::_assemble"); + + strRep_ = poBox_; + strRep_ += ";" + extAddress_; + strRep_ += ";" + street_; + strRep_ += ";" + locality_; + strRep_ += ";" + region_; + strRep_ += ";" + postCode_; + strRep_ += ";" + countryName_; +} + diff --git a/tdeabc/vcard/AgentParam.cpp b/tdeabc/vcard/AgentParam.cpp new file mode 100644 index 000000000..9e4531b02 --- /dev/null +++ b/tdeabc/vcard/AgentParam.cpp @@ -0,0 +1,103 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardAgentParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +AgentParam::AgentParam() + : Param() +{ +} + +AgentParam::AgentParam(const AgentParam & x) + : Param(x), + refer_ (x.refer_), + uri_ (x.uri_) +{ +} + +AgentParam::AgentParam(const TQCString & s) + : Param(s) +{ +} + + AgentParam & +AgentParam::operator = (AgentParam & x) +{ + if (*this == x) return *this; + + refer_ = x.refer_; + uri_ = x.uri_; + + Param::operator = (x); + return *this; +} + + AgentParam & +AgentParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +AgentParam::operator == (AgentParam & x) +{ + parse(); + + if (refer_) + return (x.refer() && uri_ == x.uri_); + + return !x.refer(); +} + +AgentParam::~AgentParam() +{ +} + + void +AgentParam::_parse() +{ + if (strRep_.isEmpty()) { + refer_ = false; + return; + } + + refer_ = true; + uri_ = strRep_; +} + + void +AgentParam::_assemble() +{ + if (!refer_) { + strRep_.truncate(0); + return; + } + + strRep_ = uri_.asString(); + return; +} diff --git a/tdeabc/vcard/AgentValue.cpp b/tdeabc/vcard/AgentValue.cpp new file mode 100644 index 000000000..7d356f8d7 --- /dev/null +++ b/tdeabc/vcard/AgentValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardAgentValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +AgentValue::AgentValue() + : Value() +{ +} + +AgentValue::AgentValue(const AgentValue & x) + : Value(x) +{ +} + +AgentValue::AgentValue(const TQCString & s) + : Value(s) +{ +} + + AgentValue & +AgentValue::operator = (AgentValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + AgentValue & +AgentValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +AgentValue::operator == (AgentValue & x) +{ + x.parse(); + return false; +} + +AgentValue::~AgentValue() +{ +} + + void +AgentValue::_parse() +{ +} + + void +AgentValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/CMakeLists.txt b/tdeabc/vcard/CMakeLists.txt new file mode 100644 index 000000000..8ad988434 --- /dev/null +++ b/tdeabc/vcard/CMakeLists.txt @@ -0,0 +1,40 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include/generated + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdecore +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### vcard ##################################### + +set( target vcard ) + +set( ${target}_SRCS + vCard-all.cpp +) + +tde_add_library( ${target} SHARED + SOURCES ${${target}_SRCS} + VERSION 0.0.0 + LINK tdecore-shared + DESTINATION ${LIB_INSTALL_DIR} +) diff --git a/tdeabc/vcard/ClassValue.cpp b/tdeabc/vcard/ClassValue.cpp new file mode 100644 index 000000000..21417f87b --- /dev/null +++ b/tdeabc/vcard/ClassValue.cpp @@ -0,0 +1,120 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardClassValue.h> + +#include <VCardValue.h> + +#include <kdebug.h> + +using namespace VCARD; + +ClassValue::ClassValue() + : Value() +{ +} + +ClassValue::ClassValue(const ClassValue & x) + : Value(x), + classType_(x.classType_) +{ +} + +ClassValue::ClassValue(const TQCString & s) + : Value(s) +{ +} + + ClassValue & +ClassValue::operator = (ClassValue & x) +{ + if (*this == x) return *this; + x.parse(); + + classType_ = x.classType_; + + Value::operator = (x); + return *this; +} + + ClassValue & +ClassValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +ClassValue::operator == (ClassValue & x) +{ + x.parse(); + return ( classType_ == x.classType_ ); +} + +ClassValue::~ClassValue() +{ +} + + ClassValue * +ClassValue::clone() +{ + return new ClassValue( *this ); +} + + void +ClassValue::_parse() +{ + if (tqstricmp(strRep_, "PUBLIC") == 0) + classType_ = Public; + + else if (tqstricmp(strRep_, "PRIVATE") == 0) + classType_ = Private; + + else if (tqstricmp(strRep_, "CONFIDENTIAL") == 0) + classType_ = Confidential; + + else classType_ = Other; +} + + void +ClassValue::_assemble() +{ + switch (classType_) { + + case Public: + strRep_ = "PUBLIC"; + break; + + case Private: + strRep_ = "PRIVATE"; + break; + + case Confidential: + strRep_ = "CONFIDENTIAL"; + break; + + default: + break; + } +} + diff --git a/tdeabc/vcard/ContentLine.cpp b/tdeabc/vcard/ContentLine.cpp new file mode 100644 index 000000000..52bcdf4f5 --- /dev/null +++ b/tdeabc/vcard/ContentLine.cpp @@ -0,0 +1,302 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqcstring.h> +#include <tqstrlist.h> +#include <tqregexp.h> + +#include <kdebug.h> + +#include <VCardAdrParam.h> +#include <VCardAgentParam.h> +#include <VCardDateParam.h> +#include <VCardEmailParam.h> +#include <VCardImageParam.h> +#include <VCardSourceParam.h> +#include <VCardTelParam.h> +#include <VCardTextBinParam.h> +#include <VCardTextParam.h> + +#include <VCardAdrValue.h> +#include <VCardAgentValue.h> +#include <VCardDateValue.h> +#include <VCardImageValue.h> +#include <VCardTextValue.h> +#include <VCardTextBinValue.h> +#include <VCardLangValue.h> +#include <VCardNValue.h> +#include <VCardURIValue.h> +#include <VCardSoundValue.h> +#include <VCardClassValue.h> +#include <VCardFloatValue.h> +#include <VCardOrgValue.h> +#include <VCardTelValue.h> +#include <VCardTextListValue.h> +#include <VCardUTCValue.h> +#include <VCardGeoValue.h> + +#include <VCardRToken.h> +#include <VCardContentLine.h> + +#include <VCardEntity.h> +#include <VCardEnum.h> +#include <VCardDefines.h> + +using namespace VCARD; + +ContentLine::ContentLine() + : Entity(), + value_(0), + paramType_( ParamUnknown ), + valueType_( ValueUnknown ), + entityType_( EntityUnknown ) +{ +} + +ContentLine::ContentLine(const ContentLine & x) + : Entity(x), + group_ (x.group_), + name_ (x.name_), + paramList_(x.paramList_), + value_(x.value_->clone()), + paramType_( x.paramType_ ), + valueType_( x.valueType_ ), + entityType_( x.entityType_ ) +{ +} + +ContentLine::ContentLine(const TQCString & s) + : Entity(s), + value_(0), + paramType_( ParamUnknown ), + valueType_( ValueUnknown ), + entityType_( EntityUnknown ) +{ +} + + ContentLine & +ContentLine::operator = (ContentLine & x) +{ + if (*this == x) return *this; + + paramList_ = x.paramList(); + value_ = x.value_->clone(); + + Entity::operator = (x); + return *this; +} + + ContentLine & +ContentLine::operator = (const TQCString & s) +{ + Entity::operator = (s); + delete value_; + value_ = 0; + return *this; +} + + bool +ContentLine::operator == (ContentLine & x) +{ + x.parse(); + + TQPtrListIterator<Param> it(x.paramList()); + + if (!paramList_.find(it.current())) + return false; + + return true; +} + +ContentLine::~ContentLine() +{ + delete value_; + value_ = 0; +} + + void +ContentLine::_parse() +{ + vDebug("parse"); + + // Unqote newlines + strRep_ = strRep_.replace( TQRegExp( "\\\\n" ), "\n" ); + + int split = strRep_.find(':'); + + if (split == -1) { // invalid content line + vDebug("No ':'"); + return; + } + + TQCString firstPart(strRep_.left(split)); + TQCString valuePart(strRep_.mid(split + 1)); + + split = firstPart.find('.'); + + if (split != -1) { + group_ = firstPart.left(split); + firstPart = firstPart.mid(split + 1); + } + + vDebug("Group == " + group_); + vDebug("firstPart == " + firstPart); + vDebug("valuePart == " + valuePart); + + // Now we have the group, the name and param list together and the value. + + TQStrList l; + + RTokenise(firstPart, ";", l); + + if (l.count() == 0) {// invalid - no name ! + vDebug("No name for this content line !"); + return; + } + + name_ = l.at(0); + + // Now we have the name, so the rest of 'l' is the params. + // Remove the name part. + l.remove(0u); + + entityType_ = EntityNameToEntityType(name_); + paramType_ = EntityTypeToParamType(entityType_); + + unsigned int i = 0; + + // For each parameter, create a new parameter of the correct type. + + TQStrListIterator it(l); + + for (; it.current(); ++it, i++) { + + TQCString str = *it; + + split = str.find("="); + if (split < 0 ) { + vDebug("No '=' in parameter."); + continue; + } + + TQCString paraName = str.left(split); + TQCString paraValue = str.mid(split + 1); + + TQStrList paraValues; + RTokenise(paraValue, ",", paraValues); + + TQStrListIterator it2( paraValues ); + + for(; it2.current(); ++it2) { + + Param *p = new Param; + p->setName( paraName ); + p->setValue( *it2 ); + + paramList_.append(p); + } + } + + // Create a new value of the correct type. + + valueType_ = EntityTypeToValueType(entityType_); + +// kdDebug(5710) << "valueType: " << valueType_ << endl; + + switch (valueType_) { + + case ValueSound: value_ = new SoundValue; break; + case ValueAgent: value_ = new AgentValue; break; + case ValueAddress: value_ = new AdrValue; break; + case ValueTel: value_ = new TelValue; break; + case ValueTextBin: value_ = new TextBinValue; break; + case ValueOrg: value_ = new OrgValue; break; + case ValueN: value_ = new NValue; break; + case ValueUTC: value_ = new UTCValue; break; + case ValueURI: value_ = new URIValue; break; + case ValueClass: value_ = new ClassValue; break; + case ValueFloat: value_ = new FloatValue; break; + case ValueImage: value_ = new ImageValue; break; + case ValueDate: value_ = new DateValue; break; + case ValueTextList: value_ = new TextListValue; break; + case ValueGeo: value_ = new GeoValue; break; + case ValueText: + case ValueUnknown: + default: value_ = new TextValue; break; + } + + *value_ = valuePart; +} + + void +ContentLine::_assemble() +{ + vDebug("Assemble (argl) - my name is \"" + name_ + "\""); + strRep_.truncate(0); + + TQCString line; + + if (!group_.isEmpty()) + line += group_ + '.'; + + line += name_; + + vDebug("Adding parameters"); + ParamListIterator it(paramList_); + + for (; it.current(); ++it) + line += ";" + it.current()->asString(); + + vDebug("Adding value"); + if (value_ != 0) + line += ":" + value_->asString(); + else { + vDebug("No value"); + } + + // Quote newlines + line = line.replace( TQRegExp( "\n" ), "\\n" ); + + // Fold lines longer than 72 chars + const int maxLen = 72; + uint cursor = 0; + while( line.length() > ( cursor + 1 ) * maxLen ) { + strRep_ += line.mid( cursor * maxLen, maxLen ); + strRep_ += "\r\n "; + ++cursor; + } + strRep_ += line.mid( cursor * maxLen ); +} + + void +ContentLine::clear() +{ + group_.truncate(0); + name_.truncate(0); + paramList_.clear(); + delete value_; + value_ = 0; + paramType_ = ParamUnknown; + valueType_ = ValueUnknown; + entityType_ = EntityUnknown; +} diff --git a/tdeabc/vcard/DateParam.cpp b/tdeabc/vcard/DateParam.cpp new file mode 100644 index 000000000..ffaf4b3f6 --- /dev/null +++ b/tdeabc/vcard/DateParam.cpp @@ -0,0 +1,82 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardDateParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +DateParam::DateParam() + : Param() +{ +} + +DateParam::DateParam(const DateParam & x) + : Param(x) +{ +} + +DateParam::DateParam(const TQCString & s) + : Param(s) +{ +} + + DateParam & +DateParam::operator = (DateParam & x) +{ + if (*this == x) return *this; + + Param::operator = (x); + return *this; +} + + DateParam & +DateParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +DateParam::operator == (DateParam & x) +{ + x.parse(); + + return false; +} + +DateParam::~DateParam() +{ +} + + void +DateParam::_parse() +{ +} + + void +DateParam::_assemble() +{ +} + diff --git a/tdeabc/vcard/DateValue.cpp b/tdeabc/vcard/DateValue.cpp new file mode 100644 index 000000000..9f578a158 --- /dev/null +++ b/tdeabc/vcard/DateValue.cpp @@ -0,0 +1,434 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqregexp.h> + +#include <kdebug.h> + +#include <VCardDefines.h> +#include <VCardDateValue.h> +#include <VCardValue.h> + +using namespace VCARD; + +DateValue::DateValue() + : Value() +{ + vDebug("DateValue::DateValue()"); +} + +DateValue::DateValue( + unsigned int year, + unsigned int month, + unsigned int day, + unsigned int hour, + unsigned int minute, + unsigned int second, + double secFrac, + bool zonePositive, + unsigned int zoneHour, + unsigned int zoneMinute) + : Value (), + year_ (year), + month_ (month), + day_ (day), + hour_ (hour), + minute_ (minute), + second_ (second), + zoneHour_ (zoneHour), + zoneMinute_ (zoneMinute), + secFrac_ (secFrac), + zonePositive_ (zonePositive), + hasTime_(true) +{ + parsed_ = true; + assembled_ = false; +} + +DateValue::DateValue(const TQDate & d) + : Value (), + year_ (d.year()), + month_ (d.month()), + day_ (d.day()), + hasTime_(false) +{ + parsed_ = true; + assembled_ = false; +} + +DateValue::DateValue(const TQDateTime & d) + : Value (), + year_ (d.date().year()), + month_ (d.date().month()), + day_ (d.date().day()), + hour_ (d.time().hour()), + minute_ (d.time().minute()), + second_ (d.time().second()), + hasTime_(true) +{ + parsed_ = true; + assembled_ = false; +} + +DateValue::DateValue(const DateValue & x) + : Value(x) +{ + year_ = x.year_; + month_ = x.month_; + day_ = x.day_; + hour_ = x.hour_; + minute_ = x.minute_; + second_ = x.second_; + zoneHour_ = x.zoneHour_; + zoneMinute_ = x.zoneMinute_; + secFrac_ = x.secFrac_; + hasTime_ = x.hasTime_; +} + +DateValue::DateValue(const TQCString & s) + : Value(s) +{ +} + + DateValue & +DateValue::operator = (DateValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + DateValue & +DateValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +DateValue::operator == (DateValue & x) +{ + x.parse(); + return false; +} + +DateValue::~DateValue() +{ +} + + DateValue * +DateValue::clone() +{ + return new DateValue( *this ); +} + + void +DateValue::_parse() +{ + vDebug("DateValue::_parse()"); + + // date = date-full-year ["-"] date-month ["-"] date-mday + // time = time-hour [":"] time-minute [":"] time-second [":"] + // [time-secfrac] [time-zone] + + int timeSep = strRep_.find('T'); + + TQCString dateStr; + TQCString timeStr; + + if (timeSep == -1) { + + dateStr = strRep_; + vDebug("Has date string \"" + dateStr + "\""); + + } else { + + dateStr = strRep_.left(timeSep); + vDebug("Has date string \"" + dateStr + "\""); + + timeStr = strRep_.mid(timeSep + 1); + vDebug("Has time string \"" + timeStr + "\""); + } + + /////////////////////////////////////////////////////////////// DATE + + dateStr.replace(TQRegExp("-"), ""); + + kdDebug(5710) << "dateStr: " << dateStr << endl; + + year_ = dateStr.left(4).toInt(); + month_ = dateStr.mid(4, 2).toInt(); + day_ = dateStr.right(2).toInt(); + + if (timeSep == -1) { + hasTime_ = false; + return; // No time, done. + } + else + hasTime_ = true; + + /////////////////////////////////////////////////////////////// TIME + + /////////////////////////////////////////////////////////////// ZONE + + int zoneSep = timeStr.find('Z'); + + if (zoneSep != -1 && timeStr.length() - zoneSep > 3) { + + TQCString zoneStr(timeStr.mid(zoneSep + 1)); + vDebug("zoneStr == " + zoneStr); + + zonePositive_ = (zoneStr[0] == '+'); + zoneHour_ = zoneStr.mid(1, 2).toInt(); + zoneMinute_ = zoneStr.right(2).toInt(); + + timeStr.remove(zoneSep, timeStr.length() - zoneSep); + } + + //////////////////////////////////////////////////// SECOND FRACTION + + int secFracSep = timeStr.findRev(','); + + if (secFracSep != -1 && zoneSep != -1) { // zoneSep checked to avoid errors. + TQCString quirkafleeg = "0." + timeStr.mid(secFracSep + 1, zoneSep); + secFrac_ = quirkafleeg.toDouble(); + } + + /////////////////////////////////////////////////////////////// HMS + + timeStr.replace(TQRegExp(":"), ""); + + hour_ = timeStr.left(2).toInt(); + minute_ = timeStr.mid(2, 2).toInt(); + second_ = timeStr.mid(4, 2).toInt(); +} + + void +DateValue::_assemble() +{ + vDebug("DateValue::_assemble"); + + TQCString year; + TQCString month; + TQCString day; + + year.setNum( year_ ); + month.setNum( month_ ); + day.setNum( day_ ); + + if ( month.length() < 2 ) month.prepend( "0" ); + if ( day.length() < 2 ) day.prepend( "0" ); + + strRep_ = year + '-' + month + '-' + day; + + if ( hasTime_ ) { + TQCString hour; + TQCString minute; + TQCString second; + + hour.setNum( hour_ ); + minute.setNum( minute_ ); + second.setNum( second_ ); + + if ( hour.length() < 2 ) hour.prepend( "0" ); + if ( minute.length() < 2 ) minute.prepend( "0" ); + if ( second.length() < 2 ) second.prepend( "0" ); + + strRep_ += 'T' + hour + ':' + minute + ':' + second + 'Z'; + } +} + + unsigned int +DateValue::year() +{ + parse(); + return year_; +} + + unsigned int +DateValue::month() +{ + parse(); + return month_; +} + + unsigned int +DateValue::day() +{ + parse(); + return day_; +} + unsigned int +DateValue::hour() +{ + parse(); + return hour_; +} + + unsigned int +DateValue::minute() +{ + parse(); + return minute_; +} + + unsigned int +DateValue::second() +{ + parse(); + return second_; +} + + double +DateValue::secondFraction() +{ + parse(); + return secFrac_; +} + + bool +DateValue::zonePositive() +{ + parse(); + return zonePositive_; +} + + unsigned int +DateValue::zoneHour() +{ + parse(); + return zoneHour_; +} + + unsigned int +DateValue::zoneMinute() +{ + parse(); + return zoneMinute_; +} + + void +DateValue::setYear(unsigned int i) +{ + year_ = i; + assembled_ = false; +} + + void +DateValue::setMonth(unsigned int i) +{ + month_ = i; + assembled_ = false; +} + + void +DateValue::setDay(unsigned int i) +{ + day_ = i; + assembled_ = false; +} + + void +DateValue::setHour(unsigned int i) +{ + hour_ = i; + assembled_ = false; +} + + void +DateValue::setMinute(unsigned int i) +{ + minute_ = i; + assembled_ = false; +} + + void +DateValue::setSecond(unsigned int i) +{ + second_ = i; + assembled_ = false; +} + + void +DateValue::setSecondFraction(double d) +{ + secFrac_ = d; + assembled_ = false; +} + + void +DateValue::setZonePositive(bool b) +{ + zonePositive_ = b; + assembled_ = false; +} + + void +DateValue::setZoneHour(unsigned int i) +{ + zoneHour_ = i; + assembled_ = false; +} + + void +DateValue::setZoneMinute(unsigned int i) +{ + zoneMinute_ = i; + assembled_ = false; +} + + TQDate +DateValue::qdate() +{ + parse(); + TQDate d(year_, month_, day_); + return d; +} + + TQTime +DateValue::qtime() +{ + parse(); + TQTime t(hour_, minute_, second_); +// t.setMs(1 / secFrac_); + return t; +} + + TQDateTime +DateValue::qdt() +{ + parse(); + TQDateTime dt; + dt.setDate(qdate()); + dt.setTime(qtime()); + return dt; +} + + bool +DateValue::hasTime() +{ + parse(); + return hasTime_; +} + diff --git a/tdeabc/vcard/EmailParam.cpp b/tdeabc/vcard/EmailParam.cpp new file mode 100644 index 000000000..7daf19ccc --- /dev/null +++ b/tdeabc/vcard/EmailParam.cpp @@ -0,0 +1,116 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardEmailParam.h> +#include <VCardParam.h> +#include <VCardDefines.h> + +using namespace VCARD; + +EmailParam::EmailParam() + : Param() +{ + vDebug("ctor"); +} + +EmailParam::EmailParam(const EmailParam & x) + : Param(x), + emailType_ (x.emailType_), + pref_ (x.pref_) +{ +} + +EmailParam::EmailParam(const TQCString & s) + : Param(s) +{ +} + + EmailParam & +EmailParam::operator = (EmailParam & x) +{ + if (*this == x) return *this; + + emailType_ = x.emailType(); + pref_ = x.pref_; + + Param::operator = (x); + return *this; +} + + EmailParam & +EmailParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +EmailParam::operator == (EmailParam & x) +{ + parse(); + + if (pref_) + return (x.pref_ && x.emailType() == emailType_); + + return !x.pref(); +} + +EmailParam::~EmailParam() +{ +} + + void +EmailParam::_parse() +{ +#if 0 + Param::parseToList(); + + SubParamListIterator it(subParamList_); + + pref_ = true; + emailType_ = ""; + + for (; it.current(); ++it) { + + if (tqstricmp(it.current()->name(), "TYPE") == 0) { + emailType_ = it.current()->value(); + continue; + } + + if (tqstricmp(it.current()->name(), "PREF") == 0) { + pref_ = true; + } + } +#endif +} + + void +EmailParam::_assemble() +{ + strRep_ = "TYPE="; + strRep_ += emailType_; + + if (pref_) + strRep_ += ",PREF"; +} + diff --git a/tdeabc/vcard/Entity.cpp b/tdeabc/vcard/Entity.cpp new file mode 100644 index 000000000..5eaf6a1d0 --- /dev/null +++ b/tdeabc/vcard/Entity.cpp @@ -0,0 +1,134 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardEntity.h> + +using namespace VCARD; + +Entity::Entity() + : parsed_ (false), + assembled_ (true) +{ + // empty +} + +Entity::Entity(const Entity & e) + : strRep_ (e.strRep_), + parsed_ (e.parsed_), + assembled_ (e.assembled_) +{ + // empty +} + +Entity::Entity(const TQCString & s) + : strRep_ (s), + parsed_ (false), + assembled_ (true) +{ + // empty +} + + Entity & +Entity::operator = (const Entity & e) +{ + if (this == &e) return *this; + + strRep_ = e.strRep_; + parsed_ = e.parsed_; + assembled_ = e.assembled_; + + return *this; +} + + Entity & +Entity::operator = (const TQCString & s) +{ + strRep_ = s; + parsed_ = false; + assembled_ = true; + + return *this; +} + + bool +Entity::operator == (Entity & e) +{ + return asString() == e.asString(); +} + + bool +Entity::operator != (Entity & e) +{ + return !(*this == e); +} + + bool +Entity::operator == (const TQCString & s) +{ + return asString() == s; +} + + bool +Entity::operator != (const TQCString & s) +{ + return !(*this == s); +} + +Entity::~Entity() +{ + // empty +} + + TQCString +Entity::asString() +{ +// vDebug("Entity::asString()"); + assemble(); + + return strRep_; +} + + void +Entity::parse() +{ +// vDebug( "Entity::parse()" ); + + if (!parsed_) _parse(); + + parsed_ = true; + assembled_ = false; +} + + void +Entity::assemble() +{ +// vDebug( "Entity::assemble()" ); + + if (assembled_) return; + + parse(); + _assemble(); + + assembled_ = true; +} + diff --git a/tdeabc/vcard/Enum.cpp b/tdeabc/vcard/Enum.cpp new file mode 100644 index 000000000..bcb48f98a --- /dev/null +++ b/tdeabc/vcard/Enum.cpp @@ -0,0 +1,490 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqcstring.h> +#include <ctype.h> + +#include <VCardEnum.h> + +using namespace VCARD; + +// There are 31 possible types, not including extensions. +// URI is a custom field designed to store the upstream URI for each contact +// in order to handle certain limited CardDAV systems such as Zimbra + const TQCString +VCARD::paramNames [] = +{ + "NAME", + "PROFILE", + "SOURCE", + "FN", + "N", + "NICKNAME", + "PHOTO", + "BDAY", + "ADR", + "LABEL", + "TEL", + "EMAIL", + "MAILER", + "TZ", + "GEO", + "TITLE", + "ROLE", + "LOGO", + "AGENT", + "ORG", + "CATEGORIES", + "NOTE", + "PRODID", + "REV", + "SORT-STRING", + "SOUND", + "UID", + "URL", + "VERSION", + "CLASS", + "KEY", + "URI" +}; + + const ParamType +VCARD::paramTypesTable[] = { + ParamNone, // NAME + ParamNone, // PROFILE + ParamSource, // SOURCE + ParamText, // FN + ParamText, // N + ParamText, // NICKNAME + ParamImage, // PHOTO (inline/refer) + ParamDate, // BDAY ("VALUE = "date-time/date) + ParamAddrText, // ADR (adr-param/text-param) + ParamAddrText, // LABEL (adr-param/text-param) + ParamTel, // TEL + ParamEmail, // EMAIL + ParamText, // MAILER + ParamNone, // TZ + ParamNone, // GEO + ParamText, // TITLE + ParamText, // ROLE + ParamImage, // LOGO + ParamAgent, // AGENT + ParamText, // ORG + ParamText, // CATEGORIES + ParamText, // NOTE + ParamNone, // PRODID + ParamDate, // REV + ParamText, // SORT-STRING + ParamSound, // SOUND + ParamNone, // UID + ParamNone, // URL + ParamNone, // VERSION + ParamNone, // CLASS + ParamTextBin, // KEY + ParamTextNS, // X + ParamNone // URI +}; + + ParamType +VCARD::EntityTypeToParamType(EntityType e) +{ + ParamType t(ParamUnknown); + + switch (e) { + + //---------------------------------------------------------------// + case EntityAgent: t = ParamAgent; break; + //---------------------------------------------------------------// + case EntitySound: t = ParamSound; break; + //---------------------------------------------------------------// + case EntitySource: t = ParamSource; break; + //---------------------------------------------------------------// + case EntityTelephone: t = ParamTel; break; + //---------------------------------------------------------------// + case EntityEmail: t = ParamEmail; break; + //---------------------------------------------------------------// + case EntityKey: t = ParamTextBin; break; + //---------------------------------------------------------------// + case EntityExtension: t = ParamTextNS; break; + //---------------------------------------------------------------// + case EntityAddress: + case EntityLabel: t = ParamAddrText; break; + //---------------------------------------------------------------// + case EntityBirthday: + case EntityRevision: t = ParamDate; break; + //---------------------------------------------------------------// + case EntityPhoto: + case EntityLogo: t = ParamImage; break; + //---------------------------------------------------------------// + case EntityOrganisation: + case EntityTitle: + case EntityRole: + case EntityFullName: + case EntityMailer: + case EntityN: + case EntitySortString: + case EntityNickname: + case EntityCategories: + case EntityNote: t = ParamText; break; + //---------------------------------------------------------------// + case EntityProductID: + case EntityTimeZone: + case EntityUID: + case EntityURL: + case EntityClass: + case EntityGeo: + case EntityName: + case EntityVersion: + case EntityProfile: + case EntityURI: + default: t = ParamNone; break; + //---------------------------------------------------------------// + + } + + return t; +} + + ValueType +VCARD::EntityTypeToValueType(EntityType e) +{ + ValueType t(ValueUnknown); + + switch (e) { + + //---------------------------------------------------------------// + case EntitySound: t = ValueSound; break; + //---------------------------------------------------------------// + case EntityAgent: t = ValueAgent; break; + //---------------------------------------------------------------// + case EntityAddress: t = ValueAddress; break; + //---------------------------------------------------------------// + case EntityTelephone: t = ValueTel; break; + //---------------------------------------------------------------// + case EntityKey: t = ValueTextBin; break; + //---------------------------------------------------------------// + case EntityOrganisation: t = ValueOrg; break; + //---------------------------------------------------------------// + case EntityN: t = ValueN; break; + //---------------------------------------------------------------// + case EntityTimeZone: t = ValueUTC; break; + //---------------------------------------------------------------// + case EntityClass: t = ValueClass; break; + //---------------------------------------------------------------// + case EntityGeo: t = ValueGeo; break; + //---------------------------------------------------------------// + case EntitySource: + case EntityURL: t = ValueURI; break; + //---------------------------------------------------------------// + case EntityPhoto: + case EntityLogo: t = ValueImage; break; + //---------------------------------------------------------------// + case EntityBirthday: + case EntityRevision: t = ValueDate; break; + //---------------------------------------------------------------// + case EntityCategories: + case EntityNickname: t = ValueTextList; break; + //---------------------------------------------------------------// + case EntityLabel: + case EntityExtension: + case EntityEmail: + case EntityTitle: + case EntityRole: + case EntityFullName: + case EntityMailer: + case EntityProductID: + case EntityName: + case EntitySortString: + case EntityVersion: + case EntityProfile: + case EntityUID: + case EntityNote: + case EntityURI: + default: t = ValueText; break; + //---------------------------------------------------------------// + + } + + return t; +} + + TQCString +VCARD::EntityTypeToParamName(EntityType e) +{ + if ( e > EntityUnknown ) e = EntityUnknown; + return paramNames[ int( e ) ]; +} + + EntityType +VCARD::EntityNameToEntityType(const TQCString & s) +{ + if (s.isEmpty()) return EntityUnknown; + + EntityType t(EntityUnknown); + + switch (s[0]) { + + case 'A': + if (s == "ADR") + t = EntityAddress; + else if (s == "AGENT") + t = EntityAgent; + break; + + case 'B': + if (s == "BDAY") + t = EntityBirthday; + break; + + case 'C': + if (s == "CATEGORIES") + t = EntityCategories; + else if (s == "CLASS") + t = EntityClass; + break; + + case 'E': + if (s == "EMAIL") + t = EntityEmail; + break; + + case 'F': + if (s == "FN") + t = EntityFullName; + break; + + case 'G': + if (s == "GEO") + t = EntityGeo; + break; + + case 'K': + if (s == "KEY") + t = EntityKey; + break; + + case 'L': + if (s == "LABEL") + t = EntityLabel; + else if (s == "LOGO") + t = EntityLogo; + break; + + case 'M': + if (s == "MAILER") + t = EntityMailer; + break; + + case 'N': + if (s == "N") + t = EntityN; + else if (s == "NAME") + t = EntityName; + else if (s == "NICKNAME") + t = EntityNickname; + else if (s == "NOTE") + t = EntityNote; + break; + + case 'O': + if (s == "ORG") + t = EntityOrganisation; + break; + + case 'P': + if (s == "PHOTO") + t = EntityPhoto; + else if (s == "PRODID") + t = EntityProductID; + else if (s == "PROFILE") + t = EntityProfile; + break; + + case 'R': + if (s == "REV") + t = EntityRevision; + else if (s == "ROLE") + t = EntityRole; + break; + + case 'S': + if (s == "SORT-STRING") + t = EntitySortString; + else if (s == "SOUND") + t = EntitySound; + else if (s == "SOURCE") + t = EntitySource; + break; + + case 'T': + if (s == "TEL") + t = EntityTelephone; + else if (s == "TITLE") + t = EntityTitle; + else if (s == "TZ") + t = EntityTimeZone; + break; + + case 'U': + if (s == "UID") + t = EntityUID; + else if (s == "URL") + t = EntityURL; + else if (s == "URI") + t = EntityURI; + case 'V': + if (s == "VERSION") + t = EntityVersion; + break; + + case 'X': + if (s.left(2) == "X-") + t = EntityExtension; + break; + + default: + + t = EntityUnknown; + } + + return t; +} + +// The copyright notice below refers to the base64 codec functions used below, +// which are modified from the original sources. + +/* + * Original version Copyright 1988 by The Leland Stanford Junior University + * Copyright 1998 by the University of Washington + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * above copyright notices and this permission notice appear in supporting + * documentation, and that the name of the University of Washington or The + * Leland Stanford Junior University not be used in advertising or publicity + * pertaining to distribution of the software without specific, written prior + * permission. This software is made available "as is", and + * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY + * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, + * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF + * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +static char B64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +// the mime base64 disctionary used for decoding +static signed char b64dec[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 30 + -1, -1, -1,-19, -1, -1, -1,-16, -4, -4, // 40 -19 == '+' -16 == '/' + -4, -4, -4, -4, -4, -4, -4, -4, -1, -1, // 50 -4 == '0' + -1, 0, -1, -1, -1, 65, 65, 65, 65, 65, // 60 0 == '=' 65 == 'A' + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 70 + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 80 + 65, -1, -1, -1, -1, -1, -1, 71, 71, 71, // 90 71 == 'a' + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, // 100 + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, // 110 + 71, 71, 71, -1, -1, -1, -1, -1, -1, -1, // 120 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 130 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 140 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 150 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 160 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 170 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 180 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 190 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 200 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 210 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 220 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 230 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 240 + -1, -1, -1, -1, -1, -1, -1 // 250 +}; + + char * +VCARD::decodeBase64(const char * s, unsigned long srcl, unsigned long & len) +{ + register unsigned char c; + register unsigned long e(0); + len = 0; + unsigned const char * src = (unsigned const char *)s; + char * ret = new char[srcl + (srcl / 4 + 1)]; + register char *d = ret; + while (srcl--) { // Critical loop + c = *src++; + int dec = b64dec[c]; + if (dec == -1) continue; + if (c == '=') { + switch (e++) { + case 3: e = 0; break; + case 2: if (*src == '=') break; + default: delete [] ret; ret = 0; return 0; break; + } + continue; + } + c -= dec; + if (e == 0) { *d = c << 2; ++e; continue; } + switch (e) { + case 1: *d |= c >> 4; *++d = c << 4; break; + case 2: *d |= c >> 2; *++d = c << 6; break; + case 3: *d++ |= c; e = 0; continue; break; + } + ++e; + } + len = d - (char *)ret; + return ret; +} + + + char * +VCARD::encodeBase64(const char * src, unsigned long srcl, unsigned long & destl) +{ + register const unsigned char *s = (unsigned char *)src; + register unsigned long i = ((srcl + 2) / 3) * 4; + destl = i += 2 * ((i / 60) + 1); + i = 0; + char * ret = new char[destl]; + register unsigned char *d((unsigned char *)ret); + while (srcl != 0) { // Critical loop + *d++ = B64[s[0] >> 2]; + *d++ = B64[((s[0] << 4) + (--srcl == 0 ? 0 : s[1] >> 4)) & 0x3f]; + *d++ = srcl == 0 ? '=' : + B64[((s[1] << 2) + (--srcl == 0 ? 0 : s[2] >> 6)) & 0x3f]; + *d++ = srcl == 0 ? '=' : B64[s[2] & 0x3f]; + if (srcl != 0) srcl--; + if (++i == 15) { i = 0; *d++ = '\r'; *d++ = '\n'; } + s += 3; + } + *d = '\r'; *++d = '\n'; *++d = '\0'; + return ret; +} + diff --git a/tdeabc/vcard/FloatValue.cpp b/tdeabc/vcard/FloatValue.cpp new file mode 100644 index 000000000..ac1f2c6b5 --- /dev/null +++ b/tdeabc/vcard/FloatValue.cpp @@ -0,0 +1,120 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardFloatValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +FloatValue::FloatValue() + : Value() +{ +} + +FloatValue::FloatValue(float f) + : Value (), + value_ (f) +{ + parsed_ = true; +} + +FloatValue::FloatValue(const FloatValue & x) + : Value(x) +{ + value_ = x.value_; +} + +FloatValue::FloatValue(const TQCString & s) + : Value(s) +{ +} + + FloatValue & +FloatValue::operator = (FloatValue & x) +{ + if (*this == x) return *this; + + x.parse(); + value_ = x.value_; + + Value::operator = (x); + return *this; +} + + FloatValue & +FloatValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +FloatValue::operator == (FloatValue & x) +{ + x.parse(); + return (value_ == x.value_); +} + +FloatValue::~FloatValue() +{ +} + + void +FloatValue::_parse() +{ + bool negative(false); + + if (strRep_[0] == '-' || strRep_[1] == '+') { + + if (strRep_[0] == '-') + negative = true; + + strRep_.remove(0, 1); + } + + value_ = strRep_.toFloat(); + if (negative) + value_ = -value_; +} + + void +FloatValue::_assemble() +{ + strRep_ = TQCString().setNum(value_); +} + + float +FloatValue::value() +{ + parse(); + return value_; +} + + void +FloatValue::setValue(float f) +{ + parsed_ = true; + value_ = f; +} + diff --git a/tdeabc/vcard/GeoValue.cpp b/tdeabc/vcard/GeoValue.cpp new file mode 100644 index 000000000..2bac28c1e --- /dev/null +++ b/tdeabc/vcard/GeoValue.cpp @@ -0,0 +1,100 @@ +/* + This file is part of libvcard. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <VCardGeoValue.h> + +#include <VCardValue.h> + +#include <kdebug.h> + +using namespace VCARD; + +GeoValue::GeoValue() + : Value() +{ +} + +GeoValue::GeoValue(const GeoValue & x) + : Value(x), latitude_(x.latitude_), longitude_(x.longitude_) +{ +} + +GeoValue::GeoValue(const TQCString & s) + : Value(s) +{ +} + + GeoValue & +GeoValue::operator = (GeoValue & x) +{ + if (*this == x) return *this; + + latitude_ = x.latitude_; + longitude_ = x.longitude_; + + Value::operator = (x); + return *this; +} + + GeoValue & +GeoValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +GeoValue::operator == (GeoValue & x) +{ + x.parse(); + + if ( latitude_ != x.latitude_ ) return false; + if ( longitude_ != x.longitude_ ) return false; + + return true; +} + +GeoValue::~GeoValue() +{ +} + + GeoValue * +GeoValue::clone() +{ + return new GeoValue( *this ); +} + + void +GeoValue::_parse() +{ + int semiColon = strRep_.find( ";" ); + + if ( semiColon == -1 ) // invalid + return; + + latitude_ = strRep_.left( semiColon ).toFloat(); + longitude_ = strRep_.mid( semiColon + 1, strRep_.length() - semiColon ).toFloat(); +} + + void +GeoValue::_assemble() +{ + strRep_.sprintf( "%.6f;%.6f", latitude_, longitude_ ); +} diff --git a/tdeabc/vcard/ImageParam.cpp b/tdeabc/vcard/ImageParam.cpp new file mode 100644 index 000000000..69611eeab --- /dev/null +++ b/tdeabc/vcard/ImageParam.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardImageParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +ImageParam::ImageParam() + : Param() +{ +} + +ImageParam::ImageParam(const ImageParam & x) + : Param(x) +{ +} + +ImageParam::ImageParam(const TQCString & s) + : Param(s) +{ +} + + ImageParam & +ImageParam::operator = (ImageParam & x) +{ + if (*this == x) return *this; + + Param::operator = (x); + return *this; +} + + ImageParam & +ImageParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +ImageParam::operator == (ImageParam & x) +{ + x.parse(); + return false; +} + +ImageParam::~ImageParam() +{ +} + + void +ImageParam::_parse() +{ +} + + void +ImageParam::_assemble() +{ +} + diff --git a/tdeabc/vcard/ImageValue.cpp b/tdeabc/vcard/ImageValue.cpp new file mode 100644 index 000000000..5d8d29bb7 --- /dev/null +++ b/tdeabc/vcard/ImageValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardImageValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +ImageValue::ImageValue() + : Value() +{ +} + +ImageValue::ImageValue(const ImageValue & x) + : Value(x) +{ +} + +ImageValue::ImageValue(const TQCString & s) + : Value(s) +{ +} + + ImageValue & +ImageValue::operator = (ImageValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + ImageValue & +ImageValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +ImageValue::operator == (ImageValue & x) +{ + x.parse(); + return false; +} + +ImageValue::~ImageValue() +{ +} + + void +ImageValue::_parse() +{ +} + + void +ImageValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/ImgValue.cpp b/tdeabc/vcard/ImgValue.cpp new file mode 100644 index 000000000..42889acd8 --- /dev/null +++ b/tdeabc/vcard/ImgValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardImgValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +ImgValue::ImgValue() + : Value() +{ +} + +ImgValue::ImgValue(const ImgValue & x) + : Value(x) +{ +} + +ImgValue::ImgValue(const TQCString & s) + : Value(s) +{ +} + + ImgValue & +ImgValue::operator = (ImgValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + ImgValue & +ImgValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +ImgValue::operator == (ImgValue & x) +{ + x.parse(); + return false; +} + +ImgValue::~ImgValue() +{ +} + + void +ImgValue::_parse() +{ +} + + void +ImgValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/LangValue.cpp b/tdeabc/vcard/LangValue.cpp new file mode 100644 index 000000000..f7e5a759e --- /dev/null +++ b/tdeabc/vcard/LangValue.cpp @@ -0,0 +1,127 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardRToken.h> + +#include <VCardLangValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +LangValue::LangValue() + : Value() +{ +} + +LangValue::LangValue(const LangValue & x) + : Value(x) +{ +} + +LangValue::LangValue(const TQCString & s) + : Value(s) +{ +} + + LangValue & +LangValue::operator = (LangValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + LangValue & +LangValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +LangValue::operator == (LangValue & x) +{ + x.parse(); + return false; +} + +LangValue::~LangValue() +{ +} + + void +LangValue::_parse() +{ + TQStrList l; + RTokenise(strRep_, "-", l); + + if (l.count() == 0) return; + + primary_ = l.at(0); + + l.remove(0u); + + subtags_ = l; +} + + void +LangValue::_assemble() +{ + strRep_ = primary_; + + TQStrListIterator it(subtags_); + + for (; it.current(); ++it) + strRep_ += TQCString('-') + it.current(); +} + + TQCString +LangValue::primary() +{ + parse(); + return primary_; +} + + TQStrList +LangValue::subtags() +{ + parse(); + return subtags_; +} + + void +LangValue::setPrimary(const TQCString & s) +{ + parse(); + primary_ = s; +} + + void +LangValue::setSubTags(const TQStrList & l) +{ + parse(); + subtags_ = l; +} + diff --git a/tdeabc/vcard/Makefile.am b/tdeabc/vcard/Makefile.am new file mode 100644 index 000000000..e8a33c3a9 --- /dev/null +++ b/tdeabc/vcard/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = \ + -I$(srcdir)/include \ + -I$(srcdir)/include/generated \ + $(all_includes) + +### KDE 4.0: either make noinst or rename to something like libkvcard +lib_LTLIBRARIES = libvcard.la + +libvcard_la_SOURCES = vCard-all.cpp +libvcard_la_LDFLAGS = $(all_libraries) +libvcard_la_LIBADD = $(LIB_TDECORE) $(LIB_QT) + +check_PROGRAMS = testwrite testread + +testwrite_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testwrite_LDADD = libvcard.la +testwrite_SOURCES = testwrite.cpp + +testread_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testread_LDADD = libvcard.la +testread_SOURCES = testread.cpp diff --git a/tdeabc/vcard/NValue.cpp b/tdeabc/vcard/NValue.cpp new file mode 100644 index 000000000..e63268134 --- /dev/null +++ b/tdeabc/vcard/NValue.cpp @@ -0,0 +1,128 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqstrlist.h> + +#include <VCardRToken.h> +#include <VCardNValue.h> +#include <VCardValue.h> +#include <VCardDefines.h> + +using namespace VCARD; + +NValue::NValue() + : Value() +{ + vDebug("ctor"); +} + +NValue::NValue(const NValue & x) + : Value(x), + family_ (x.family_), + given_ (x.given_), + middle_ (x.middle_), + prefix_ (x.prefix_), + suffix_ (x.suffix_) +{ +} + +NValue::NValue(const TQCString & s) + : Value(s) +{ + vDebug("ctor"); +} + + NValue & +NValue::operator = (NValue & x) +{ + if (*this == x) return *this; + + family_ = x.family_; + given_ = x.given_; + middle_ = x.middle_; + prefix_ = x.prefix_; + suffix_ = x.suffix_; + + Value::operator = (x); + return *this; +} + + NValue & +NValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +NValue::operator == (NValue & x) +{ + x.parse(); + + return ( + family_ == x.family_ && + given_ == x.given_ && + middle_ == x.middle_ && + prefix_ == x.prefix_ && + suffix_ == x.suffix_); +} + +NValue::~NValue() +{ +} + + NValue * +NValue::clone() +{ + return new NValue( *this ); +} + + void +NValue::_parse() +{ + TQStrList l; + RTokenise(strRep_, ";", l); + + for (unsigned int i = 0; i < l.count(); i++) { + + switch (i) { + case 0: family_ = l.at(0); break; + case 1: given_ = l.at(1); break; + case 2: middle_ = l.at(2); break; + case 3: prefix_ = l.at(3); break; + case 4: suffix_ = l.at(4); break; + default: break; + } + } +} + + void +NValue::_assemble() +{ + strRep_ = family_; + strRep_ += ";" + given_; + strRep_ += ";" + middle_; + strRep_ += ";" + prefix_; + strRep_ += ";" + suffix_; +} + diff --git a/tdeabc/vcard/OrgValue.cpp b/tdeabc/vcard/OrgValue.cpp new file mode 100644 index 000000000..94ca18243 --- /dev/null +++ b/tdeabc/vcard/OrgValue.cpp @@ -0,0 +1,107 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardRToken.h> + +#include <VCardOrgValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +OrgValue::OrgValue() + : Value() +{ +} + +OrgValue::OrgValue(const OrgValue & x) + : Value(x) +{ +} + +OrgValue::OrgValue(const TQCString & s) + : Value(s) +{ +} + + OrgValue & +OrgValue::operator = (OrgValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + OrgValue & +OrgValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +OrgValue::operator == (OrgValue & x) +{ + x.parse(); + return false; +} + +OrgValue::~OrgValue() +{ +} + + void +OrgValue::_parse() +{ + RTokenise(strRep_, ";", valueList_); +} + + void +OrgValue::_assemble() +{ + bool first(true); + + TQStrListIterator it(valueList_); + + for (; it.current(); ++it) { + if (!first) strRep_ += ';'; + strRep_ += it.current(); + first = false; + } +} + + unsigned int +OrgValue::numValues() +{ + parse(); + return valueList_.count(); +} + + TQCString +OrgValue::value(unsigned int i) +{ + parse(); + return valueList_.at(i); +} + diff --git a/tdeabc/vcard/Param.cpp b/tdeabc/vcard/Param.cpp new file mode 100644 index 000000000..8c5ad9e2c --- /dev/null +++ b/tdeabc/vcard/Param.cpp @@ -0,0 +1,129 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardParam.h> + +#include <VCardEntity.h> + +#include <VCardRToken.h> + +using namespace VCARD; + +Param::Param() + : Entity(), + name_(""), + value_("") +{ +} + +Param::Param(const Param & x) + : Entity(x), + name_(x.name_), + value_(x.value_) +{ +} + +Param::Param(const TQCString & s) + : Entity(s), + name_(""), + value_("") +{ +} + + Param & +Param::operator = (Param & x) +{ + if (*this == x) return *this; + + Entity::operator = (x); + name_ = x.name_; + value_ = x.value_; + + return *this; +} + + Param & +Param::operator = (const TQCString & s) +{ + Entity::operator = (s); + return *this; +} + + bool +Param::operator == (Param & x) +{ + x.parse(); + return false; +} + +Param::~Param() +{ +} + + void +Param::_parse() +{ +} + + void +Param::_assemble() +{ + strRep_ = name_ + "=" + value_; +} + +Param::Param(const TQCString &name, const TQCString &value) + : Entity(), + name_(name), + value_(value) +{ + parsed_ = true; + assembled_ = false; +} + + void +Param::setName(const TQCString & name) +{ + name_ = name; + + assembled_ = false; +} + + void +Param::setValue(const TQCString & value) +{ + value_ = value; + + assembled_ = false; +} + + TQCString +Param::name() +{ + return name_; +} + + TQCString +Param::value() +{ + return value_; +} diff --git a/tdeabc/vcard/PhoneNumberValue.cpp b/tdeabc/vcard/PhoneNumberValue.cpp new file mode 100644 index 000000000..02a1266fe --- /dev/null +++ b/tdeabc/vcard/PhoneNumberValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardPhoneNumberValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +PhoneNumberValue::PhoneNumberValue() + : Value() +{ +} + +PhoneNumberValue::PhoneNumberValue(const PhoneNumberValue & x) + : Value(x) +{ +} + +PhoneNumberValue::PhoneNumberValue(const TQCString & s) + : Value(s) +{ +} + + PhoneNumberValue & +PhoneNumberValue::operator = (PhoneNumberValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + PhoneNumberValue & +PhoneNumberValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +PhoneNumberValue::operator == (PhoneNumberValue & x) +{ + x.parse(); + return false; +} + +PhoneNumberValue::~PhoneNumberValue() +{ +} + + void +PhoneNumberValue::_parse() +{ +} + + void +PhoneNumberValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/README b/tdeabc/vcard/README new file mode 100644 index 000000000..18a9daf4a --- /dev/null +++ b/tdeabc/vcard/README @@ -0,0 +1,15 @@ +libvcard (C) 1999 Rik Hemsley <[email protected]> +Written for the KDE project. + +This software is licensed under the MIT license. + +A vCard 3.0 parser based on the same principles that librmm (from Empath) uses. + +It's small and very fast due to parsing and assembly of object being lazy. + +There is a base64 codec declared in Enum.h + +Feedback welcome. + +Rik <[email protected]> + diff --git a/tdeabc/vcard/RToken.cpp b/tdeabc/vcard/RToken.cpp new file mode 100644 index 000000000..582a9e1c7 --- /dev/null +++ b/tdeabc/vcard/RToken.cpp @@ -0,0 +1,88 @@ +/* + + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <string.h> +#include <stddef.h> +#include <tqcstring.h> +#include <tqstrlist.h> + +namespace VCARD +{ + + TQ_UINT32 +RTokenise(const char * str, const char * delim, TQStrList & l) +{ + // FIXME no stderr ! + l.clear(); + + if (!delim || !str || strlen(delim) == 0 || strlen(str) == 0) return 0; + + char * len = (char *)(str + strlen(str)); // End of string. + + register char * rstart = new char[strlen(str) + 1]; + register char * r = rstart; + + + register const char * i = str; // Cursor. + + while (i <= len) { + + if (*i == '\\') { // Escaped chars go straight through. + *r++ = *i++; + if (i <= len) + *r++ = *i++; + continue; + } + + if (strchr(delim, *i) != 0) { + // We hit a delimiter. If we have some text, make a new token. + // This has the effect that multiple delimiters are collapsed. + // cs: We mustn't collapse multiple delimiters, otherwise we + // lose empty fields. + *r = '\0'; +// if (r != rstart) { + l.append(rstart); +// } + r = rstart; + ++i; + continue; + } + + *r++ = *i++; + } + + // Catch last token +// if (r != rstart) { + *r = '\0'; + l.append(rstart); +// } + + r = 0; + + delete [] rstart; + + return l.count(); +} + +} diff --git a/tdeabc/vcard/SoundValue.cpp b/tdeabc/vcard/SoundValue.cpp new file mode 100644 index 000000000..5be75d358 --- /dev/null +++ b/tdeabc/vcard/SoundValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardSoundValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +SoundValue::SoundValue() + : Value() +{ +} + +SoundValue::SoundValue(const SoundValue & x) + : Value(x) +{ +} + +SoundValue::SoundValue(const TQCString & s) + : Value(s) +{ +} + + SoundValue & +SoundValue::operator = (SoundValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + SoundValue & +SoundValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +SoundValue::operator == (SoundValue & x) +{ + x.parse(); + return false; +} + +SoundValue::~SoundValue() +{ +} + + void +SoundValue::_parse() +{ +} + + void +SoundValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/SourceParam.cpp b/tdeabc/vcard/SourceParam.cpp new file mode 100644 index 000000000..6a0e772ac --- /dev/null +++ b/tdeabc/vcard/SourceParam.cpp @@ -0,0 +1,112 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardSourceParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +SourceParam::SourceParam() + : Param(), + type_(SourceParam::TypeUnknown) +{ +} + +SourceParam::SourceParam(const SourceParam & x) + : Param(x), + type_ (x.type_), + par_ (x.par_), + val_ (x.val_) +{ +} + +SourceParam::SourceParam(const TQCString & s) + : Param(s), + type_(SourceParam::TypeUnknown) +{ +} + + SourceParam & +SourceParam::operator = (SourceParam & x) +{ + if (*this == x) return *this; + type_ = x.type(); + par_ = x.par(); + val_ = x.val(); + + Param::operator = (x); + return *this; +} + + SourceParam & +SourceParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +SourceParam::operator == (SourceParam & x) +{ + x.parse(); + return false; +} + +SourceParam::~SourceParam() +{ +} + + void +SourceParam::_parse() +{ + int i = strRep_.find('='); + if (i == -1) // Invalid + return; + + par_ = strRep_.left(i); + val_ = strRep_.right(strRep_.length() - i - 1); + + if (tqstricmp(par_, "VALUE") == 0 && tqstricmp(val_, "uri") == 0) + type_ = TypeValue; + else if (tqstricmp(par_, "CONTEXT") == 0 && tqstricmp(val_, "word") == 0) + type_ = TypeContext; + else if (tqstrnicmp(par_, "X-", 2) == 0) { + type_ = TypeX; + } + else type_ = TypeUnknown; + +} + + void +SourceParam::_assemble() +{ + if (type_ == TypeValue) + strRep_ = "VALUE=uri"; + else if (type_ == TypeContext) + strRep_ = "CONTEXT=word"; + else if (type_ == TypeX) + strRep_ = par_ + "=" + val_; + else strRep_ = ""; +} + diff --git a/tdeabc/vcard/TelParam.cpp b/tdeabc/vcard/TelParam.cpp new file mode 100644 index 000000000..072b1dc81 --- /dev/null +++ b/tdeabc/vcard/TelParam.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardTelParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +TelParam::TelParam() + : Param() +{ +} + +TelParam::TelParam(const TelParam & x) + : Param(x) +{ +} + +TelParam::TelParam(const TQCString & s) + : Param(s) +{ +} + + TelParam & +TelParam::operator = (TelParam & x) +{ + if (*this == x) return *this; + + Param::operator = (x); + return *this; +} + + TelParam & +TelParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +TelParam::operator == (TelParam & x) +{ + x.parse(); + return false; +} + +TelParam::~TelParam() +{ +} + + void +TelParam::_parse() +{ +} + + void +TelParam::_assemble() +{ +} + diff --git a/tdeabc/vcard/TelValue.cpp b/tdeabc/vcard/TelValue.cpp new file mode 100644 index 000000000..c9c1b85aa --- /dev/null +++ b/tdeabc/vcard/TelValue.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardTelValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +TelValue::TelValue() + : Value() +{ +} + +TelValue::TelValue(const TelValue & x) + : Value(x) +{ +} + +TelValue::TelValue(const TQCString & s) + : Value(s) +{ +} + + TelValue & +TelValue::operator = (TelValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + TelValue & +TelValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +TelValue::operator == (TelValue & x) +{ + x.parse(); + return false; +} + +TelValue::~TelValue() +{ +} + + void +TelValue::_parse() +{ +} + + void +TelValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/TextBinParam.cpp b/tdeabc/vcard/TextBinParam.cpp new file mode 100644 index 000000000..4e0ebadff --- /dev/null +++ b/tdeabc/vcard/TextBinParam.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardTextBinParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +TextBinParam::TextBinParam() + : Param() +{ +} + +TextBinParam::TextBinParam(const TextBinParam & x) + : Param(x) +{ +} + +TextBinParam::TextBinParam(const TQCString & s) + : Param(s) +{ +} + + TextBinParam & +TextBinParam::operator = (TextBinParam & x) +{ + if (*this == x) return *this; + + Param::operator = (x); + return *this; +} + + TextBinParam & +TextBinParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +TextBinParam::operator == (TextBinParam & x) +{ + x.parse(); + return false; +} + +TextBinParam::~TextBinParam() +{ +} + + void +TextBinParam::_parse() +{ +} + + void +TextBinParam::_assemble() +{ +} + diff --git a/tdeabc/vcard/TextBinValue.cpp b/tdeabc/vcard/TextBinValue.cpp new file mode 100644 index 000000000..e7da0b7c6 --- /dev/null +++ b/tdeabc/vcard/TextBinValue.cpp @@ -0,0 +1,104 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <kmdcodec.h> + +#include <VCardTextBinValue.h> +#include <VCardValue.h> + +using namespace VCARD; + +TextBinValue::TextBinValue() + : Value() +{ +} + +TextBinValue::TextBinValue(const TextBinValue & x) + : Value(x) +{ + mIsBinary_ = x.mIsBinary_; + mData_ = x.mData_; + mUrl_ = x.mUrl_; +} + +TextBinValue::TextBinValue(const TQCString & s) + : Value(s) +{ +} + + TextBinValue & +TextBinValue::operator = (TextBinValue & x) +{ + if (*this == x) return *this; + + mIsBinary_ = x.mIsBinary_; + mData_ = x.mData_; + mUrl_ = x.mUrl_; + + Value::operator = (x); + return *this; +} + + TextBinValue & +TextBinValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +TextBinValue::operator == (TextBinValue & x) +{ + x.parse(); + + if ( mIsBinary_ != x.mIsBinary_ ) return false; + if ( mData_ != x.mData_ ) return false; + if ( mUrl_ != x.mUrl_ ) return false; + + return true; +} + +TextBinValue::~TextBinValue() +{ +} + + TextBinValue * +TextBinValue::clone() +{ + return new TextBinValue( *this ); +} + + void +TextBinValue::_parse() +{ +} + + void +TextBinValue::_assemble() +{ + if ( mIsBinary_ ) { + strRep_ = KCodecs::base64Encode( mData_ ); + } else + strRep_ = mUrl_.utf8(); +} + diff --git a/tdeabc/vcard/TextListValue.cpp b/tdeabc/vcard/TextListValue.cpp new file mode 100644 index 000000000..2bec2e181 --- /dev/null +++ b/tdeabc/vcard/TextListValue.cpp @@ -0,0 +1,107 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardRToken.h> + +#include <VCardTextListValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +TextListValue::TextListValue() + : Value() +{ +} + +TextListValue::TextListValue(const TextListValue & x) + : Value(x) +{ +} + +TextListValue::TextListValue(const TQCString & s) + : Value(s) +{ +} + + TextListValue & +TextListValue::operator = (TextListValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + TextListValue & +TextListValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +TextListValue::operator == (TextListValue & x) +{ + x.parse(); + return false; +} + +TextListValue::~TextListValue() +{ +} + + void +TextListValue::_parse() +{ + RTokenise(strRep_, ";", valueList_); +} + + void +TextListValue::_assemble() +{ + bool first(true); + + TQStrListIterator it(valueList_); + + for (; it.current(); ++it) { + if (!first) strRep_ += ';'; + strRep_ += it.current(); + first = false; + } +} + + unsigned int +TextListValue::numValues() +{ + parse(); + return valueList_.count(); +} + + TQCString +TextListValue::value(unsigned int i) +{ + parse(); + return valueList_.at(i); +} + diff --git a/tdeabc/vcard/TextParam.cpp b/tdeabc/vcard/TextParam.cpp new file mode 100644 index 000000000..b353483ec --- /dev/null +++ b/tdeabc/vcard/TextParam.cpp @@ -0,0 +1,82 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardTextParam.h> + +#include <VCardParam.h> + +using namespace VCARD; + +TextParam::TextParam() + : Param() +{ +} + +TextParam::TextParam(const TextParam & x) + : Param(x) +{ +} + +TextParam::TextParam(const TQCString & s) + : Param(s) +{ +} + + TextParam & +TextParam::operator = (TextParam & x) +{ + if (*this == x) return *this; + + Param::operator = (x); + return *this; +} + + TextParam & +TextParam::operator = (const TQCString & s) +{ + Param::operator = (s); + return *this; +} + + bool +TextParam::operator == (TextParam & x) +{ + x.parse(); + + return false; +} + +TextParam::~TextParam() +{ +} + + void +TextParam::_parse() +{ +} + + void +TextParam::_assemble() +{ +} + diff --git a/tdeabc/vcard/TextValue.cpp b/tdeabc/vcard/TextValue.cpp new file mode 100644 index 000000000..cf8e0673f --- /dev/null +++ b/tdeabc/vcard/TextValue.cpp @@ -0,0 +1,86 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardTextValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +TextValue::TextValue() + : Value() +{ +} + +TextValue::TextValue(const TextValue & x) + : Value(x) +{ +} + +TextValue::TextValue(const TQCString & s) + : Value(s) +{ +} + + TextValue & +TextValue::operator = (TextValue & x) +{ + if (*this == x) return *this; + + Value::operator = (x); + return *this; +} + + TextValue & +TextValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +TextValue::operator == (TextValue & x) +{ + return strRep_ == x.strRep_; +} + +TextValue::~TextValue() +{ +} + + TextValue * +TextValue::clone() +{ + return new TextValue( *this ); +} + + void +TextValue::_parse() +{ +} + + void +TextValue::_assemble() +{ +} + diff --git a/tdeabc/vcard/URIValue.cpp b/tdeabc/vcard/URIValue.cpp new file mode 100644 index 000000000..bba8db0fa --- /dev/null +++ b/tdeabc/vcard/URIValue.cpp @@ -0,0 +1,133 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardURIValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +URIValue::URIValue() + : Value() +{ +} + +URIValue::URIValue(const TQCString & scheme, const TQCString & schemeSpecificPart) + : Value(), + scheme_ (scheme), + schemeSpecificPart_ (schemeSpecificPart) +{ + parsed_ = true; +} + +URIValue::URIValue(const URIValue & x) + : Value (x), + scheme_ (x.scheme_), + schemeSpecificPart_ (x.schemeSpecificPart_) +{ +} + +URIValue::URIValue(const TQCString & s) + : Value(s) +{ +} + + URIValue & +URIValue::operator = (URIValue & x) +{ + if (*this == x) return *this; + + scheme_ = x.scheme_; + schemeSpecificPart_ = x.schemeSpecificPart_; + + Value::operator = (x); + return *this; +} + + URIValue & +URIValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +URIValue::operator == (URIValue & x) +{ + x.parse(); + return ( + (scheme_ == x.scheme_) && + (schemeSpecificPart_ == x.schemeSpecificPart_)); + + return false; +} + +URIValue::~URIValue() +{ +} + + void +URIValue::_parse() +{ + int split = strRep_.find(':'); + if (split == -1) + return; + + scheme_ = strRep_.left(split); + schemeSpecificPart_ = strRep_.mid(split + 1); +} + + void +URIValue::_assemble() +{ + strRep_ = scheme_ + ':' + schemeSpecificPart_; +} + + TQCString +URIValue::scheme() +{ + parse(); + return scheme_; +} + + TQCString +URIValue::schemeSpecificPart() +{ + parse(); + return schemeSpecificPart_; +} + + void +URIValue::setScheme(const TQCString & s) +{ + parse(); + scheme_ = s; +} + + void +URIValue::setSchemeSpecificPart(const TQCString & s) +{ + parse(); + schemeSpecificPart_ = s; +} + diff --git a/tdeabc/vcard/UTCValue.cpp b/tdeabc/vcard/UTCValue.cpp new file mode 100644 index 000000000..30473661f --- /dev/null +++ b/tdeabc/vcard/UTCValue.cpp @@ -0,0 +1,110 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardUTCValue.h> + +#include <VCardValue.h> + +using namespace VCARD; + +UTCValue::UTCValue() + : Value() +{ +} + +UTCValue::UTCValue(const UTCValue & x) + : Value(x), positive_(x.positive_), hour_(x.hour_), minute_(x.minute_) + +{ +} + +UTCValue::UTCValue(const TQCString & s) + : Value(s) +{ +} + + UTCValue & +UTCValue::operator = (UTCValue & x) +{ + if (*this == x) return *this; + + positive_ = x.positive_; + hour_ = x.hour_; + minute_ = x.minute_; + + Value::operator = (x); + return *this; +} + + UTCValue & +UTCValue::operator = (const TQCString & s) +{ + Value::operator = (s); + return *this; +} + + bool +UTCValue::operator == (UTCValue & x) +{ + x.parse(); + + if (positive_ != x.positive_) return false; + if (hour_ != x.hour_) return false; + if (minute_ != x.minute_) return false; + + return true; +} + +UTCValue::~UTCValue() +{ +} + + UTCValue * +UTCValue::clone() +{ + return new UTCValue( *this ); +} + + void +UTCValue::_parse() +{ + if ( strRep_.isEmpty() ) + return; + + positive_ = ( strRep_[0] == '+' ); + + int colon = strRep_.find( ':' ); + + if ( colon == -1 ) // Not valid. + return; + + hour_ = strRep_.mid( 1, 2 ).toInt(); + minute_ = strRep_.right( 2 ).toInt(); +} + + void +UTCValue::_assemble() +{ + strRep_.sprintf( "%c%.2i:%.2i", (positive_ ? '+' : '-'), hour_, minute_ ); +} + diff --git a/tdeabc/vcard/VCard.cpp b/tdeabc/vcard/VCard.cpp new file mode 100644 index 000000000..eb3f57f6e --- /dev/null +++ b/tdeabc/vcard/VCard.cpp @@ -0,0 +1,283 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqcstring.h> +#include <tqstrlist.h> + +#include <VCardEntity.h> +#include <VCardVCard.h> +#include <VCardContentLine.h> +#include <VCardRToken.h> + +#include <VCardDefines.h> + +using namespace VCARD; + +VCard::VCard() + : Entity() +{ + contentLineList_.setAutoDelete( true ); +} + +VCard::VCard(const VCard & x) + : Entity(x), + group_(x.group_), + contentLineList_(x.contentLineList_) +{ +} + +VCard::VCard(const TQCString & s) + : Entity(s) +{ +} + + VCard & +VCard::operator = (VCard & x) +{ + if (*this == x) return *this; + + group_ = x.group(); + contentLineList_ = x.contentLineList_; + + Entity::operator = (x); + return *this; +} + + VCard & +VCard::operator = (const TQCString & s) +{ + Entity::operator = (s); + return *this; +} + + bool +VCard::operator == (VCard & x) +{ + x.parse(); + return false; +} + +VCard::~VCard() +{ +} + + void +VCard::_parse() +{ + vDebug("parse() called"); + TQStrList l; + + RTokenise(strRep_, "\r\n", l); + + if (l.count() < 3) { // Invalid VCARD ! + vDebug("Invalid vcard"); + return; + } + + // Get the first line + TQCString beginLine = TQCString(l.at(0)).stripWhiteSpace(); + + vDebug("Begin line == \"" + beginLine + "\""); + + // Remove extra blank lines + while (TQCString(l.last()).isEmpty()) + l.remove(l.last()); + + // Now we know this is the last line + TQCString endLine = l.last(); + + // Trash the first and last lines as we have seen them. + l.remove(0u); + l.remove(l.last()); + + /////////////////////////////////////////////////////////////// + // FIRST LINE + + int split = beginLine.find(':'); + + if (split == -1) { // invalid, no BEGIN + vDebug("No split"); + return; + } + + TQCString firstPart(beginLine.left(split)); + TQCString valuePart(beginLine.mid(split + 1)); + + split = firstPart.find('.'); + + if (split != -1) { + group_ = firstPart.left(split); + firstPart = firstPart.right(firstPart.length() - split - 1); + } + + if (tqstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! + vDebug("No BEGIN"); + return; + } + + if (tqstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! + vDebug("No VCARD"); + return; + } + + /////////////////////////////////////////////////////////////// + // CONTENT LINES + // + vDebug("Content lines"); + + // Handle folded lines. + + TQStrList refolded; + + TQStrListIterator it(l); + + TQCString cur; + + for (; it.current(); ++it) { + + cur = it.current(); + + ++it; + + while ( + it.current() && + it.current()[0] == ' ' && + strlen(it.current()) != 1) + { + cur += it.current() + 1; + ++it; + } + + --it; + + refolded.append(cur); + } + + TQStrListIterator it2(refolded); + + for (; it2.current(); ++it2) { + + vDebug("New contentline using \"" + TQCString(it2.current()) + "\""); + ContentLine * cl = new ContentLine(it2.current()); + + cl->parse(); + + contentLineList_.append(cl); + } + + /////////////////////////////////////////////////////////////// + // LAST LINE + + split = endLine.find(':'); + + if (split == -1) // invalid, no END + return; + + firstPart = endLine.left(split); + valuePart = endLine.right(firstPart.length() - split - 1); + + split = firstPart.find('.'); + + if (split != -1) { + group_ = firstPart.left(split); + firstPart = firstPart.right(firstPart.length() - split - 1); + } + + if (tqstricmp(firstPart, "END") != 0) // No END ! + return; + + if (tqstricmp(valuePart, "VCARD") != 0) // Not a vcard ! + return; +} + + void +VCard::_assemble() +{ + vDebug("Assembling vcard"); + strRep_ = "BEGIN:VCARD\r\n"; + strRep_ += "VERSION:3.0\r\n"; + + TQPtrListIterator<ContentLine> it(contentLineList_); + + for (; it.current(); ++it) + strRep_ += it.current()->asString() + "\r\n"; + + strRep_ += "END:VCARD\r\n"; +} + + bool +VCard::has(EntityType t) +{ + parse(); + return contentLine(t) == 0 ? false : true; +} + + bool +VCard::has(const TQCString & s) +{ + parse(); + return contentLine(s) == 0 ? false : true; +} + + void +VCard::add(const ContentLine & cl) +{ + parse(); + ContentLine * c = new ContentLine(cl); + contentLineList_.append(c); +} + + void +VCard::add(const TQCString & s) +{ + parse(); + ContentLine * c = new ContentLine(s); + contentLineList_.append(c); +} + + ContentLine * +VCard::contentLine(EntityType t) +{ + parse(); + TQPtrListIterator<ContentLine> it(contentLineList_); + + for (; it.current(); ++it) + if (it.current()->entityType() == t) + return it.current(); + + return 0; +} + + ContentLine * +VCard::contentLine(const TQCString & s) +{ + parse(); + TQPtrListIterator<ContentLine> it(contentLineList_); + + for (; it.current(); ++it) + if (it.current()->entityType() == EntityNameToEntityType(s)) + return it.current(); + + return 0; +} + diff --git a/tdeabc/vcard/VCardEntity.cpp b/tdeabc/vcard/VCardEntity.cpp new file mode 100644 index 000000000..1f8cea5b1 --- /dev/null +++ b/tdeabc/vcard/VCardEntity.cpp @@ -0,0 +1,119 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <tqregexp.h> + +#include <VCardDefines.h> +#include <VCardVCardEntity.h> + +using namespace VCARD; + +VCardEntity::VCardEntity() + : Entity() +{ +} + +VCardEntity::VCardEntity(const VCardEntity & x) + : Entity(x) +{ +} + +VCardEntity::VCardEntity(const TQCString & s) + : Entity(s) +{ +} + + VCardEntity & +VCardEntity::operator = (VCardEntity & x) +{ + if (*this == x) return *this; + + Entity::operator = (x); + return *this; +} + + VCardEntity & +VCardEntity::operator = (const TQCString & s) +{ + Entity::operator = (s); + return *this; +} + + bool +VCardEntity::operator == (VCardEntity & x) +{ + x.parse(); + return false; +} + +VCardEntity::~VCardEntity() +{ +} + + void +VCardEntity::_parse() +{ + vDebug("parse"); + TQCString s(strRep_); + + int i = s.find(TQRegExp("BEGIN:VCARD", false)); + + while (i != -1) { + + i = s.find(TQRegExp("BEGIN:VCARD", false), 11); + + TQCString cardStr(s.left(i)); + + VCard * v = new VCard(cardStr); + + cardList_.append(v); + + v->parse(); + + s.remove(0, i); + } +} + + void +VCardEntity::_assemble() +{ + VCardListIterator it(cardList_); + + for (; it.current(); ++it) + strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. +} + + VCardList & +VCardEntity::cardList() +{ + parse(); + return cardList_; +} + + void +VCardEntity::setCardList(const VCardList & l) +{ + parse(); + cardList_ = l; +} + diff --git a/tdeabc/vcard/Value.cpp b/tdeabc/vcard/Value.cpp new file mode 100644 index 000000000..c95c0712b --- /dev/null +++ b/tdeabc/vcard/Value.cpp @@ -0,0 +1,81 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <VCardEntity.h> +#include <VCardValue.h> + +using namespace VCARD; + +Value::Value() + : Entity() +{ +} + +Value::Value(const Value & x) + : Entity(x) +{ +} + +Value::Value(const TQCString & s) + : Entity(s) +{ +} + + Value & +Value::operator = (Value & x) +{ + if (*this == x) return *this; + + Entity::operator = (x); + return *this; +} + + Value & +Value::operator = (const TQCString & s) +{ + Entity::operator = (s); + return *this; +} + + bool +Value::operator == (Value & x) +{ + x.parse(); + return false; +} + +Value::~Value() +{ +} + + void +Value::_parse() +{ +} + + void +Value::_assemble() +{ + vDebug("Value::_assemble()"); +} + diff --git a/tdeabc/vcard/include/VCard.h b/tdeabc/vcard/include/VCard.h new file mode 100644 index 000000000..17b50e8f2 --- /dev/null +++ b/tdeabc/vcard/include/VCard.h @@ -0,0 +1,43 @@ +#ifndef VCARD_H +#define VCARD_H + +#include "VCardAdrParam.h" +#include "VCardAdrValue.h" +#include "VCardAgentParam.h" +#include "VCardAgentValue.h" +#include "VCardClassValue.h" +#include "VCardContentLine.h" +#include "VCardDateParam.h" +#include "VCardDateValue.h" +#include "VCardDefines.h" +#include "VCardEmailParam.h" +#include "VCardEntity.h" +#include "VCardEnum.h" +#include "VCardFloatValue.h" +#include "VCardGeoValue.h" +#include "VCardGroup.h" +#include "VCardImageParam.h" +#include "VCardImageValue.h" +#include "VCardImgValue.h" +#include "VCardLangValue.h" +#include "VCardNValue.h" +#include "VCardOrgValue.h" +#include "VCardParam.h" +#include "VCardPhoneNumberValue.h" +#include "VCardRToken.h" +#include "VCardSoundValue.h" +#include "VCardSourceParam.h" +#include "VCardTelParam.h" +#include "VCardTelValue.h" +#include "VCardTextBinParam.h" +#include "VCardTextBinValue.h" +#include "VCardTextListValue.h" +#include "VCardTextParam.h" +#include "VCardTextValue.h" +#include "VCardURIValue.h" +#include "VCardUTCValue.h" +#include "VCardVCard.h" +#include "VCardVCardEntity.h" +#include "VCardValue.h" + +#endif diff --git a/tdeabc/vcard/include/VCardAdrParam.h b/tdeabc/vcard/include/VCardAdrParam.h new file mode 100644 index 000000000..d40165f4a --- /dev/null +++ b/tdeabc/vcard/include/VCardAdrParam.h @@ -0,0 +1,64 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ADRPARAM_H +#define ADRPARAM_H + +#include <tqcstring.h> +#include <tqstrlist.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT AdrParam : public Param +{ + +#include "AdrParam-generated.h" + + TQStrList adrTypeList() + { parse(); return adrTypeList_; } + + TQCString textParam() + { parse(); return textParam_; } + + void setAdrTypeList(const TQStrList & l) + { adrTypeList_ = l; assembled_ = false; } + + void setTextParam(const TQCString & s) + { textParam_ = s; assembled_ = false; } + + enum AdrType { + AdrDom, AdrIntl, AdrPostal, AdrParcel, AdrHome, AdrWork, AdrPref, + AdrIANA, AdrX + }; + + private: + + TQStrList adrTypeList_; + TQCString textParam_; +}; +} + +#endif diff --git a/tdeabc/vcard/include/VCardAdrValue.h b/tdeabc/vcard/include/VCardAdrValue.h new file mode 100644 index 000000000..94ed93aee --- /dev/null +++ b/tdeabc/vcard/include/VCardAdrValue.h @@ -0,0 +1,83 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ADRVALUE_H +#define ADRVALUE_H + +#include <tqstrlist.h> +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT AdrValue : public Value +{ + +#include "AdrValue-generated.h" + + AdrValue *clone(); + + void setPOBox(const TQCString & s) + { poBox_ = s; assembled_ = false; } + + void setExtAddress(const TQCString & s) + { extAddress_ = s; assembled_ = false; } + + void setStreet(const TQCString & s) + { street_ = s; assembled_ = false; } + + void setLocality(const TQCString & s) + { locality_ = s; assembled_ = false; } + + void setRegion(const TQCString & s) + { region_ = s; assembled_ = false; } + + void setPostCode(const TQCString & s) + { postCode_ = s; assembled_ = false; } + + void setCountryName(const TQCString & s) + { countryName_ = s; assembled_ = false; } + + TQCString poBox() { parse(); return poBox_; } + TQCString extAddress() { parse(); return extAddress_; } + TQCString street() { parse(); return street_; } + TQCString locality() { parse(); return locality_; } + TQCString region() { parse(); return region_; } + TQCString postCode() { parse(); return postCode_; } + TQCString countryName() { parse(); return countryName_; } + + private: + + TQCString poBox_; + TQCString extAddress_; + TQCString street_; + TQCString locality_; + TQCString region_; + TQCString postCode_; + TQCString countryName_; +}; + +} + +#endif + diff --git a/tdeabc/vcard/include/VCardAgentParam.h b/tdeabc/vcard/include/VCardAgentParam.h new file mode 100644 index 000000000..90c3bd528 --- /dev/null +++ b/tdeabc/vcard/include/VCardAgentParam.h @@ -0,0 +1,60 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef AGENTPARAM_H +#define AGENTPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> +#include <VCardURIValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT AgentParam : public Param +{ + +#include "AgentParam-generated.h" + + bool refer() + { parse(); return refer_; } + + URIValue uri() + { parse(); return uri_; } + + void setRefer(bool b) + { refer_ = b; assembled_ = false; } + + void setURI(const TQCString & s) + { uri_ = s; assembled_ = false; } + + private: + + bool refer_; + URIValue uri_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardAgentValue.h b/tdeabc/vcard/include/VCardAgentValue.h new file mode 100644 index 000000000..dd68145c9 --- /dev/null +++ b/tdeabc/vcard/include/VCardAgentValue.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef AGENTVALUE_H +#define AGENTVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT AgentValue : public Value +{ + +#include "AgentValue-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardClassValue.h b/tdeabc/vcard/include/VCardClassValue.h new file mode 100644 index 000000000..5de79167b --- /dev/null +++ b/tdeabc/vcard/include/VCardClassValue.h @@ -0,0 +1,56 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef CLASSVALUE_H +#define CLASSVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +#include <kdebug.h> + +namespace VCARD +{ + +class KVCARD_EXPORT ClassValue : public Value +{ + +#include "ClassValue-generated.h" + + enum ClassType { + Public, Private, Confidential, Other + }; + + ClassValue *clone(); + + void setType( int type ) { classType_ = type; assembled_ = false; parsed_ = true; } + int type() { parse(); return classType_; } + + private: + int classType_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardContentLine.h b/tdeabc/vcard/include/VCardContentLine.h new file mode 100644 index 000000000..ea59444a0 --- /dev/null +++ b/tdeabc/vcard/include/VCardContentLine.h @@ -0,0 +1,77 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef CONTENTLINE_H +#define CONTENTLINE_H + +#include <tqptrlist.h> + +#include "VCardEnum.h" +#include "VCardEntity.h" +#include "VCardParam.h" +#include "VCardValue.h" + +namespace VCARD +{ + +class KVCARD_EXPORT ContentLine : public Entity +{ + +#include "ContentLine-generated.h" + + TQCString group() { parse(); return group_; } + TQCString name() { parse(); return name_; } + Value * value() { parse(); return value_; } + ParamList paramList() { parse(); return paramList_; } + ParamType paramType() { parse(); return paramType_; } + ValueType valueType() { parse(); return valueType_; } + EntityType entityType() { parse(); return entityType_; } + + void setGroup (const TQCString & s) + { group_ = s; assembled_ = false; } + + void setName (const TQCString & s) + { name_ = s; assembled_ = false; } + + void setValue (Value *s) + { value_ = s; assembled_ = false; } + + void setParamList (const ParamList & l) + { paramList_ = l; assembled_ = false; } + + void clear (); + + private: + + TQCString group_; + TQCString name_; + TQPtrList<Param> paramList_; + Value * value_; + + ParamType paramType_; + ValueType valueType_; + EntityType entityType_; +}; +} + +#endif diff --git a/tdeabc/vcard/include/VCardDateParam.h b/tdeabc/vcard/include/VCardDateParam.h new file mode 100644 index 000000000..410eae6b7 --- /dev/null +++ b/tdeabc/vcard/include/VCardDateParam.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef DATEPARAM_H +#define DATEPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT DateParam : public Param +{ + +#include "DateParam-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardDateValue.h b/tdeabc/vcard/include/VCardDateValue.h new file mode 100644 index 000000000..4f2e2fe7f --- /dev/null +++ b/tdeabc/vcard/include/VCardDateValue.h @@ -0,0 +1,99 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef DATEVALUE_H +#define DATEVALUE_H + +#include <tqcstring.h> +#include <tqdatetime.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT DateValue : public Value +{ +#include "DateValue-generated.h" + + DateValue( + unsigned int year, + unsigned int month, + unsigned int day, + unsigned int hour = 0, + unsigned int minute = 0, + unsigned int second = 0, + double secFrac = 0, + bool zonePositive = true, + unsigned int zoneHour = 0, + unsigned int zoneMinute = 0); + + DateValue(const TQDate &); + DateValue(const TQDateTime &); + + DateValue *clone(); + + bool hasTime(); + + unsigned int year(); + unsigned int month(); + unsigned int day(); + unsigned int hour(); + unsigned int minute(); + unsigned int second(); + double secondFraction(); + bool zonePositive(); + unsigned int zoneHour(); + unsigned int zoneMinute(); + + void setYear (unsigned int); + void setMonth (unsigned int); + void setDay (unsigned int); + void setHour (unsigned int); + void setMinute (unsigned int); + void setSecond (unsigned int); + void setSecondFraction (double); + void setZonePositive (bool); + void setZoneHour (unsigned int); + void setZoneMinute (unsigned int); + + TQDate qdate(); + TQTime qtime(); + TQDateTime qdt(); + + private: + + unsigned int year_, month_, day_, + hour_, minute_, second_, + zoneHour_, zoneMinute_; + + double secFrac_; + + bool zonePositive_; + + bool hasTime_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardDefines.h b/tdeabc/vcard/include/VCardDefines.h new file mode 100644 index 000000000..e778bc24f --- /dev/null +++ b/tdeabc/vcard/include/VCardDefines.h @@ -0,0 +1,52 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1998 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VCARD_DEFINES_H +#define VCARD_DEFINES_H + +#include <kdebug.h> + +#ifdef VCARD_DEBUG +#define vDebug(a) kdDebug(5710) << a << endl; +#else +#define vDebug(a) +#endif + +#if 0 +#ifndef NDEBUG +# include <tqcstring.h> +# include <iostream> +# ifdef __GNUG__ +# define vDebug(a) cerr << className() << ":" << __FUNCTION__ << " (" \ + << __LINE__ << "): " << TQCString((a)).data() << endl; +# else +# define vDebug(a) cerr << className() << ": " \ + << TQCString((a)).data() << endl; +# endif +#else +# define vDebug(a) +#endif +#endif + +#endif // Included this file + diff --git a/tdeabc/vcard/include/VCardEmailParam.h b/tdeabc/vcard/include/VCardEmailParam.h new file mode 100644 index 000000000..1fe558afd --- /dev/null +++ b/tdeabc/vcard/include/VCardEmailParam.h @@ -0,0 +1,56 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef EMAILPARAM_H +#define EMAILPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT EmailParam : public Param +{ + +#include "EmailParam-generated.h" + + TQCString emailType() { parse(); return emailType_; } + bool pref() { parse(); return pref_; } + + void setEmailType(const TQCString & s) + { emailType_ = s; assembled_ = false; } + + void setPref(bool b) + { pref_ = b; assembled_ = false; } + + private: + + TQCString emailType_; + bool pref_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardEntity.h b/tdeabc/vcard/include/VCardEntity.h new file mode 100644 index 000000000..e87c5f1a6 --- /dev/null +++ b/tdeabc/vcard/include/VCardEntity.h @@ -0,0 +1,68 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ENTITY_H +#define ENTITY_H + +#include <tqcstring.h> +#include <tdelibs_export.h> + +namespace VCARD +{ + +class KVCARD_EXPORT Entity +{ + public: + + Entity(); + Entity(const Entity & e); + Entity(const TQCString & s); + + virtual Entity & operator = (const Entity & e); + virtual Entity & operator = (const TQCString & s); + + virtual bool operator == (Entity & e); + virtual bool operator != (Entity & e); + virtual bool operator == (const TQCString & s); + virtual bool operator != (const TQCString & s); + + virtual ~Entity(); + + TQCString asString(); + + virtual void parse(); + virtual void assemble(); + + virtual void _parse() = 0; + virtual void _assemble() = 0; + + protected: + + TQCString strRep_; + bool parsed_; + bool assembled_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardEnum.h b/tdeabc/vcard/include/VCardEnum.h new file mode 100644 index 000000000..4552ccdbc --- /dev/null +++ b/tdeabc/vcard/include/VCardEnum.h @@ -0,0 +1,123 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ENUM_H +#define ENUM_H + +#include <tqcstring.h> + +#include <tdelibs_export.h> + +namespace VCARD +{ + +extern const TQCString paramNames []; + +enum EntityType { + EntityName, + EntityProfile, + EntitySource, + EntityFullName, + EntityN, + EntityNickname, + EntityPhoto, + EntityBirthday, + EntityAddress, + EntityLabel, + EntityTelephone, + EntityEmail, + EntityMailer, + EntityTimeZone, + EntityGeo, + EntityTitle, + EntityRole, + EntityLogo, + EntityAgent, + EntityOrganisation, + EntityCategories, + EntityNote, + EntityProductID, + EntityRevision, + EntitySortString, + EntitySound, + EntityUID, + EntityURI, + EntityURL, + EntityVersion, + EntityClass, + EntityKey, + EntityExtension, + EntityUnknown +}; + +enum ValueType { + ValueSound, + ValueAgent, + ValueAddress, + ValueTel, + ValueTextBin, + ValueOrg, + ValueN, + ValueUTC, + ValueURI, + ValueClass, + ValueFloat, + ValueImage, + ValueDate, + ValueTextList, + ValueText, + ValueGeo, + ValueUnknown +}; + +enum ParamType { + ParamUnknown, + ParamNone, + ParamSource, + ParamText, + ParamImage, + ParamDate, + ParamAddrText, + ParamTel, + ParamEmail, + ParamMailer, + ParamAgent, + ParamTextBin, + ParamTextNS, + ParamSound +}; + +extern const ParamType paramTypesTable[]; + +KVCARD_EXPORT ParamType EntityTypeToParamType(EntityType); +KVCARD_EXPORT ValueType EntityTypeToValueType(EntityType); +KVCARD_EXPORT TQCString EntityTypeToParamName(EntityType); +KVCARD_EXPORT EntityType EntityNameToEntityType(const TQCString &); + +KVCARD_EXPORT char * encodeBase64(const char *, unsigned long, unsigned long &); +KVCARD_EXPORT char * decodeBase64(const char *, unsigned long, unsigned long &); + +} + +#endif + diff --git a/tdeabc/vcard/include/VCardFloatValue.h b/tdeabc/vcard/include/VCardFloatValue.h new file mode 100644 index 000000000..45a6823be --- /dev/null +++ b/tdeabc/vcard/include/VCardFloatValue.h @@ -0,0 +1,51 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef FLOATVALUE_H +#define FLOATVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT FloatValue : public Value +{ + +#include "FloatValue-generated.h" + + FloatValue(float); + + float value(); + void setValue(float); + + private: + + float value_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardGeoValue.h b/tdeabc/vcard/include/VCardGeoValue.h new file mode 100644 index 000000000..4228587a4 --- /dev/null +++ b/tdeabc/vcard/include/VCardGeoValue.h @@ -0,0 +1,49 @@ +/* + This file is part of libvcard. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef GEOVALUE_H +#define GEOVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT GeoValue : public Value +{ + +#include "GeoValue-generated.h" + + GeoValue *clone(); + + void setLatitude( float lat ) { latitude_ = lat; assembled_ = false; } + void setLongitude( float lon ) { longitude_ = lon; assembled_ = false; } + + float latitude() { parse(); return latitude_; } + float longitude() { parse(); return longitude_; } + + private: + float latitude_; + float longitude_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardGroup.h b/tdeabc/vcard/include/VCardGroup.h new file mode 100644 index 000000000..ce884f100 --- /dev/null +++ b/tdeabc/vcard/include/VCardGroup.h @@ -0,0 +1,39 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef GROUP_H +#define GROUP_H + +#include <VCardEntity.h> + +namespace VCARD +{ + +class KVCARD_EXPORT Group : public Entity +{ +#include "Group-generated.h" +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardImageParam.h b/tdeabc/vcard/include/VCardImageParam.h new file mode 100644 index 000000000..10ab8a3f5 --- /dev/null +++ b/tdeabc/vcard/include/VCardImageParam.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef IMGPARAM_H +#define IMGPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT ImageParam : public Param +{ + +#include "ImageParam-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardImageValue.h b/tdeabc/vcard/include/VCardImageValue.h new file mode 100644 index 000000000..45fbcad9c --- /dev/null +++ b/tdeabc/vcard/include/VCardImageValue.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef IMAGEVALUE_H +#define IMAGEVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT ImageValue : public Value +{ + +#include "ImageValue-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardImgValue.h b/tdeabc/vcard/include/VCardImgValue.h new file mode 100644 index 000000000..7d4bbfa2d --- /dev/null +++ b/tdeabc/vcard/include/VCardImgValue.h @@ -0,0 +1,39 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef IMGVALUE_H +#define IMGVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT ImgValue : public Value +{ +#include "ImgValue-generated.h" +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardLangValue.h b/tdeabc/vcard/include/VCardLangValue.h new file mode 100644 index 000000000..7767d52fa --- /dev/null +++ b/tdeabc/vcard/include/VCardLangValue.h @@ -0,0 +1,51 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef LANGVALUE_H +#define LANGVALUE_H + +#include <tqcstring.h> +#include <tqstrlist.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT LangValue : public Value +{ +#include "LangValue-generated.h" + + TQCString primary(); + TQStrList subtags(); + + void setPrimary(const TQCString &); + void setSubTags(const TQStrList &); + + TQCString primary_; + TQStrList subtags_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardNValue.h b/tdeabc/vcard/include/VCardNValue.h new file mode 100644 index 000000000..9db37fbbc --- /dev/null +++ b/tdeabc/vcard/include/VCardNValue.h @@ -0,0 +1,56 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef NVALUE_H +#define NVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT NValue : public Value +{ +#include "NValue-generated.h" + NValue *clone(); + + TQCString family() { parse(); return family_; } + TQCString given() { parse(); return given_; } + TQCString middle() { parse(); return middle_; } + TQCString prefix() { parse(); return prefix_; } + TQCString suffix() { parse(); return suffix_; } + + void setFamily (const TQCString & s) { family_ = s; assembled_ = false; } + void setGiven (const TQCString & s) { given_ = s; assembled_ = false; } + void setMiddle (const TQCString & s) { middle_ = s; assembled_ = false; } + void setPrefix (const TQCString & s) { prefix_ = s; assembled_ = false; } + void setSuffix (const TQCString & s) { suffix_ = s; assembled_ = false; } + + private: + + TQCString family_, given_, middle_, prefix_, suffix_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardOrgValue.h b/tdeabc/vcard/include/VCardOrgValue.h new file mode 100644 index 000000000..a2bd803e5 --- /dev/null +++ b/tdeabc/vcard/include/VCardOrgValue.h @@ -0,0 +1,50 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ORGVALUE_H +#define ORGVALUE_H + +#include <tqcstring.h> +#include <tqstrlist.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT OrgValue : public Value +{ + +#include "OrgValue-generated.h" + + unsigned int numValues(); + TQCString value(unsigned int); + + private: + + TQStrList valueList_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardParam.h b/tdeabc/vcard/include/VCardParam.h new file mode 100644 index 000000000..93d70f06b --- /dev/null +++ b/tdeabc/vcard/include/VCardParam.h @@ -0,0 +1,59 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef PARAM_H +#define PARAM_H + +#include <tqcstring.h> +#include <tqptrlist.h> + +#include <VCardEntity.h> + +namespace VCARD +{ + +class KVCARD_EXPORT Param : public Entity +{ + +#include "Param-generated.h" + + Param(const TQCString &name, const TQCString &value); + + void setName(const TQCString &); + void setValue(const TQCString &); + + TQCString name(); + TQCString value(); + + private: + + TQCString name_; + TQCString value_; +}; + +typedef TQPtrList<Param> ParamList; +typedef TQPtrListIterator<Param> ParamListIterator; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardPhoneNumberValue.h b/tdeabc/vcard/include/VCardPhoneNumberValue.h new file mode 100644 index 000000000..3f9e106ca --- /dev/null +++ b/tdeabc/vcard/include/VCardPhoneNumberValue.h @@ -0,0 +1,39 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef PHONENUMBERVALUE_H +#define PHONENUMBERVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT PhoneNumberValue : public Value +{ +#include "PhoneNumberValue-generated.h" +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardRToken.h b/tdeabc/vcard/include/VCardRToken.h new file mode 100644 index 000000000..17a3943d3 --- /dev/null +++ b/tdeabc/vcard/include/VCardRToken.h @@ -0,0 +1,40 @@ +/* + + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef RTOKEN_H +#define RTOKEN_H + +#include <tqstrlist.h> + +#include <tdelibs_export.h> + +namespace VCARD +{ + +KVCARD_EXPORT TQ_UINT32 RTokenise(const char * str, const char * delim, TQStrList & l); + +} + +#endif + diff --git a/tdeabc/vcard/include/VCardSndValue.h b/tdeabc/vcard/include/VCardSndValue.h new file mode 100644 index 000000000..09a3a8238 --- /dev/null +++ b/tdeabc/vcard/include/VCardSndValue.h @@ -0,0 +1,39 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef SNDVALUE_H +#define SNDVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT SndValue : public Value +{ +#include "SndValue-generated.h" +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardSoundValue.h b/tdeabc/vcard/include/VCardSoundValue.h new file mode 100644 index 000000000..61858f058 --- /dev/null +++ b/tdeabc/vcard/include/VCardSoundValue.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef SOUNDVALUE_H +#define SOUNDVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT SoundValue : public Value +{ + +#include "SoundValue-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardSourceParam.h b/tdeabc/vcard/include/VCardSourceParam.h new file mode 100644 index 000000000..1d9d03d47 --- /dev/null +++ b/tdeabc/vcard/include/VCardSourceParam.h @@ -0,0 +1,58 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef SOURCEPARAM_H +#define SOURCEPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT SourceParam : public Param +{ + +#include "SourceParam-generated.h" + + enum SourceParamType { TypeUnknown, TypeValue, TypeContext, TypeX }; + + SourceParamType type() { parse(); return type_;} + TQCString par() { parse(); return par_; } + TQCString val() { parse(); return val_; } + + void setType(SourceParamType t) { type_ = t; assembled_ = false; } + void setPar(const TQCString & s) { par_ = s; assembled_ = false; } + void setVal(const TQCString & s) { val_ = s; assembled_ = false; } + + private: + + SourceParamType type_; + // May be "VALUE = uri" or "CONTEXT = word" or "x-name = *SAFE-CHAR" + TQCString par_, val_; // Sub-parameter, value +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTelParam.h b/tdeabc/vcard/include/VCardTelParam.h new file mode 100644 index 000000000..9eea5da2f --- /dev/null +++ b/tdeabc/vcard/include/VCardTelParam.h @@ -0,0 +1,51 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TELPARAM_H +#define TELPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TelParam : public Param +{ +#include "TelParam-generated.h" + + enum TelType { + TelHome, TelWork, TelPref, TelVoice, TelFex, TelMsg, TelCell, + TelPager, TelBBS, TelModem, TelCar, TelISDN, TelVideo, TelPCS, + TelIANA, TelX + }; + + private: + + TQPtrList<TelType> types_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTelValue.h b/tdeabc/vcard/include/VCardTelValue.h new file mode 100644 index 000000000..043a45aa9 --- /dev/null +++ b/tdeabc/vcard/include/VCardTelValue.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TELVALUE_H +#define TELVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TelValue : public Value +{ + +#include "TelValue-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTextBinParam.h b/tdeabc/vcard/include/VCardTextBinParam.h new file mode 100644 index 000000000..5a681ad48 --- /dev/null +++ b/tdeabc/vcard/include/VCardTextBinParam.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TEXTBINPARAM_H +#define TEXTBINPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TextBinParam : public Param +{ + +#include "TextBinParam-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTextBinValue.h b/tdeabc/vcard/include/VCardTextBinValue.h new file mode 100644 index 000000000..316fa7832 --- /dev/null +++ b/tdeabc/vcard/include/VCardTextBinValue.h @@ -0,0 +1,67 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TEXTBINVALUE_H +#define TEXTBINVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TextBinValue : public Value +{ + +#include "TextBinValue-generated.h" + + TextBinValue *clone(); + + bool isBinary() { parse(); return mIsBinary_; } + TQByteArray data() { parse(); return mData_; } + TQString url() { parse(); return mUrl_; } + + void setData( const TQByteArray &data ) + { + mData_ = data; + mIsBinary_ = true; + assembled_ = false; + } + + void setUrl( const TQString &url ) + { + mUrl_ = url; + mIsBinary_ = false; + assembled_ = false; + } + + private: + int mIsBinary_; + TQByteArray mData_; + TQString mUrl_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTextListValue.h b/tdeabc/vcard/include/VCardTextListValue.h new file mode 100644 index 000000000..53760c75a --- /dev/null +++ b/tdeabc/vcard/include/VCardTextListValue.h @@ -0,0 +1,51 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TEXTLISTVALUE_H +#define TEXTLISTVALUE_H + +#include <tqstrlist.h> + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TextListValue : public Value +{ + +#include "TextListValue-generated.h" + + unsigned int numValues(); + TQCString value(unsigned int); + + private: + + TQStrList valueList_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTextParam.h b/tdeabc/vcard/include/VCardTextParam.h new file mode 100644 index 000000000..d593c0578 --- /dev/null +++ b/tdeabc/vcard/include/VCardTextParam.h @@ -0,0 +1,44 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TEXTPARAM_H +#define TEXTPARAM_H + +#include <tqcstring.h> + +#include <VCardParam.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TextParam : public Param +{ + +#include "TextParam-generated.h" + + private: +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardTextValue.h b/tdeabc/vcard/include/VCardTextValue.h new file mode 100644 index 000000000..66eed32a8 --- /dev/null +++ b/tdeabc/vcard/include/VCardTextValue.h @@ -0,0 +1,41 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TEXTVALUE_H +#define TEXTVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT TextValue : public Value +{ +#include "TextValue-generated.h" + + TextValue *clone(); +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardURIValue.h b/tdeabc/vcard/include/VCardURIValue.h new file mode 100644 index 000000000..696887774 --- /dev/null +++ b/tdeabc/vcard/include/VCardURIValue.h @@ -0,0 +1,52 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef URIVALUE_H +#define URIVALUE_H + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT URIValue : public Value +{ +#include "URIValue-generated.h" + + URIValue(const TQCString & scheme, const TQCString & schemeSpecificPart); + + TQCString scheme(); + TQCString schemeSpecificPart(); + + void setScheme (const TQCString &); + void setSchemeSpecificPart (const TQCString &); + + private: + + TQCString scheme_; + TQCString schemeSpecificPart_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardUTCValue.h b/tdeabc/vcard/include/VCardUTCValue.h new file mode 100644 index 000000000..cb09ccf00 --- /dev/null +++ b/tdeabc/vcard/include/VCardUTCValue.h @@ -0,0 +1,58 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef UTCVALUE_H +#define UTCVALUE_H + +#include <tqcstring.h> + +#include <VCardValue.h> + +namespace VCARD +{ + +class KVCARD_EXPORT UTCValue : public Value +{ + +#include "UTCValue-generated.h" + + UTCValue *clone(); + + void setPositive( int p ) { positive_ = p; assembled_ = false; } + void setHour( int h ) { hour_ = h; assembled_ = false; } + void setMinute( int m ) { minute_ = m; assembled_ = false; } + + bool positive() { parse(); return positive_; } + unsigned int hour() { parse(); return hour_; } + unsigned int minute() { parse(); return minute_; } + + private: + + bool positive_; + unsigned int hour_; + unsigned int minute_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardVCard.h b/tdeabc/vcard/include/VCardVCard.h new file mode 100644 index 000000000..53563e8c0 --- /dev/null +++ b/tdeabc/vcard/include/VCardVCard.h @@ -0,0 +1,63 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VCARD_VCARD_H +#define VCARD_VCARD_H + +#include <tqstring.h> +#include <tqptrlist.h> + +#include <VCardEnum.h> +#include <VCardEntity.h> +#include <VCardContentLine.h> + +namespace VCARD +{ + +class KVCARD_EXPORT VCard : public Entity +{ + +#include "VCard-generated.h" + + bool has(EntityType); + bool has(const TQCString &); + + void add(const ContentLine &); + void add(const TQCString &); + + ContentLine * contentLine(EntityType); + ContentLine * contentLine(const TQCString &); + + TQCString group() { parse(); return group_; } + + TQPtrList<ContentLine> contentLineList() { parse(); return contentLineList_; } + + private: + + TQCString group_; + TQPtrList<ContentLine> contentLineList_; +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardVCardEntity.h b/tdeabc/vcard/include/VCardVCardEntity.h new file mode 100644 index 000000000..422790c22 --- /dev/null +++ b/tdeabc/vcard/include/VCardVCardEntity.h @@ -0,0 +1,56 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VCARD_ENTITY_H +#define VCARD_ENTITY_H + +#include <tqstring.h> +#include <tqptrlist.h> + +#include <VCardEnum.h> +#include <VCardVCard.h> +#include <VCardEntity.h> + +namespace VCARD +{ + +typedef TQPtrList<VCard> VCardList; +typedef TQPtrListIterator<VCard> VCardListIterator; + +class KVCARD_EXPORT VCardEntity : public Entity +{ + +#include "VCardEntity-generated.h" + + void setCardList(const VCardList & l); + VCardList & cardList(); + + private: + + VCardList cardList_; + +}; + +} + +#endif diff --git a/tdeabc/vcard/include/VCardValue.h b/tdeabc/vcard/include/VCardValue.h new file mode 100644 index 000000000..3c167d70a --- /dev/null +++ b/tdeabc/vcard/include/VCardValue.h @@ -0,0 +1,46 @@ +/* + libvcard - vCard parsing library for vCard version 3.0 + + Copyright (C) 1999 Rik Hemsley [email protected] + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VALUE_H +#define VALUE_H + +#include <tqptrlist.h> + +#include <VCardEntity.h> + +namespace VCARD +{ + +class KVCARD_EXPORT Value : public Entity +{ +#include "Value-generated.h" + + virtual Value *clone() { return new Value( *this ); } +}; + +typedef TQPtrList<Value> ValueList; +typedef TQPtrListIterator<Value> ValueListIterator; + +} + +#endif diff --git a/tdeabc/vcard/include/generated/AdrParam-generated.h b/tdeabc/vcard/include/generated/AdrParam-generated.h new file mode 100644 index 000000000..1afdcd36a --- /dev/null +++ b/tdeabc/vcard/include/generated/AdrParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +AdrParam(); +AdrParam(const AdrParam&); +AdrParam(const TQCString&); +AdrParam & operator = (AdrParam&); +AdrParam & operator = (const TQCString&); +bool operator ==(AdrParam&); +bool operator !=(AdrParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {AdrParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~AdrParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "AdrParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/AdrValue-generated.h b/tdeabc/vcard/include/generated/AdrValue-generated.h new file mode 100644 index 000000000..9882d1186 --- /dev/null +++ b/tdeabc/vcard/include/generated/AdrValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +AdrValue(); +AdrValue(const AdrValue&); +AdrValue(const TQCString&); +AdrValue & operator = (AdrValue&); +AdrValue & operator = (const TQCString&); +bool operator ==(AdrValue&); +bool operator !=(AdrValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {AdrValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~AdrValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "AdrValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/AgentParam-generated.h b/tdeabc/vcard/include/generated/AgentParam-generated.h new file mode 100644 index 000000000..07b87d106 --- /dev/null +++ b/tdeabc/vcard/include/generated/AgentParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +AgentParam(); +AgentParam(const AgentParam&); +AgentParam(const TQCString&); +AgentParam & operator = (AgentParam&); +AgentParam & operator = (const TQCString&); +bool operator ==(AgentParam&); +bool operator !=(AgentParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {AgentParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~AgentParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "AgentParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/AgentValue-generated.h b/tdeabc/vcard/include/generated/AgentValue-generated.h new file mode 100644 index 000000000..e2866bb8f --- /dev/null +++ b/tdeabc/vcard/include/generated/AgentValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +AgentValue(); +AgentValue(const AgentValue&); +AgentValue(const TQCString&); +AgentValue & operator = (AgentValue&); +AgentValue & operator = (const TQCString&); +bool operator ==(AgentValue&); +bool operator !=(AgentValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {AgentValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~AgentValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "AgentValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ClassValue-generated.h b/tdeabc/vcard/include/generated/ClassValue-generated.h new file mode 100644 index 000000000..e10c65568 --- /dev/null +++ b/tdeabc/vcard/include/generated/ClassValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ClassValue(); +ClassValue(const ClassValue&); +ClassValue(const TQCString&); +ClassValue & operator = (ClassValue&); +ClassValue & operator = (const TQCString&); +bool operator ==(ClassValue&); +bool operator !=(ClassValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ClassValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ClassValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "ClassValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ContentLine-generated.h b/tdeabc/vcard/include/generated/ContentLine-generated.h new file mode 100644 index 000000000..ad2ac7649 --- /dev/null +++ b/tdeabc/vcard/include/generated/ContentLine-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ContentLine(); +ContentLine(const ContentLine&); +ContentLine(const TQCString&); +ContentLine & operator = (ContentLine&); +ContentLine & operator = (const TQCString&); +bool operator ==(ContentLine&); +bool operator !=(ContentLine& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ContentLine a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ContentLine(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "ContentLine"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/DateParam-generated.h b/tdeabc/vcard/include/generated/DateParam-generated.h new file mode 100644 index 000000000..75e7ad72d --- /dev/null +++ b/tdeabc/vcard/include/generated/DateParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +DateParam(); +DateParam(const DateParam&); +DateParam(const TQCString&); +DateParam & operator = (DateParam&); +DateParam & operator = (const TQCString&); +bool operator ==(DateParam&); +bool operator !=(DateParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {DateParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~DateParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "DateParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/DateValue-generated.h b/tdeabc/vcard/include/generated/DateValue-generated.h new file mode 100644 index 000000000..cf0eb40d8 --- /dev/null +++ b/tdeabc/vcard/include/generated/DateValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +DateValue(); +DateValue(const DateValue&); +DateValue(const TQCString&); +DateValue & operator = (DateValue&); +DateValue & operator = (const TQCString&); +bool operator ==(DateValue&); +bool operator !=(DateValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {DateValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~DateValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "DateValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/EmailParam-generated.h b/tdeabc/vcard/include/generated/EmailParam-generated.h new file mode 100644 index 000000000..46ae1f80f --- /dev/null +++ b/tdeabc/vcard/include/generated/EmailParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +EmailParam(); +EmailParam(const EmailParam&); +EmailParam(const TQCString&); +EmailParam & operator = (EmailParam&); +EmailParam & operator = (const TQCString&); +bool operator ==(EmailParam&); +bool operator !=(EmailParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {EmailParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~EmailParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "EmailParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/FloatValue-generated.h b/tdeabc/vcard/include/generated/FloatValue-generated.h new file mode 100644 index 000000000..155f52ae1 --- /dev/null +++ b/tdeabc/vcard/include/generated/FloatValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +FloatValue(); +FloatValue(const FloatValue&); +FloatValue(const TQCString&); +FloatValue & operator = (FloatValue&); +FloatValue & operator = (const TQCString&); +bool operator ==(FloatValue&); +bool operator !=(FloatValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {FloatValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~FloatValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "FloatValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/GeoValue-generated.h b/tdeabc/vcard/include/generated/GeoValue-generated.h new file mode 100644 index 000000000..b525e8c21 --- /dev/null +++ b/tdeabc/vcard/include/generated/GeoValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +GeoValue(); +GeoValue(const GeoValue&); +GeoValue(const TQCString&); +GeoValue & operator = (GeoValue&); +GeoValue & operator = (const TQCString&); +bool operator ==(GeoValue&); +bool operator !=(GeoValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {GeoValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~GeoValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "GeoValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/Group-generated.h b/tdeabc/vcard/include/generated/Group-generated.h new file mode 100644 index 000000000..38e1c2a3a --- /dev/null +++ b/tdeabc/vcard/include/generated/Group-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +Group(); +Group(const Group&); +Group(const TQCString&); +Group & operator = (Group&); +Group & operator = (const TQCString&); +bool operator ==(Group&); +bool operator !=(Group& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {Group a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~Group(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "Group"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ImageParam-generated.h b/tdeabc/vcard/include/generated/ImageParam-generated.h new file mode 100644 index 000000000..78a5a97cf --- /dev/null +++ b/tdeabc/vcard/include/generated/ImageParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ImageParam(); +ImageParam(const ImageParam&); +ImageParam(const TQCString&); +ImageParam & operator = (ImageParam&); +ImageParam & operator = (const TQCString&); +bool operator ==(ImageParam&); +bool operator !=(ImageParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ImageParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ImageParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "ImageParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ImageValue-generated.h b/tdeabc/vcard/include/generated/ImageValue-generated.h new file mode 100644 index 000000000..882081fbc --- /dev/null +++ b/tdeabc/vcard/include/generated/ImageValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ImageValue(); +ImageValue(const ImageValue&); +ImageValue(const TQCString&); +ImageValue & operator = (ImageValue&); +ImageValue & operator = (const TQCString&); +bool operator ==(ImageValue&); +bool operator !=(ImageValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ImageValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ImageValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "ImageValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ImgParam-generated.h b/tdeabc/vcard/include/generated/ImgParam-generated.h new file mode 100644 index 000000000..04132c857 --- /dev/null +++ b/tdeabc/vcard/include/generated/ImgParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ImgParam(); +ImgParam(const ImgParam&); +ImgParam(const TQCString&); +ImgParam & operator = (ImgParam&); +ImgParam & operator = (const TQCString&); +bool operator ==(ImgParam&); +bool operator !=(ImgParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ImgParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ImgParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +virtual const char * className() const { return "ImgParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ImgValue-generated.h b/tdeabc/vcard/include/generated/ImgValue-generated.h new file mode 100644 index 000000000..0774de9bf --- /dev/null +++ b/tdeabc/vcard/include/generated/ImgValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +ImgValue(); +ImgValue(const ImgValue&); +ImgValue(const TQCString&); +ImgValue & operator = (ImgValue&); +ImgValue & operator = (const TQCString&); +bool operator ==(ImgValue&); +bool operator !=(ImgValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {ImgValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~ImgValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +virtual const char * className() const { return "ImgValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/LangValue-generated.h b/tdeabc/vcard/include/generated/LangValue-generated.h new file mode 100644 index 000000000..c4930c59e --- /dev/null +++ b/tdeabc/vcard/include/generated/LangValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +LangValue(); +LangValue(const LangValue&); +LangValue(const TQCString&); +LangValue & operator = (LangValue&); +LangValue & operator = (const TQCString&); +bool operator ==(LangValue&); +bool operator !=(LangValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {LangValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~LangValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "LangValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/NValue-generated.h b/tdeabc/vcard/include/generated/NValue-generated.h new file mode 100644 index 000000000..d78715ec0 --- /dev/null +++ b/tdeabc/vcard/include/generated/NValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +NValue(); +NValue(const NValue&); +NValue(const TQCString&); +NValue & operator = (NValue&); +NValue & operator = (const TQCString&); +bool operator ==(NValue&); +bool operator !=(NValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {NValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~NValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "NValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/Name-generated.h b/tdeabc/vcard/include/generated/Name-generated.h new file mode 100644 index 000000000..17d56e680 --- /dev/null +++ b/tdeabc/vcard/include/generated/Name-generated.h @@ -0,0 +1,22 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +V_Name(); +V_Name(const V_Name&); +V_Name(const TQCString&); +V_Name & operator = (V_Name&); +V_Name & operator = (const TQCString&); +bool operator ==(V_Name&); +bool operator !=(V_Name& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {V_Name a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~V_Name(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/OrgValue-generated.h b/tdeabc/vcard/include/generated/OrgValue-generated.h new file mode 100644 index 000000000..661ecf5a3 --- /dev/null +++ b/tdeabc/vcard/include/generated/OrgValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +OrgValue(); +OrgValue(const OrgValue&); +OrgValue(const TQCString&); +OrgValue & operator = (OrgValue&); +OrgValue & operator = (const TQCString&); +bool operator ==(OrgValue&); +bool operator !=(OrgValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {OrgValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~OrgValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "OrgValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/Param-generated.h b/tdeabc/vcard/include/generated/Param-generated.h new file mode 100644 index 000000000..bf63e7166 --- /dev/null +++ b/tdeabc/vcard/include/generated/Param-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +Param(); +Param(const Param&); +Param(const TQCString&); +Param & operator = (Param&); +Param & operator = (const TQCString&); +bool operator ==(Param&); +bool operator !=(Param& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {Param a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~Param(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "Param"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ParamName-generated.h b/tdeabc/vcard/include/generated/ParamName-generated.h new file mode 100644 index 000000000..60b1e12d5 --- /dev/null +++ b/tdeabc/vcard/include/generated/ParamName-generated.h @@ -0,0 +1,22 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +V_ParamName(); +V_ParamName(const V_ParamName&); +V_ParamName(const TQCString&); +V_ParamName & operator = (V_ParamName&); +V_ParamName & operator = (const TQCString&); +bool operator ==(V_ParamName&); +bool operator !=(V_ParamName& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {V_ParamName a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~V_ParamName(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/ParamValue-generated.h b/tdeabc/vcard/include/generated/ParamValue-generated.h new file mode 100644 index 000000000..f31a166c6 --- /dev/null +++ b/tdeabc/vcard/include/generated/ParamValue-generated.h @@ -0,0 +1,22 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +V_ParamValue(); +V_ParamValue(const V_ParamValue&); +V_ParamValue(const TQCString&); +V_ParamValue & operator = (V_ParamValue&); +V_ParamValue & operator = (const TQCString&); +bool operator ==(V_ParamValue&); +bool operator !=(V_ParamValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {V_ParamValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~V_ParamValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/PhoneNumberValue-generated.h b/tdeabc/vcard/include/generated/PhoneNumberValue-generated.h new file mode 100644 index 000000000..f0eb6b4f4 --- /dev/null +++ b/tdeabc/vcard/include/generated/PhoneNumberValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +PhoneNumberValue(); +PhoneNumberValue(const PhoneNumberValue&); +PhoneNumberValue(const TQCString&); +PhoneNumberValue & operator = (PhoneNumberValue&); +PhoneNumberValue & operator = (const TQCString&); +bool operator ==(PhoneNumberValue&); +bool operator !=(PhoneNumberValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {PhoneNumberValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~PhoneNumberValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "PhoneNumberValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/SoundValue-generated.h b/tdeabc/vcard/include/generated/SoundValue-generated.h new file mode 100644 index 000000000..64081be0b --- /dev/null +++ b/tdeabc/vcard/include/generated/SoundValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +SoundValue(); +SoundValue(const SoundValue&); +SoundValue(const TQCString&); +SoundValue & operator = (SoundValue&); +SoundValue & operator = (const TQCString&); +bool operator ==(SoundValue&); +bool operator !=(SoundValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {SoundValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~SoundValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "SoundValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/SourceParam-generated.h b/tdeabc/vcard/include/generated/SourceParam-generated.h new file mode 100644 index 000000000..e3b13bca1 --- /dev/null +++ b/tdeabc/vcard/include/generated/SourceParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +SourceParam(); +SourceParam(const SourceParam&); +SourceParam(const TQCString&); +SourceParam & operator = (SourceParam&); +SourceParam & operator = (const TQCString&); +bool operator ==(SourceParam&); +bool operator !=(SourceParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {SourceParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~SourceParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "SourceParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TelParam-generated.h b/tdeabc/vcard/include/generated/TelParam-generated.h new file mode 100644 index 000000000..9f8f24270 --- /dev/null +++ b/tdeabc/vcard/include/generated/TelParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TelParam(); +TelParam(const TelParam&); +TelParam(const TQCString&); +TelParam & operator = (TelParam&); +TelParam & operator = (const TQCString&); +bool operator ==(TelParam&); +bool operator !=(TelParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TelParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TelParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TelParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TelValue-generated.h b/tdeabc/vcard/include/generated/TelValue-generated.h new file mode 100644 index 000000000..600da7727 --- /dev/null +++ b/tdeabc/vcard/include/generated/TelValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TelValue(); +TelValue(const TelValue&); +TelValue(const TQCString&); +TelValue & operator = (TelValue&); +TelValue & operator = (const TQCString&); +bool operator ==(TelValue&); +bool operator !=(TelValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TelValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TelValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TelValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextBinParam-generated.h b/tdeabc/vcard/include/generated/TextBinParam-generated.h new file mode 100644 index 000000000..37dc56e55 --- /dev/null +++ b/tdeabc/vcard/include/generated/TextBinParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextBinParam(); +TextBinParam(const TextBinParam&); +TextBinParam(const TQCString&); +TextBinParam & operator = (TextBinParam&); +TextBinParam & operator = (const TQCString&); +bool operator ==(TextBinParam&); +bool operator !=(TextBinParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextBinParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextBinParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextBinParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextBinValue-generated.h b/tdeabc/vcard/include/generated/TextBinValue-generated.h new file mode 100644 index 000000000..4c9580421 --- /dev/null +++ b/tdeabc/vcard/include/generated/TextBinValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextBinValue(); +TextBinValue(const TextBinValue&); +TextBinValue(const TQCString&); +TextBinValue & operator = (TextBinValue&); +TextBinValue & operator = (const TQCString&); +bool operator ==(TextBinValue&); +bool operator !=(TextBinValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextBinValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextBinValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextBinValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextListValue-generated.h b/tdeabc/vcard/include/generated/TextListValue-generated.h new file mode 100644 index 000000000..8babb0d9f --- /dev/null +++ b/tdeabc/vcard/include/generated/TextListValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextListValue(); +TextListValue(const TextListValue&); +TextListValue(const TQCString&); +TextListValue & operator = (TextListValue&); +TextListValue & operator = (const TQCString&); +bool operator ==(TextListValue&); +bool operator !=(TextListValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextListValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextListValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextListValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextNSParam-generated.h b/tdeabc/vcard/include/generated/TextNSParam-generated.h new file mode 100644 index 000000000..bd8e74b07 --- /dev/null +++ b/tdeabc/vcard/include/generated/TextNSParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextNSParam(); +TextNSParam(const TextNSParam&); +TextNSParam(const TQCString&); +TextNSParam & operator = (TextNSParam&); +TextNSParam & operator = (const TQCString&); +bool operator ==(TextNSParam&); +bool operator !=(TextNSParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextNSParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextNSParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextNSParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextParam-generated.h b/tdeabc/vcard/include/generated/TextParam-generated.h new file mode 100644 index 000000000..54ae611a5 --- /dev/null +++ b/tdeabc/vcard/include/generated/TextParam-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextParam(); +TextParam(const TextParam&); +TextParam(const TQCString&); +TextParam & operator = (TextParam&); +TextParam & operator = (const TQCString&); +bool operator ==(TextParam&); +bool operator !=(TextParam& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextParam a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextParam(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextParam"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/TextValue-generated.h b/tdeabc/vcard/include/generated/TextValue-generated.h new file mode 100644 index 000000000..5b56b54a7 --- /dev/null +++ b/tdeabc/vcard/include/generated/TextValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +TextValue(); +TextValue(const TextValue&); +TextValue(const TQCString&); +TextValue & operator = (TextValue&); +TextValue & operator = (const TQCString&); +bool operator ==(TextValue&); +bool operator !=(TextValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {TextValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~TextValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "TextValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/URIValue-generated.h b/tdeabc/vcard/include/generated/URIValue-generated.h new file mode 100644 index 000000000..5a691e6d6 --- /dev/null +++ b/tdeabc/vcard/include/generated/URIValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +URIValue(); +URIValue(const URIValue&); +URIValue(const TQCString&); +URIValue & operator = (URIValue&); +URIValue & operator = (const TQCString&); +bool operator ==(URIValue&); +bool operator !=(URIValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {URIValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~URIValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "URIValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/UTCValue-generated.h b/tdeabc/vcard/include/generated/UTCValue-generated.h new file mode 100644 index 000000000..0c6edfb46 --- /dev/null +++ b/tdeabc/vcard/include/generated/UTCValue-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +UTCValue(); +UTCValue(const UTCValue&); +UTCValue(const TQCString&); +UTCValue & operator = (UTCValue&); +UTCValue & operator = (const TQCString&); +bool operator ==(UTCValue&); +bool operator !=(UTCValue& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {UTCValue a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~UTCValue(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "UTCValue"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/VCard-generated.h b/tdeabc/vcard/include/generated/VCard-generated.h new file mode 100644 index 000000000..4f36d11da --- /dev/null +++ b/tdeabc/vcard/include/generated/VCard-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +VCard(); +VCard(const VCard&); +VCard(const TQCString&); +VCard & operator = (VCard&); +VCard & operator = (const TQCString&); +bool operator ==(VCard&); +bool operator !=(VCard& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {VCard a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~VCard(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "VCard"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/VCardEntity-generated.h b/tdeabc/vcard/include/generated/VCardEntity-generated.h new file mode 100644 index 000000000..4e973e62a --- /dev/null +++ b/tdeabc/vcard/include/generated/VCardEntity-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +VCardEntity(); +VCardEntity(const VCardEntity&); +VCardEntity(const TQCString&); +VCardEntity & operator = (VCardEntity&); +VCardEntity & operator = (const TQCString&); +bool operator ==(VCardEntity&); +bool operator !=(VCardEntity& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {VCardEntity a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~VCardEntity(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "VCardEntity"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/Value-generated.h b/tdeabc/vcard/include/generated/Value-generated.h new file mode 100644 index 000000000..935d137b6 --- /dev/null +++ b/tdeabc/vcard/include/generated/Value-generated.h @@ -0,0 +1,23 @@ +// XXX Automatically generated. DO NOT EDIT! XXX // + +public: +Value(); +Value(const Value&); +Value(const TQCString&); +Value & operator = (Value&); +Value & operator = (const TQCString&); +bool operator ==(Value&); +bool operator !=(Value& x) {return !(*this==x);} +bool operator ==(const TQCString& s) {Value a(s);return(*this==a);} +bool operator != (const TQCString& s) {return !(*this == s);} + +virtual ~Value(); +void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;} + +void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;} + +void _parse(); +void _assemble(); +const char * className() const { return "Value"; } + +// End of automatically generated code // diff --git a/tdeabc/vcard/include/generated/generate b/tdeabc/vcard/include/generated/generate new file mode 100755 index 000000000..926dbf136 --- /dev/null +++ b/tdeabc/vcard/include/generated/generate @@ -0,0 +1,2 @@ +#!/bin/sh +cat headerBodies | awk -f generateHeaders.awk diff --git a/tdeabc/vcard/include/generated/generateHeaders.awk b/tdeabc/vcard/include/generated/generateHeaders.awk new file mode 100755 index 000000000..471db11b4 --- /dev/null +++ b/tdeabc/vcard/include/generated/generateHeaders.awk @@ -0,0 +1,41 @@ +#!/bin/awk -f + +{ + outfile = $1 "-generated.h" + name = $1 + + OFS="" + + print "// XXX Automatically generated. DO NOT EDIT! XXX //\n" > outfile + print "// WARNING! All changes made in this file will be lost!\n" > outfile + + if ($2 == "v") { pre = "virtual " } else { pre = "" } + + print "public:" >> outfile + print name "();" >> outfile + print name "(const " name "&);" >> outfile + print name "(const QCString&);" >> outfile + print pre name " & operator = (" name "&);" >> outfile + print pre name " & operator = (const QCString&);" >> outfile + print pre "bool operator ==(" name "&);" >> outfile + print pre "bool operator !=(" name "& x) {return !(*this==x);}" \ + >> outfile + print pre "bool operator ==(const QCString& s) {" name " a(s);" \ + "return(*this==a);} " >> outfile + print pre "bool operator != (const QCString& s) {return !(*this == s);}\n" \ + >> outfile + print "virtual ~" name "();" >> outfile + print pre "void parse() " \ + "{if(!parsed_) _parse();parsed_=true;assembled_=false;}\n" \ + >> outfile + print pre "void assemble() " \ + "{if(assembled_) return;parse();_assemble();assembled_=true;}\n" \ + >> outfile + print pre "void _parse();" >> outfile + print pre "void _assemble();" >> outfile + print pre "const char * className() const { return \"" name "\"; }" \ + >> outfile + + print "\n// End of automatically generated code //" >> outfile +} + diff --git a/tdeabc/vcard/include/generated/headerBodies b/tdeabc/vcard/include/generated/headerBodies new file mode 100644 index 000000000..5e77b2b5e --- /dev/null +++ b/tdeabc/vcard/include/generated/headerBodies @@ -0,0 +1,34 @@ +AdrParam Param +AdrValue Value +AgentParam Param +ContentLine Entity +DateParam Param +DateValue Value +EmailParam Param +GeoValue Value +Group Entity +ImageParam Param +ImageValue Value +LangValue Value +NValue Value +Param Entity +PhoneNumberValue Value +SourceParam Param +TelParam Param +TextParam Param +TextNSParam Param +TextValue Value +TextBinParam Param +URIValue Value +VCard Entity +VCardEntity Entity +Value Entity +SoundValue Value +AgentValue Value +TelValue Value +TextBinValue Value +OrgValue Value +UTCValue Value +ClassValue Value +FloatValue Value +TextListValue Value diff --git a/tdeabc/vcard/testread.cpp b/tdeabc/vcard/testread.cpp new file mode 100644 index 000000000..3a33c7d54 --- /dev/null +++ b/tdeabc/vcard/testread.cpp @@ -0,0 +1,129 @@ +#include <iostream> +#include <stdlib.h> +#include <assert.h> + +#include <tqfile.h> +#include <tqtextstream.h> + +#include <VCard.h> + +using namespace std; + +int main(int argc, char * argv[]) +{ + if (argc != 2) { + cerr << "Usage: " << argv[0] << " <filename>" << endl; + exit(1); + } + + TQFile f(argv[1]); + + TQCString str; + + if (!f.open(IO_ReadOnly)) { + cerr << "Couldn't open file \"" << argv[1] << endl; + exit(1); + } + + TQTextStream t(&f); + + while (!t.eof()) + str += t.readLine().utf8() + '\n'; + + using namespace VCARD; + + // Iterate through all vCards in the file. + + cout << "--------- begin ----------" << endl; + cout << str.data(); + cout << "--------- end ----------" << endl; + + VCardEntity e(str); + + VCardListIterator it(e.cardList()); + + for (; it.current(); ++it) { + + cerr << "****************** VCARD ********************" << endl; + + // Create a vcard using the string representation. + VCard & v (*it.current()); + + if (v.has(EntityEmail)) { + cerr << "Email parameter found" << endl; + + TQCString s = v.contentLine(EntityEmail)->value()->asString(); + + cerr << "Email value == " << s << endl; + } + + if (v.has(EntityNickname)) { + cerr << "Nickname parameter found" << endl; + + cerr << "Nickname value == " << + v.contentLine(EntityNickname)->value()->asString() << + endl; + } + + if (v.has(EntityRevision)) { + + cerr << "Revision parameter found" << endl; + + DateValue * d = + (DateValue *) + v.contentLine(EntityRevision)->value(); + + assert(d != 0); + + cerr << "Revision date: " << endl; + cerr << "Day : " << d->day() << endl; + cerr << "Month : " << d->month() << endl; + cerr << "Year : " << d->year() << endl; + + if (d->hasTime()) { + cerr << "Revision date has a time component" << endl; + cerr << "Revision time: " << endl; + cerr << "Hour : " << d->hour() << endl; + cerr << "Minute : " << d->minute() << endl; + cerr << "Second : " << d->second() << endl; + + } + else cerr << "Revision date does NOT have a time component" << endl; + } + + if (v.has(EntityURL)) { + cerr << "URL Parameter found" << endl; + + cerr << "URL Value == " << + v.contentLine(EntityURL)->value()->asString() << + endl; + + URIValue * urlVal = + (URIValue *)v.contentLine(EntityURL)->value(); + + assert(urlVal != 0); + + cerr << "URL scheme == " << + urlVal->scheme() << endl; + + cerr << "URL scheme specific part == " << + urlVal->schemeSpecificPart() << endl; + } + + if (v.has(EntityN)) { + cerr << "N Parameter found" << endl; + + NValue * n = + (NValue *)(v.contentLine(EntityN)->value()); + + cerr << "Family name == " << n->family() << endl; + cerr << "Given name == " << n->given() << endl; + cerr << "Middle name == " << n->middle() << endl; + cerr << "Prefix == " << n->prefix() << endl; + cerr << "Suffix == " << n->suffix() << endl; + } + + cerr << "***************** END VCARD ******************" << endl; + } +} + diff --git a/tdeabc/vcard/testwrite.cpp b/tdeabc/vcard/testwrite.cpp new file mode 100644 index 000000000..42b76c80f --- /dev/null +++ b/tdeabc/vcard/testwrite.cpp @@ -0,0 +1,41 @@ +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdecmdlineargs.h> + +#include <VCard.h> + +int main(int argc,char **argv) +{ + TDEAboutData aboutData("testwrite",I18N_NOOP("TestWritevCard"),"0.1"); + TDECmdLineArgs::init(argc,argv,&aboutData); + + TDEApplication app; + + kdDebug() << "Test Write VCard" << endl; + + using namespace VCARD; + + VCard v; + + ContentLine cl1; + cl1.setName(EntityTypeToParamName(EntityName)); + cl1.setValue(new TextValue("Hans Wurst")); + v.add(cl1); + + ContentLine cl2; + cl2.setName(EntityTypeToParamName(EntityTelephone)); + cl2.setValue(new TelValue("12345")); + ParamList p; + p.append( new TelParam("home") ); + p.append( new TelParam("fax") ); + cl2.setParamList( p ); + v.add(cl2); + + TQCString str = v.asString(); + + kdDebug() << "--- VCard begin ---" << endl + << str + << "--- VCard end ---" << endl; +} diff --git a/tdeabc/vcard/vCard-all.cpp b/tdeabc/vcard/vCard-all.cpp new file mode 100644 index 000000000..07bbcd2bb --- /dev/null +++ b/tdeabc/vcard/vCard-all.cpp @@ -0,0 +1,37 @@ +#include "AdrParam.cpp" +#include "AdrValue.cpp" +#include "AgentParam.cpp" +#include "AgentValue.cpp" +#include "ClassValue.cpp" +#include "ContentLine.cpp" +#include "DateParam.cpp" +#include "DateValue.cpp" +#include "EmailParam.cpp" +#include "Entity.cpp" +#include "Enum.cpp" +#include "FloatValue.cpp" +#include "GeoValue.cpp" +#include "ImageParam.cpp" +#include "ImageValue.cpp" +#include "ImgValue.cpp" +#include "LangValue.cpp" +#include "NValue.cpp" +#include "OrgValue.cpp" +#include "Param.cpp" +#include "PhoneNumberValue.cpp" +#include "RToken.cpp" +#include "SoundValue.cpp" +#include "SourceParam.cpp" +#include "TelParam.cpp" +#include "TelValue.cpp" +#include "TextBinParam.cpp" +#include "TextBinValue.cpp" +#include "TextListValue.cpp" +#include "TextParam.cpp" +#include "TextValue.cpp" +#include "URIValue.cpp" +#include "UTCValue.cpp" +#include "VCard.cpp" +#include "VCardEntity.cpp" +#include "Value.cpp" + diff --git a/tdeabc/vcard21parser.cpp b/tdeabc/vcard21parser.cpp new file mode 100644 index 000000000..46581b411 --- /dev/null +++ b/tdeabc/vcard21parser.cpp @@ -0,0 +1,608 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Mark Westcott <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqmap.h> +#include <tqregexp.h> +#include <kmdcodec.h> + +#include "vcard21parser.h" +#include "vcardconverter.h" + +using namespace TDEABC; + +bool VCardLineX::isValid() const +{ + // Invalid: if it is "begin:vcard" or "end:vcard" + if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) + return false; + + if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line + return true; + + // This is long but it makes it a bit faster (and saves me from using + // a tree which is probably the ideal situation, but a bit memory heavy) + switch( name[0] ) { + case 'a': + if ( name == VCARD_ADR && qualified && + (qualifiers.contains(VCARD_ADR_DOM) || + qualifiers.contains(VCARD_ADR_INTL) || + qualifiers.contains(VCARD_ADR_POSTAL) || + qualifiers.contains(VCARD_ADR_HOME) || + qualifiers.contains(VCARD_ADR_WORK) || + qualifiers.contains(VCARD_ADR_PREF) + ) ) + return true; + + if ( name == VCARD_AGENT ) + return true; + break; + + case 'b': + if ( name == VCARD_BDAY ) + return true; + break; + + case 'c': + if ( name == VCARD_CATEGORIES ) + return true; + if ( name == VCARD_CLASS && qualified && + (qualifiers.contains(VCARD_CLASS_PUBLIC) || + qualifiers.contains(VCARD_CLASS_PRIVATE) || + qualifiers.contains(VCARD_CLASS_CONFIDENTIAL) + ) ) + return true; + break; + + case 'e': + if ( name == VCARD_EMAIL && qualified && + (qualifiers.contains(VCARD_EMAIL_INTERNET) || + qualifiers.contains(VCARD_EMAIL_PREF) || + qualifiers.contains(VCARD_EMAIL_X400) + ) ) + return true; + break; + + case 'f': + if ( name == VCARD_FN ) + return true; + break; + + case 'g': + if ( name == VCARD_GEO ) + return true; + break; + + case 'k': + if ( name == VCARD_KEY && qualified && + (qualifiers.contains(VCARD_KEY_X509) || + qualifiers.contains(VCARD_KEY_PGP) + ) ) + return true; + break; + + case 'l': + if ( name == VCARD_LABEL ) + return true; + if ( name == VCARD_LOGO ) + return true; + break; + + case 'm': + if ( name == VCARD_MAILER ) + return true; + break; + + case 'n': + if ( name == VCARD_N ) + return true; + if ( name == VCARD_NAME ) + return true; + if ( name == VCARD_NICKNAME ) + return true; + if ( name == VCARD_NOTE ) + return true; + break; + + case 'o': + if ( name == VCARD_ORG ) + return true; + break; + + case 'p': + if ( name == VCARD_PHOTO ) + return true; + if ( name == VCARD_PROFILE ) + return true; + if ( name == VCARD_PRODID ) + return true; + break; + + case 'r': + if ( name == VCARD_ROLE ) + return true; + if ( name == VCARD_REV ) + return true; + break; + + case 's': + if ( name == VCARD_SOURCE ) + return true; + if ( name == VCARD_SOUND ) + return true; + break; + + case 't': + if ( name == VCARD_TEL && qualified && + (qualifiers.contains(VCARD_TEL_HOME) || + qualifiers.contains(VCARD_TEL_WORK) || + qualifiers.contains(VCARD_TEL_PREF) || + qualifiers.contains(VCARD_TEL_VOICE) || + qualifiers.contains(VCARD_TEL_FAX) || + qualifiers.contains(VCARD_TEL_MSG) || + qualifiers.contains(VCARD_TEL_CELL) || + qualifiers.contains(VCARD_TEL_PAGER) || + qualifiers.contains(VCARD_TEL_BBS) || + qualifiers.contains(VCARD_TEL_MODEM) || + qualifiers.contains(VCARD_TEL_CAR) || + qualifiers.contains(VCARD_TEL_ISDN) || + qualifiers.contains(VCARD_TEL_VIDEO) || + qualifiers.contains(VCARD_TEL_PCS) + ) ) + return true; + if ( name == VCARD_TZ ) + return true; + if ( name == VCARD_TITLE ) + return true; + break; + + case 'u': + if ( name == VCARD_URL ) + return true; + if ( name == VCARD_UID ) + return true; + break; + + case 'v': + if ( name == VCARD_VERSION ) + return true; + break; + default: + break; + } + + return false; +} + + +VCard21Parser::VCard21Parser() +{ +} + +VCard21Parser::~VCard21Parser() +{ +} + +void VCard21Parser::readFromString(TDEABC::AddressBook *addressbook, const TQString &data) +{ + TDEABC::Addressee mAddressee = readFromString(data); + addressbook->insertAddressee(mAddressee); +} + +TDEABC::Addressee VCard21Parser::readFromString( const TQString &data) +{ + TDEABC::Addressee addressee; + VCard21ParserImpl *vCard = VCard21ParserImpl::parseVCard(data); + TQString tmpStr; + + // Check if parsing failed + if (vCard == 0) + { + kdDebug() << "Parsing failed" << endl; + return addressee; + } + //set the addressees name and formated name + TQStringList tmpList = vCard->getValues(VCARD_N); + TQString formattedName = ""; + if (tmpList.count() > 0) + addressee.setFamilyName(tmpList[0]); + if (tmpList.count() > 1) + addressee.setGivenName(tmpList[1]); + if (tmpList.count() > 2) + addressee.setAdditionalName(tmpList[2]); + if (tmpList.count() > 3) + addressee.setPrefix(tmpList[3]); + if (tmpList.count() > 4) + addressee.setSuffix(tmpList[4]); + + tmpStr = (vCard->getValue(VCARD_FN)); + if (!tmpStr.isEmpty()) + addressee.setFormattedName(tmpStr); + + //set the addressee's nick name + tmpStr = vCard->getValue(VCARD_NICKNAME); + addressee.setNickName(tmpStr); + //set the addressee's organization + tmpStr = vCard->getValue(VCARD_ORG); + addressee.setOrganization(tmpStr); + //set the addressee's title + tmpStr = vCard->getValue(VCARD_TITLE); + addressee.setTitle(tmpStr); + //set the addressee's email - we can only deal with two. The preferenced one and one other. + tmpStr = vCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); + addressee.insertEmail(tmpStr, false); + tmpStr = vCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); + addressee.insertEmail(tmpStr, true); + //set the addressee's url + tmpStr = vCard->getValue(VCARD_URL); + if (tmpStr.isEmpty()) tmpStr = vCard->getValue(VCARD_URL, VCARD_ADR_WORK); + if (tmpStr.isEmpty()) tmpStr = vCard->getValue(VCARD_URL, VCARD_ADR_HOME); + if (!tmpStr.isEmpty()) { + addressee.setUrl(KURL(tmpStr)); + } + + //set the addressee's birthday + tmpStr = vCard->getValue(VCARD_BDAY); + addressee.setBirthday(VCardStringToDate(tmpStr)); + + //set the addressee's phone numbers + for ( TQValueListIterator<VCardLineX> i = vCard->_vcdata->begin();i != vCard->_vcdata->end(); ++i ) { + if ( (*i).name == VCARD_TEL ) { + int type = 0; + if ( (*i).qualified ) { + if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) + type |= PhoneNumber::Home; + if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) + type |= PhoneNumber::Work; + if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) + type |= PhoneNumber::Pref; + // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) + // type |= PhoneNumber::Voice; + if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) + type |= PhoneNumber::Fax; + if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) + type |= PhoneNumber::Msg; + if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) + type |= PhoneNumber::Cell; + if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) + type |= PhoneNumber::Pager; + if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) + type |= PhoneNumber::Bbs; + if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) + type |= PhoneNumber::Modem; + if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) + type |= PhoneNumber::Car; + if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) + type |= PhoneNumber::Isdn; + if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) + type |= PhoneNumber::Video; + if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) + type |= PhoneNumber::Pcs; + } + addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); + } + } + + //set the addressee's addresses + for ( TQValueListIterator<VCardLineX> i = vCard->_vcdata->begin();i != vCard->_vcdata->end(); ++i ) { + if ( (*i).name == VCARD_ADR ) { + int type = 0; + if ( (*i).qualified ) { + if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) + type |= Address::Dom; + if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) + type |= Address::Intl; + if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) + type |= Address::Postal; + if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) + type |= Address::Parcel; + if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) + type |= Address::Home; + if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) + type |= Address::Work; + if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) + type |= Address::Pref; + } + addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); + } + } + + //set the addressee's delivery label + tmpStr = vCard->getValue(VCARD_LABEL); + if (!tmpStr.isEmpty()) { + tmpStr.replace("\r\n","\n"); + Address tmpAddress; + tmpAddress.setLabel(tmpStr); + addressee.insertAddress(tmpAddress); + } + + //set the addressee's notes + tmpStr = vCard->getValue(VCARD_NOTE); + tmpStr.replace("\r\n","\n"); + addressee.setNote(tmpStr); + + //set the addressee's timezone + tmpStr = vCard->getValue(VCARD_TZ); + TimeZone tmpZone(tmpStr.toInt()); + addressee.setTimeZone(tmpZone); + + //set the addressee's geographical position + tmpList = vCard->getValues(VCARD_GEO); + if (tmpList.count()==2) + { + tmpStr = tmpList[0]; + float glat = tmpStr.toFloat(); + tmpStr = tmpList[1]; + float glong = tmpStr.toFloat(); + Geo tmpGeo(glat,glong); + addressee.setGeo(tmpGeo); + } + + //set the last revision date + tmpStr = vCard->getValue(VCARD_REV); + addressee.setRevision(VCardStringToDate(tmpStr)); + + //set the role of the addressee + tmpStr = vCard->getValue(VCARD_ROLE); + addressee.setRole(tmpStr); + + delete vCard; + + return addressee; +} + + + +TDEABC::Address VCard21Parser::readAddressFromQStringList ( const TQStringList &data, const int type ) +{ + TDEABC::Address mAddress; + mAddress.setType( type ); + + if ( data.count() > 0 ) + mAddress.setPostOfficeBox( data[0] ); + if ( data.count() > 1 ) + mAddress.setExtended( data[1] ); + if ( data.count() > 2 ) + mAddress.setStreet( data[2] ); + if ( data.count() > 3 ) + mAddress.setLocality( data[3] ); + if ( data.count() > 4 ) + mAddress.setRegion( data[4] ); + if ( data.count() > 5 ) + mAddress.setPostalCode( data[5] ); + if ( data.count() > 6 ) + mAddress.setCountry( data[6] ); + + return mAddress; +} + + +VCard21ParserImpl *VCard21ParserImpl::parseVCard( const TQString& vc, int *err ) +{ + int _err = 0; + int _state = VC_STATE_BEGIN; + + TQValueList<VCardLineX> *vcdata; + TQValueList<TQString> lines; + + vcdata = new TQValueList<VCardLineX>; + + lines = TQStringList::split( TQRegExp( "[\x0d\x0a]" ), vc ); + + // for each line in the vCard + for ( TQStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { + VCardLineX _vcl; + + // take spaces off the end - ugly but necessary hack + for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g ) + (*j)[g] = 0; + + // first token: + // verify state, update if necessary + if ( _state & VC_STATE_BEGIN) { + if ( !tqstricmp( (*j).latin1(), VCARD_BEGIN ) ) { + _state = VC_STATE_BODY; + continue; + } else { + _err = VC_ERR_NO_BEGIN; + break; + } + } else if ( _state & VC_STATE_BODY ) { + if ( !tqstricmp( (*j).latin1(), VCARD_END ) ) { + _state |= VC_STATE_END; + break; + } + + // split into two tokens + int colon = (*j).find( ':' ); + if ( colon < 0 ) { + _err = VC_ERR_INVALID_LINE; + break; + } + + TQString key = (*j).left( colon ); + TQString value = (*j).mid( colon + 1 ); + + // check for qualifiers and + // set name, qualified, qualifier(s) + TQStringList keyTokens = TQStringList::split( ';', key ); + bool qp = false, first_pass = true; + bool b64 = false; + + if ( keyTokens.count() > 0 ) { + _vcl.qualified = false; + _vcl.name = keyTokens[ 0 ].lower(); + + for ( TQStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) { + TQString zz = (*z).lower(); + if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) { + qp = true; + } else if ( zz == VCARD_BASE64 ) { + b64 = true; + } else if ( !first_pass ) { + _vcl.qualified = true; + _vcl.qualifiers.append( zz ); + } + first_pass = false; + } + } else { + _err = VC_ERR_INVALID_LINE; + } + + if ( _err != 0 ) + break; + + if ( _vcl.name == VCARD_VERSION ) + _state |= VC_STATE_HAVE_VERSION; + + if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN ) + _state |= VC_STATE_HAVE_N; + + // second token: + // split into tokens by ; + // add to parameters vector + if ( b64 ) { + if ( value[ value.length() - 1 ] != '=' ) + do { + value += *( ++j ); + } while ( (*j)[ (*j).length() - 1 ] != '=' ); + } else { + if ( qp ) { // join any split lines + while ( value[ value.length() - 1 ] == '=' ) { + value.remove( value.length() - 1, 1 ); + value.append(*( ++j )); + } + } + _vcl.parameters = TQStringList::split( ';', value, true ); + if ( qp ) { // decode the quoted printable + for ( TQStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) + *z = KCodecs::quotedPrintableDecode( TQCString((*z).latin1()) ); + } + } + } else { + _err = VC_ERR_INTERNAL; + break; + } + + // validate VCardLineX + if ( !_vcl.isValid() ) { + _err = VC_ERR_INVALID_LINE; + break; + } + + // add to vector + vcdata->append( _vcl ); + } + + // errors to check at the last minute (exit state related) + if ( _err == 0 ) { + if ( !( _state & VC_STATE_END ) ) // we have to have an end!! + _err = VC_ERR_NO_END; + + if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories! + !( _state & VC_STATE_HAVE_VERSION ) ) + _err = VC_ERR_MISSING_MANDATORY; + } + + // set the error message if we can, and only return an object + // if the vCard was valid. + if ( err ) + *err = _err; + + if ( _err != 0 ) { + delete vcdata; + return 0; + } + + return new VCard21ParserImpl( vcdata ); +} + +VCard21ParserImpl::VCard21ParserImpl() + : _vcdata( 0 ) +{ +} + +VCard21ParserImpl::VCard21ParserImpl(TQValueList<VCardLineX> *_vcd) + : _vcdata(_vcd) +{ +} + +VCard21ParserImpl::~VCard21ParserImpl() +{ + delete _vcdata; + _vcdata = 0; +} + +TQString VCard21ParserImpl::getValue(const TQString& name, const TQString& qualifier) +{ + TQString failed; + const TQString lowname = name.lower(); + const TQString lowqualifier = qualifier.lower(); + + for (TQValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { + if ((*i).parameters.count() > 0) + return (*i).parameters[0]; + else return failed; + } + } + return failed; +} + + +TQString VCard21ParserImpl::getValue(const TQString& name) +{ + TQString failed; + const TQString lowname = name.lower(); + + for (TQValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + if ((*i).name == lowname && !(*i).qualified) { + if ((*i).parameters.count() > 0) + return (*i).parameters[0]; + else return failed; + } + } + return failed; +} + + +TQStringList VCard21ParserImpl::getValues(const TQString& name) +{ + const TQString lowname = name.lower(); + for (TQValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + if ((*i).name == lowname && !(*i).qualified) + return (*i).parameters; + } + // failed. + return TQStringList(); +} + +TQStringList VCard21ParserImpl::getValues(const TQString& name, const TQString& qualifier) +{ + const TQString lowname = name.lower(); + const TQString lowqualifier = qualifier.lower(); + for (TQValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) + return (*i).parameters; + } + // failed. + return TQStringList(); +} + + diff --git a/tdeabc/vcard21parser.h b/tdeabc/vcard21parser.h new file mode 100644 index 000000000..a743e65f3 --- /dev/null +++ b/tdeabc/vcard21parser.h @@ -0,0 +1,221 @@ +/* + This file is part of libkabc. + + Copyright (c) 2002 Mark Westcott <[email protected]> + Copyright (c) 2000 George Staikos <[email protected]> + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_VCARD21FORMAT_H +#define KABC_VCARD21FORMAT_H + +#include <tqdatetime.h> +#include <kdebug.h> +#include <tqregexp.h> +#include <tqstring.h> +#include <kurl.h> +#include <tqvaluelist.h> + +#include "addressee.h" +#include "addressbook.h" +#include "phonenumber.h" + + +#define VCARD_BEGIN "begin:vcard" +#define VCARD_END "end:vcard" +#define VCARD_BEGIN_N "begin" +#define VCARD_END_N "end" +#define VCARD_VERSION "version" + +#define VCARD_FN "fn" +#define VCARD_N "n" + +// optional +#define VCARD_NAME "name" +#define VCARD_NICKNAME "nickname" +#define VCARD_PHOTO "photo" +#define VCARD_BDAY "bday" +#define VCARD_ADR "adr" + +// types +#define VCARD_ADR_DOM "dom" +#define VCARD_ADR_INTL "intl" +#define VCARD_ADR_POSTAL "postal" +#define VCARD_ADR_PARCEL "parcel" +#define VCARD_ADR_HOME "home" +#define VCARD_ADR_WORK "work" +#define VCARD_ADR_PREF "pref" +// values +#define VCARD_ADR_POBOX "PO Box" +#define VCARD_ADR_EXTADR "Extended Address" +#define VCARD_ADR_STREET "Street" +#define VCARD_ADR_LOCALITY "Locality" +#define VCARD_ADR_REGION "Region" +#define VCARD_ADR_POSTCODE "Postal Code" +#define VCARD_ADR_COUNTRY "Country Name" +#define VCARD_LABEL "label" +#define VCARD_PROFILE "profile" +#define VCARD_SOURCE "source" +#define VCARD_TEL "tel" +// types +#define VCARD_TEL_HOME "home" +#define VCARD_TEL_WORK "work" +#define VCARD_TEL_PREF "pref" +#define VCARD_TEL_VOICE "voice" +#define VCARD_TEL_FAX "fax" +#define VCARD_TEL_MSG "msg" +#define VCARD_TEL_CELL "cell" +#define VCARD_TEL_PAGER "pager" +#define VCARD_TEL_BBS "bbs" +#define VCARD_TEL_MODEM "modem" +#define VCARD_TEL_CAR "car" +#define VCARD_TEL_ISDN "isdn" +#define VCARD_TEL_VIDEO "video" +#define VCARD_TEL_PCS "pcs" +#define VCARD_EMAIL "email" +// types +#define VCARD_EMAIL_PREF "pref" +#define VCARD_EMAIL_INTERNET "internet" +#define VCARD_EMAIL_X400 "x400" +#define VCARD_TZ "tz" +#define VCARD_GEO "geo" +#define VCARD_MAILER "mailer" +#define VCARD_TITLE "title" +#define VCARD_ROLE "role" +#define VCARD_LOGO "logo" +#define VCARD_AGENT "agent" +#define VCARD_ORG "org" +#define VCARD_CATEGORIES "categories" +#define VCARD_NOTE "note" +#define VCARD_PRODID "prodid" +#define VCARD_REV "rev" +#define VCARD_SOUND "sound" +#define VCARD_UID "uid" +#define VCARD_URL "url" +#define VCARD_CLASS "class" +#define VCARD_CLASS_PUBLIC "public" +#define VCARD_CLASS_PRIVATE "private" +#define VCARD_CLASS_CONFIDENTIAL "confidential" +#define VCARD_KEY "key" +// types +#define VCARD_KEY_X509 "x509" +#define VCARD_KEY_PGP "pgp" + +#define VCARD_QUOTED_PRINTABLE "quoted-printable" +// this one is a temporary hack until we support TYPE=VALUE +#define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" +#define VCARD_BASE64 "base64" + +#define VC_STATE_BEGIN 1 +#define VC_STATE_BODY 2 +#define VC_STATE_END 4 +#define VC_STATE_HAVE_N 8 +#define VC_STATE_HAVE_VERSION 16 + +#define VC_ERR_NO_BEGIN 1 +#define VC_ERR_NO_END 2 +#define VC_ERR_INVALID_LINE 3 +#define VC_ERR_INTERNAL 4 +#define VC_ERR_INVALID_NAME 5 +#define VC_ERR_MISSING_MANDATORY 6 + +namespace TDEABC { + +class AddressBook; + +/** + @deprecated use VCardConverter instead. + */ +class KABC_EXPORT_DEPRECATED VCard21Parser +{ +public: + + /** + * Constructor. + */ + VCard21Parser(); + + /** + * Destructor. + */ + virtual ~VCard21Parser(); + + /** + * Parses a string in vcard2.1 format and saves the single addressees + * to the address book. + * + * @param ab The address book. + * @param str The vcard string. + */ + void readFromString( TDEABC::AddressBook *ab, const TQString &str ); + + /** + * FIXME: we need a writeToString method + * TQString writeToString (TDEABC::AddressBook *); + */ + + /** + * Parses a string in vcard2.1 format and returns the inherent addressee. + */ + TDEABC::Addressee readFromString( const TQString &data); + + /** + * Helper method to store a address. + * + * @param data A string list, that is filled with 'street', 'house number' ... + * @param type The type of the returned address. + */ + static TDEABC::Address readAddressFromQStringList (const TQStringList &data, const int type); +}; + +} + +/** + * @short Helper class + */ +class KABC_EXPORT VCardLineX +{ +public: + TQString name; + bool qualified; + TQValueList<TQString> qualifiers; + TQValueList<TQString> parameters; + bool isValid() const; +}; + +/** + * @short Helper class + */ +class KABC_EXPORT VCard21ParserImpl +{ + friend class VCardLineX; + +public: + VCard21ParserImpl(); + virtual ~VCard21ParserImpl(); + static VCard21ParserImpl *parseVCard(const TQString& vc, int *err = NULL); + TQString getValue(const TQString& name, const TQString& qualifier); + TQString getValue(const TQString& name); + TQStringList getValues(const TQString& name, const TQString& qualifier); + TQStringList getValues(const TQString& name); + + TQValueList<VCardLineX> *_vcdata; + +private: + VCard21ParserImpl (TQValueList<VCardLineX> *_vcd); +}; + +#endif diff --git a/tdeabc/vcardconverter.cpp b/tdeabc/vcardconverter.cpp new file mode 100644 index 000000000..2dff56aa2 --- /dev/null +++ b/tdeabc/vcardconverter.cpp @@ -0,0 +1,129 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "vcard21parser.h" +#include "vcardformatimpl.h" +#include "vcardtool.h" + +#include "vcardconverter.h" + +using namespace TDEABC; + +struct VCardConverter::VCardConverterData +{ + VCard21Parser vcard21parser; + VCardFormatImpl vcard30parser; +}; + +VCardConverter::VCardConverter() + : d( new VCardConverterData ) +{ +} + +VCardConverter::~VCardConverter() +{ + delete d; + d = 0; +} + +TQString VCardConverter::createVCard( const Addressee &addr, Version version ) +{ + Addressee::List list; + list.append( addr ); + + return createVCards( list, version ); +} + +TQString VCardConverter::createVCards( Addressee::List list, Version version ) +{ + VCardTool tool; + + return tool.createVCards( list, ( version == v3_0 ? VCard::v3_0 : VCard::v2_1 ) ); +} + +Addressee VCardConverter::parseVCard( const TQString& vcard ) +{ + Addressee::List list = parseVCards( vcard ); + + return list[ 0 ]; +} + +Addressee::List VCardConverter::parseVCards( const TQString& vcard ) +{ + VCardTool tool; + + return tool.parseVCards( vcard ); +} + +// ---------------------------- deprecated stuff ---------------------------- // + +bool VCardConverter::vCardToAddressee( const TQString &str, Addressee &addr, Version version ) +{ + if ( version == v2_1 ) { + addr = d->vcard21parser.readFromString( str ); + return true; + } + + if ( version == v3_0 ) + return d->vcard30parser.readFromString( str, addr ); + + return false; +} + +bool VCardConverter::addresseeToVCard( const Addressee &addr, TQString &str, Version version ) +{ + if ( version == v2_1 ) + return false; + + if ( version == v3_0 ) + return d->vcard30parser.writeToString( addr, str ); + + return false; +} + + +/* Helper functions */ + +TQString TDEABC::dateToVCardString( const TQDateTime &dateTime ) +{ + return dateTime.toString("yyyyMMddThhmmssZ"); +} + +TQString TDEABC::dateToVCardString( const TQDate &date ) +{ + return date.toString("yyyyMMdd"); +} + +TQDateTime TDEABC::VCardStringToDate( const TQString &dateString ) +{ + TQDate date; + TQTime time; + TQString d( dateString ); + + d = d.remove('-').remove(':'); + + if (d.length()>=8) + date = TQDate( d.mid(0,4).toUInt(), d.mid(4,2).toUInt(), d.mid(6,2).toUInt() ); + if (d.length()>9 && d[8].upper()=='T') + time = TQTime( d.mid(9,2).toUInt(), d.mid(11,2).toUInt(), d.mid(13,2).toUInt() ); + + return TQDateTime( date, time ); +} + diff --git a/tdeabc/vcardconverter.h b/tdeabc/vcardconverter.h new file mode 100644 index 000000000..982c704d4 --- /dev/null +++ b/tdeabc/vcardconverter.h @@ -0,0 +1,163 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_VCARDCONVERTER_H +#define KABC_VCARDCONVERTER_H + +#include <tqstring.h> + +#include "addressee.h" + +namespace TDEABC { + +/** + @short Class to converting contact objects into vCard format and vice versa. + + This class implements reading and writing of contact using from/to the + vCard format. Currently vCard version 2.1 and 3.0 is supported. + + Example: + + \code + + TQFile file( "myfile.vcf" ); + file.open( IO_ReadOnly ); + + TQString data = file.readAll(); + + VCardConverter converter; + Addressee::List list = converter.parseVCards( data ); + + // print formatted name of first contact + tqDebug( "name=%s", list[ 0 ].formattedName().latin1() ); + + \endcode +*/ +class KABC_EXPORT VCardConverter +{ + public: + + /** + @li v2_1 - VCard format version 2.1 + @li v3_0 - VCard format version 3.0 + */ + enum Version + { + v2_1, + v3_0 + }; + + /** + Constructor. + */ + VCardConverter(); + + /** + Destructor. + */ + ~VCardConverter(); + + /** + Creates a string in vCard format which contains the given + contact. + + @param addr The contact object + @param version The version of the generated vCard format + */ + TQString createVCard( const Addressee &addr, Version version = v3_0 ); + + /** + Creates a string in vCard format which contains the given + list of contact. + + @param list The list of contact objects + @param version The version of the generated vCard format + */ + // FIXME: Add error handling + TQString createVCards( Addressee::List list, Version version = v3_0 ); + + // FIXME: Add "createVCards( AddressBook * )" + + /** + Parses a string in vCard format and returns the first contact. + */ + Addressee parseVCard( const TQString& vcard ); + + /** + Parses a string in vCard format and returns a list of contact objects. + */ + // FIXME: Add error handling + Addressee::List parseVCards( const TQString& vcard ); + + // FIXME: Add "bool parseVCards( AddressBook *, const TQString &vcard )" + + /** + @deprecated + */ + bool vCardToAddressee( const TQString&, Addressee &, Version version = v3_0 ) KDE_DEPRECATED; + + /** + @deprecated + */ + bool addresseeToVCard( const Addressee&, TQString&, Version version = v3_0 ) KDE_DEPRECATED; + + private: + /** + Split a string and replaces escaped separators on the fly with + unescaped ones. + */ + TQStringList splitString( const TQChar &sep, const TQString &value ); + + struct VCardConverterData; + VCardConverterData *d; +}; + + +/** + Helper functions + */ + +/** + * Converts a TQDateTime to a date string as it is used in VCard and LDIF files. + * The return value is in the form "yyyyMMddThhmmssZ" (e.g. "20031201T120000Z") + * @param dateTime date and time to be converted + * @since 3.2 + */ +KABC_EXPORT TQString dateToVCardString( const TQDateTime &dateTime ); + +/** + * Converts a TQDate to a short date string as it is used in VCard and LDIF files. + * The return value is in the form "yyyyMMdd" (e.g. "20031201") + * @param date date to be converted + * @since 3.2 + */ +KABC_EXPORT TQString dateToVCardString( const TQDate &date ); + +/** + * Converts a date string as it is used in VCard and LDIF files to a TQDateTime value. + * If the date string does not contain a time value, it will be returned as 00:00:00. + * (e.g. "20031201T120000" will return a TQDateTime for 2003-12-01 at 12:00) + * @param dateString string representing the date and time. + * @since 3.2 + */ +KABC_EXPORT TQDateTime VCardStringToDate( const TQString &dateString ); + +} +#endif diff --git a/tdeabc/vcardformat.cpp b/tdeabc/vcardformat.cpp new file mode 100644 index 000000000..b8bfaa6b6 --- /dev/null +++ b/tdeabc/vcardformat.cpp @@ -0,0 +1,59 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "vcardformatimpl.h" + +#include "vcardformat.h" + +using namespace TDEABC; + +VCardFormat::VCardFormat() +{ + mImpl = new VCardFormatImpl; +} + +VCardFormat::~VCardFormat() +{ + delete mImpl; +} + +bool VCardFormat::load( AddressBook *addressBook, const TQString &fileName ) +{ + TQFile f( fileName ); + if ( !f.open( IO_ReadOnly ) ) return false; + + bool result = mImpl->loadAll( addressBook, 0, &f ); + + f.close(); + + return result; +} + +bool VCardFormat::save( AddressBook *addressBook, const TQString &fileName ) +{ + TQFile f( fileName ); + if ( !f.open( IO_WriteOnly ) ) return false; + + mImpl->saveAll( addressBook, 0, &f ); + + f.close(); + + return true; +} diff --git a/tdeabc/vcardformat.h b/tdeabc/vcardformat.h new file mode 100644 index 000000000..b5d6ff133 --- /dev/null +++ b/tdeabc/vcardformat.h @@ -0,0 +1,49 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_VCARDFORMAT_H +#define KABC_VCARDFORMAT_H + +#include <tqstring.h> + +#include "format.h" + +namespace TDEABC { + +class AddressBook; +class VCardFormatImpl; + +/** + @deprecated use VCardFormatPlugin instead. + */ +class KABC_EXPORT_DEPRECATED VCardFormat : public Format { + public: + VCardFormat(); + virtual ~VCardFormat(); + + bool load( AddressBook *, const TQString &fileName ); + bool save( AddressBook *, const TQString &fileName ); + + private: + VCardFormatImpl *mImpl; +}; + +} + +#endif diff --git a/tdeabc/vcardformatimpl.cpp b/tdeabc/vcardformatimpl.cpp new file mode 100644 index 000000000..e88ab3078 --- /dev/null +++ b/tdeabc/vcardformatimpl.cpp @@ -0,0 +1,1001 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#include <tqfile.h> +#include <tqregexp.h> + +#include <kdebug.h> +#include <kmdcodec.h> +#include <kstandarddirs.h> +#include <tdetempfile.h> + +#include <VCard.h> + +#include "addressbook.h" +#include "vcardformatimpl.h" + +using namespace TDEABC; +using namespace VCARD; + +bool VCardFormatImpl::load( Addressee &addressee, TQFile *file ) +{ + kdDebug(5700) << "VCardFormat::load()" << endl; + + TQByteArray fdata = file->readAll(); + TQCString data(fdata.data(), fdata.size()+1); + + VCardEntity e( data ); + + VCardListIterator it( e.cardList() ); + + if ( it.current() ) { + VCARD::VCard v(*it.current()); + loadAddressee( addressee, v ); + return true; + } + + return false; +} + +bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, TQFile *file ) +{ + kdDebug(5700) << "VCardFormat::loadAll()" << endl; + + TQByteArray fdata = file->readAll(); + TQCString data(fdata.data(), fdata.size()+1); + + VCardEntity e( data ); + + VCardListIterator it( e.cardList() ); + + for (; it.current(); ++it) { + VCARD::VCard v(*it.current()); + Addressee addressee; + loadAddressee( addressee, v ); + addressee.setResource( resource ); + addressBook->insertAddressee( addressee ); + } + + return true; +} + +void VCardFormatImpl::save( const Addressee &addressee, TQFile *file ) +{ + VCardEntity vcards; + VCardList vcardlist; + vcardlist.setAutoDelete( true ); + + VCARD::VCard *v = new VCARD::VCard; + + saveAddressee( addressee, v, false ); + + vcardlist.append( v ); + vcards.setCardList( vcardlist ); + + TQCString vcardData = vcards.asString(); + file->writeBlock( (const char*)vcardData, vcardData.length() ); +} + +void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, TQFile *file ) +{ + VCardEntity vcards; + VCardList vcardlist; + vcardlist.setAutoDelete( true ); + + AddressBook::Iterator it; + for ( it = ab->begin(); it != ab->end(); ++it ) { + if ( (*it).resource() == resource ) { + VCARD::VCard *v = new VCARD::VCard; + saveAddressee( (*it), v, false ); + (*it).setChanged( false ); + vcardlist.append( v ); + } + } + + vcards.setCardList( vcardlist ); + + TQCString vcardData = vcards.asString(); + file->writeBlock( (const char*)vcardData, vcardData.length() ); +} + +bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCARD::VCard &v ) +{ + TQPtrList<ContentLine> contentLines = v.contentLineList(); + ContentLine *cl; + + for( cl = contentLines.first(); cl; cl = contentLines.next() ) { + TQCString n = cl->name(); + if ( n.left( 2 ) == "X-" ) { + n = n.mid( 2 ); + int posDash = n.find( "-" ); + addressee.insertCustom( TQString::fromUtf8( n.left( posDash ) ), + TQString::fromUtf8( n.mid( posDash + 1 ) ), + TQString::fromUtf8( cl->value()->asString() ) ); + continue; + } + + EntityType type = cl->entityType(); + switch( type ) { + + case EntityUID: + addressee.setUid( readTextValue( cl ) ); + break; + + case EntityURI: + addressee.setUri( readTextValue( cl ) ); + break; + + case EntityEmail: + addressee.insertEmail( readTextValue( cl ) ); + break; + + case EntityName: + addressee.setName( readTextValue( cl ) ); + break; + + case EntityFullName: + addressee.setFormattedName( readTextValue( cl ) ); + break; + + case EntityURL: + addressee.setUrl( KURL( readTextValue( cl ) ) ); + break; + + case EntityNickname: + addressee.setNickName( readTextValue( cl ) ); + break; + + case EntityLabel: + // not yet supported by kabc + break; + + case EntityMailer: + addressee.setMailer( readTextValue( cl ) ); + break; + + case EntityTitle: + addressee.setTitle( readTextValue( cl ) ); + break; + + case EntityRole: + addressee.setRole( readTextValue( cl ) ); + break; + + case EntityOrganisation: + addressee.setOrganization( readTextValue( cl ) ); + break; + + case EntityNote: + addressee.setNote( readTextValue( cl ) ); + break; + + case EntityProductID: + addressee.setProductId( readTextValue( cl ) ); + break; + + case EntitySortString: + addressee.setSortString( readTextValue( cl ) ); + break; + + case EntityN: + readNValue( cl, addressee ); + break; + + case EntityAddress: + addressee.insertAddress( readAddressValue( cl ) ); + break; + + case EntityTelephone: + addressee.insertPhoneNumber( readTelephoneValue( cl ) ); + break; + + case EntityCategories: + addressee.setCategories( TQStringList::split( ",", readTextValue( cl ) ) ); + break; + + case EntityBirthday: + addressee.setBirthday( readDateValue( cl ) ); + break; + + case EntityRevision: + addressee.setRevision( readDateTimeValue( cl ) ); + break; + + case EntityGeo: + addressee.setGeo( readGeoValue( cl ) ); + break; + + case EntityTimeZone: + addressee.setTimeZone( readUTCValue( cl ) ); + break; + + case EntityVersion: + break; + + case EntityClass: + addressee.setSecrecy( readClassValue( cl ) ); + break; + + case EntityKey: + addressee.insertKey( readKeyValue( cl ) ); + break; + + case EntityPhoto: + addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); + break; + + case EntityLogo: + addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); + break; + + case EntityAgent: + addressee.setAgent( readAgentValue( cl ) ); + break; + + case EntitySound: + addressee.setSound( readSoundValue( cl, addressee ) ); + break; + + default: + kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " + << int( type ) << ": " << cl->asString() << endl; + break; + } + } + + for( cl = contentLines.first(); cl; cl = contentLines.next() ) { + EntityType type = cl->entityType(); + if ( type == EntityLabel ) { + int type = readAddressParam( cl ); + Address address = addressee.address( type ); + if ( address.isEmpty() ) + address.setType( type ); + + address.setLabel( TQString::fromUtf8( cl->value()->asString() ) ); + addressee.insertAddress( address ); + } + } + + return true; +} + +void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCARD::VCard *v, bool intern ) +{ + ContentLine cl; + TQString value; + + addTextValue( v, EntityName, addressee.name() ); + addTextValue( v, EntityUID, addressee.uid() ); + addTextValue( v, EntityURI, addressee.uri() ); + addTextValue( v, EntityFullName, addressee.formattedName() ); + + TQStringList emails = addressee.emails(); + TQStringList::ConstIterator it4; + for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { + addTextValue( v, EntityEmail, *it4 ); + } + + TQStringList customs = addressee.customs(); + TQStringList::ConstIterator it5; + for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { + addCustomValue( v, *it5 ); + } + + addTextValue( v, EntityURL, addressee.url().url() ); + + addNValue( v, addressee ); + + addTextValue( v, EntityNickname, addressee.nickName() ); + addTextValue( v, EntityMailer, addressee.mailer() ); + addTextValue( v, EntityTitle, addressee.title() ); + addTextValue( v, EntityRole, addressee.role() ); + addTextValue( v, EntityOrganisation, addressee.organization() ); + addTextValue( v, EntityNote, addressee.note() ); + addTextValue( v, EntityProductID, addressee.productId() ); + addTextValue( v, EntitySortString, addressee.sortString() ); + + Address::List addresses = addressee.addresses(); + Address::List::ConstIterator it3; + for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { + addAddressValue( v, *it3 ); + addLabelValue( v, *it3 ); + } + + PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); + PhoneNumber::List::ConstIterator it2; + for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { + addTelephoneValue( v, *it2 ); + } + + Key::List keys = addressee.keys(); + Key::List::ConstIterator it6; + for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { + addKeyValue( v, *it6 ); + } + + addTextValue( v, EntityCategories, addressee.categories().join(",") ); + + addDateValue( v, EntityBirthday, TQT_TQDATE_OBJECT(addressee.birthday().date()) ); + addDateTimeValue( v, EntityRevision, TQT_TQDATETIME_OBJECT(addressee.revision()) ); + addGeoValue( v, addressee.geo() ); + addUTCValue( v, addressee.timeZone() ); + + addClassValue( v, addressee.secrecy() ); + + addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); + addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); + + addAgentValue( v, addressee.agent() ); + + addSoundValue( v, addressee.sound(), addressee, intern ); +} + +void VCardFormatImpl::addCustomValue( VCARD::VCard *v, const TQString &txt ) +{ + if ( txt.isEmpty() ) return; + + ContentLine cl; + cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); + TQString value = txt.mid( txt.find( ":" ) + 1 ); + if ( value.isEmpty() ) + return; + cl.setValue( new TextValue( value.utf8() ) ); + v->add(cl); +} + +void VCardFormatImpl::addTextValue( VCARD::VCard *v, EntityType type, const TQString &txt ) +{ + if ( txt.isEmpty() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( type ) ); + cl.setValue( new TextValue( txt.utf8() ) ); + v->add(cl); +} + +void VCardFormatImpl::addDateValue( VCARD::VCard *vcard, EntityType type, + const TQDate &date ) +{ + if ( !date.isValid() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( type ) ); + + DateValue *v = new DateValue( date ); + cl.setValue( v ); + vcard->add(cl); +} + +void VCardFormatImpl::addDateTimeValue( VCARD::VCard *vcard, EntityType type, + const TQDateTime &dateTime ) +{ + if ( !dateTime.isValid() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( type ) ); + + DateValue *v = new DateValue( dateTime ); + cl.setValue( v ); + vcard->add(cl); +} + +void VCardFormatImpl::addAddressValue( VCARD::VCard *vcard, const Address &a ) +{ + if ( a.isEmpty() ) + return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityAddress ) ); + + AdrValue *v = new AdrValue; + v->setPOBox( a.postOfficeBox().utf8() ); + v->setExtAddress( a.extended().utf8() ); + v->setStreet( a.street().utf8() ); + v->setLocality( a.locality().utf8() ); + v->setRegion( a.region().utf8() ); + v->setPostCode( a.postalCode().utf8() ); + v->setCountryName( a.country().utf8() ); + cl.setValue( v ); + + addAddressParam( &cl, a.type() ); + + vcard->add( cl ); +} + +void VCardFormatImpl::addLabelValue( VCARD::VCard *vcard, const Address &a ) +{ + if ( a.label().isEmpty() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityLabel ) ); + cl.setValue( new TextValue( a.label().utf8() ) ); + + addAddressParam( &cl, a.type() ); + + vcard->add( cl ); +} + +void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) +{ + ParamList params; + if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); + if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); + if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); + if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); + if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); + if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); + if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); + cl->setParamList( params ); +} + +void VCardFormatImpl::addGeoValue( VCARD::VCard *vcard, const Geo &geo ) +{ + if ( !geo.isValid() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityGeo ) ); + + GeoValue *v = new GeoValue; + v->setLatitude( geo.latitude() ); + v->setLongitude( geo.longitude() ); + + cl.setValue( v ); + vcard->add(cl); +} + +void VCardFormatImpl::addUTCValue( VCARD::VCard *vcard, const TimeZone &tz ) +{ + if ( !tz.isValid() ) return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityTimeZone ) ); + + UTCValue *v = new UTCValue; + + v->setPositive( tz.offset() >= 0 ); + v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); + v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); + + cl.setValue( v ); + vcard->add(cl); +} + +void VCardFormatImpl::addClassValue( VCARD::VCard *vcard, const Secrecy &secrecy ) +{ + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityClass ) ); + + ClassValue *v = new ClassValue; + switch ( secrecy.type() ) { + case Secrecy::Public: + v->setType( (int)ClassValue::Public ); + break; + case Secrecy::Private: + v->setType( (int)ClassValue::Private ); + break; + case Secrecy::Confidential: + v->setType( (int)ClassValue::Confidential ); + break; + } + + cl.setValue( v ); + vcard->add(cl); +} + + +Address VCardFormatImpl::readAddressValue( ContentLine *cl ) +{ + Address a; + AdrValue *v = (AdrValue *)cl->value(); + a.setPostOfficeBox( TQString::fromUtf8( v->poBox() ) ); + a.setExtended( TQString::fromUtf8( v->extAddress() ) ); + a.setStreet( TQString::fromUtf8( v->street() ) ); + a.setLocality( TQString::fromUtf8( v->locality() ) ); + a.setRegion( TQString::fromUtf8( v->region() ) ); + a.setPostalCode( TQString::fromUtf8( v->postCode() ) ); + a.setCountry( TQString::fromUtf8( v->countryName() ) ); + + a.setType( readAddressParam( cl ) ); + + return a; +} + +int VCardFormatImpl::readAddressParam( ContentLine *cl ) +{ + int type = 0; + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "TYPE" ) { + if ( (*it)->value() == "dom" ) type |= Address::Dom; + else if ( (*it)->value() == "intl" ) type |= Address::Intl; + else if ( (*it)->value() == "parcel" ) type |= Address::Parcel; + else if ( (*it)->value() == "postal" ) type |= Address::Postal; + else if ( (*it)->value() == "work" ) type |= Address::Work; + else if ( (*it)->value() == "home" ) type |= Address::Home; + else if ( (*it)->value() == "pref" ) type |= Address::Pref; + } + } + return type; +} + +void VCardFormatImpl::addNValue( VCARD::VCard *vcard, const Addressee &a ) +{ + ContentLine cl; + cl.setName(EntityTypeToParamName( EntityN ) ); + NValue *v = new NValue; + v->setFamily( TQString(a.familyName()).utf8() ); + v->setGiven( TQString(a.givenName()).utf8() ); + v->setMiddle( TQString(a.additionalName()).utf8() ); + v->setPrefix( TQString(a.prefix()).utf8() ); + v->setSuffix( TQString(a.suffix()).utf8() ); + + cl.setValue( v ); + vcard->add(cl); +} + +void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) +{ + NValue *v = (NValue *)cl->value(); + a.setFamilyName( TQString::fromUtf8( v->family() ) ); + a.setGivenName( TQString::fromUtf8( v->given() ) ); + a.setAdditionalName( TQString::fromUtf8( v->middle() ) ); + a.setPrefix( TQString::fromUtf8( v->prefix() ) ); + a.setSuffix( TQString::fromUtf8( v->suffix() ) ); +} + +void VCardFormatImpl::addTelephoneValue( VCARD::VCard *v, const PhoneNumber &p ) +{ + if ( p.number().isEmpty() ) + return; + + ContentLine cl; + cl.setName(EntityTypeToParamName(EntityTelephone)); + cl.setValue(new TelValue( p.number().utf8() )); + + ParamList params; + if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); + if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); + if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); + if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); + if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); + if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); + if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); + if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); + if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); + if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); + if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); + if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); + if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); + if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); + cl.setParamList( params ); + + v->add(cl); +} + +PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) +{ + PhoneNumber p; + TelValue *value = (TelValue *)cl->value(); + p.setNumber( TQString::fromUtf8( value->asString() ) ); + + int type = 0; + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "TYPE" ) { + if ( (*it)->value() == "home" ) type |= PhoneNumber::Home; + else if ( (*it)->value() == "work" ) type |= PhoneNumber::Work; + else if ( (*it)->value() == "msg" ) type |= PhoneNumber::Msg; + else if ( (*it)->value() == "pref" ) type |= PhoneNumber::Pref; + else if ( (*it)->value() == "voice" ) type |= PhoneNumber::Voice; + else if ( (*it)->value() == "fax" ) type |= PhoneNumber::Fax; + else if ( (*it)->value() == "cell" ) type |= PhoneNumber::Cell; + else if ( (*it)->value() == "video" ) type |= PhoneNumber::Video; + else if ( (*it)->value() == "bbs" ) type |= PhoneNumber::Bbs; + else if ( (*it)->value() == "modem" ) type |= PhoneNumber::Modem; + else if ( (*it)->value() == "car" ) type |= PhoneNumber::Car; + else if ( (*it)->value() == "isdn" ) type |= PhoneNumber::Isdn; + else if ( (*it)->value() == "pcs" ) type |= PhoneNumber::Pcs; + else if ( (*it)->value() == "pager" ) type |= PhoneNumber::Pager; + } + } + p.setType( type ); + + return p; +} + +TQString VCardFormatImpl::readTextValue( ContentLine *cl ) +{ + VCARD::Value *value = cl->value(); + if ( value ) { + return TQString::fromUtf8( value->asString() ); + } else { + kdDebug(5700) << "No value: " << cl->asString() << endl; + return TQString::null; + } +} + +TQDate VCardFormatImpl::readDateValue( ContentLine *cl ) +{ + DateValue *dateValue = (DateValue *)cl->value(); + if ( dateValue ) + return dateValue->qdate(); + else + return TQDate(); +} + +TQDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) +{ + DateValue *dateValue = (DateValue *)cl->value(); + if ( dateValue ) + return dateValue->qdt(); + else + return TQDateTime(); +} + +Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) +{ + GeoValue *geoValue = (GeoValue *)cl->value(); + if ( geoValue ) { + Geo geo( geoValue->latitude(), geoValue->longitude() ); + return geo; + } else + return Geo(); +} + +TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) +{ + UTCValue *utcValue = (UTCValue *)cl->value(); + if ( utcValue ) { + TimeZone tz; + tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); + return tz; + } else + return TimeZone(); +} + +Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) +{ + ClassValue *classValue = (ClassValue *)cl->value(); + if ( classValue ) { + Secrecy secrecy; + switch ( classValue->type() ) { + case ClassValue::Public: + secrecy.setType( Secrecy::Public ); + break; + case ClassValue::Private: + secrecy.setType( Secrecy::Private ); + break; + case ClassValue::Confidential: + secrecy.setType( Secrecy::Confidential ); + break; + } + + return secrecy; + } else + return Secrecy(); +} + +void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) +{ + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityKey ) ); + + ParamList params; + if ( key.isBinary() ) { + cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); + params.append( new Param( "ENCODING", "b" ) ); + } else { + cl.setValue( new TextValue( key.textData().utf8() ) ); + } + + switch ( key.type() ) { + case Key::X509: + params.append( new Param( "TYPE", "X509" ) ); + break; + case Key::PGP: + params.append( new Param( "TYPE", "PGP" ) ); + break; + case Key::Custom: + params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); + break; + } + + cl.setParamList( params ); + vcard->add( cl ); +} + +Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) +{ + Key key; + bool isBinary = false; + TextValue *v = (TextValue *)cl->value(); + + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) + isBinary = true; + if ( (*it)->name() == "TYPE" ) { + if ( (*it)->value().isEmpty() ) + continue; + if ( (*it)->value() == "X509" ) + key.setType( Key::X509 ); + else if ( (*it)->value() == "PGP" ) + key.setType( Key::PGP ); + else { + key.setType( Key::Custom ); + key.setCustomTypeString( TQString::fromUtf8( (*it)->value() ) ); + } + } + } + + + if ( isBinary ) { + TQByteArray data; + KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); + key.setBinaryData( data ); + } else { + key.setTextData( TQString::fromUtf8( v->asString() ) ); + } + + return key; +} + + +void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) +{ + if ( agent.isIntern() && !agent.addressee() ) + return; + + if ( !agent.isIntern() && agent.url().isEmpty() ) + return; + + ContentLine cl; + cl.setName( EntityTypeToParamName( EntityAgent ) ); + + ParamList params; + if ( agent.isIntern() ) { + TQString vstr; + Addressee *addr = agent.addressee(); + if ( addr ) { + writeToString( (*addr), vstr ); + vstr.replace( ":", "\\:" ); + vstr.replace( ",", "\\," ); + vstr.replace( ";", "\\;" ); + vstr.replace( "\r\n", "\\n" ); + cl.setValue( new TextValue( vstr.utf8() ) ); + } else + return; + } else { + cl.setValue( new TextValue( agent.url().utf8() ) ); + params.append( new Param( "VALUE", "uri" ) ); + } + + cl.setParamList( params ); + vcard->add( cl ); +} + +Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) +{ + Agent agent; + bool isIntern = true; + TextValue *v = (TextValue *)cl->value(); + + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) + isIntern = false; + } + + if ( isIntern ) { + TQString vstr = TQString::fromUtf8( v->asString() ); + vstr.replace( "\\n", "\r\n" ); + vstr.replace( "\\:", ":" ); + vstr.replace( "\\,", "," ); + vstr.replace( "\\;", ";" ); + Addressee *addr = new Addressee; + readFromString( vstr, *addr ); + agent.setAddressee( addr ); + } else { + agent.setUrl( TQString::fromUtf8( v->asString() ) ); + } + + return agent; +} + +void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) +{ + ContentLine cl; + cl.setName( EntityTypeToParamName( type ) ); + + if ( pic.isIntern() && pic.data().isNull() ) + return; + + if ( !pic.isIntern() && pic.url().isEmpty() ) + return; + + ParamList params; + if ( pic.isIntern() ) { + TQImage img = pic.data(); + if ( intern ) { // only for vCard export we really write the data inline + TQByteArray data; + TQDataStream s( data, IO_WriteOnly ); + s.setVersion( 4 ); // to produce valid png files + s << img; + cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); + } else { // save picture in cache + TQString dir; + if ( type == EntityPhoto ) + dir = "photos"; + if ( type == EntityLogo ) + dir = "logos"; + + img.save( locateLocal( "data", "tdeabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); + cl.setValue( new TextValue( "<dummy>" ) ); + } + params.append( new Param( "ENCODING", "b" ) ); + if ( !pic.type().isEmpty() ) + params.append( new Param( "TYPE", pic.type().utf8() ) ); + } else { + cl.setValue( new TextValue( pic.url().utf8() ) ); + params.append( new Param( "VALUE", "uri" ) ); + } + + cl.setParamList( params ); + vcard->add( cl ); +} + +Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) +{ + Picture pic; + bool isInline = false; + TQString picType; + TextValue *v = (TextValue *)cl->value(); + + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) + isInline = true; + if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) + picType = TQString::fromUtf8( (*it)->value() ); + } + + if ( isInline ) { + TQImage img; + if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache + TQString dir; + if ( type == EntityPhoto ) + dir = "photos"; + if ( type == EntityLogo ) + dir = "logos"; + + img.load( locateLocal( "data", "tdeabc/" + dir + "/" + addr.uid() ) ); + } else { + TQByteArray data; + KCodecs::base64Decode( v->asString(), data ); + img.loadFromData( data ); + } + pic.setData( img ); + pic.setType( picType ); + } else { + pic.setUrl( TQString::fromUtf8( v->asString() ) ); + } + + return pic; +} + +void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) +{ + ContentLine cl; + cl.setName( EntityTypeToParamName( EntitySound ) ); + + if ( sound.isIntern() && sound.data().isNull() ) + return; + + if ( !sound.isIntern() && sound.url().isEmpty() ) + return; + + ParamList params; + if ( sound.isIntern() ) { + TQByteArray data = sound.data(); + if ( intern ) { // only for vCard export we really write the data inline + cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); + } else { // save sound in cache + TQFile file( locateLocal( "data", "tdeabc/sounds/" + addr.uid() ) ); + if ( file.open( IO_WriteOnly ) ) { + file.writeBlock( data ); + } + cl.setValue( new TextValue( "<dummy>" ) ); + } + params.append( new Param( "ENCODING", "b" ) ); + } else { + cl.setValue( new TextValue( sound.url().utf8() ) ); + params.append( new Param( "VALUE", "uri" ) ); + } + + cl.setParamList( params ); + vcard->add( cl ); +} + +Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) +{ + Sound sound; + bool isInline = false; + TextValue *v = (TextValue *)cl->value(); + + ParamList params = cl->paramList(); + ParamListIterator it( params ); + for( ; it.current(); ++it ) { + if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) + isInline = true; + } + + if ( isInline ) { + TQByteArray data; + if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache + TQFile file( locateLocal( "data", "tdeabc/sounds/" + addr.uid() ) ); + if ( file.open( IO_ReadOnly ) ) { + data = file.readAll(); + file.close(); + } + } else { + KCodecs::base64Decode( v->asString(), data ); + } + sound.setData( data ); + } else { + sound.setUrl( TQString::fromUtf8( v->asString() ) ); + } + + return sound; +} + +bool VCardFormatImpl::readFromString( const TQString &vcard, Addressee &addressee ) +{ + VCardEntity e( vcard.utf8() ); + VCardListIterator it( e.cardList() ); + + if ( it.current() ) { + VCARD::VCard v(*it.current()); + loadAddressee( addressee, v ); + return true; + } + + return false; +} + +bool VCardFormatImpl::writeToString( const Addressee &addressee, TQString &vcard ) +{ + VCardEntity vcards; + VCardList vcardlist; + vcardlist.setAutoDelete( true ); + + VCARD::VCard *v = new VCARD::VCard; + + saveAddressee( addressee, v, true ); + + vcardlist.append( v ); + vcards.setCardList( vcardlist ); + vcard = TQString::fromUtf8( vcards.asString() ); + + return true; +} diff --git a/tdeabc/vcardformatimpl.h b/tdeabc/vcardformatimpl.h new file mode 100644 index 000000000..ddcd6fc07 --- /dev/null +++ b/tdeabc/vcardformatimpl.h @@ -0,0 +1,106 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_VCARDFORMATIMPL_H +#define KABC_VCARDFORMATIMPL_H + +#include <tqstring.h> +#include <tqfile.h> + +#include "address.h" +#include "addressee.h" + +#ifdef __CYGWIN__ +#include <vcard/include/VCard.h> +#else +#include <VCard.h> +#endif + +namespace TDEABC { + +class AddressBook; + +/** + @deprecated use VCardFormatPlugin instead. + */ +class KABC_EXPORT_DEPRECATED VCardFormatImpl +{ + public: + bool load( Addressee &, TQFile *file ); + bool loadAll( AddressBook *, Resource *, TQFile *file ); + void save( const Addressee &, TQFile *file ); + void saveAll( AddressBook *, Resource *, TQFile *file ); + + bool readFromString( const TQString &vcard, Addressee &addr ); + bool writeToString( const Addressee &addressee, TQString &vcard ); + + protected: + bool loadAddressee( Addressee &, VCARD::VCard & ); + void saveAddressee( const Addressee &, VCARD::VCard *, bool intern ); + + void addTextValue (VCARD::VCard *, VCARD::EntityType, const TQString & ); + TQString readTextValue( VCARD::ContentLine * ); + + void addDateValue( VCARD::VCard *, VCARD::EntityType, const TQDate & ); + TQDate readDateValue( VCARD::ContentLine * ); + + void addDateTimeValue( VCARD::VCard *, VCARD::EntityType, const TQDateTime & ); + TQDateTime readDateTimeValue( VCARD::ContentLine * ); + + void addAddressValue( VCARD::VCard *, const Address & ); + Address readAddressValue( VCARD::ContentLine * ); + + void addLabelValue( VCARD::VCard *, const Address & ); + + void addTelephoneValue( VCARD::VCard *, const PhoneNumber & ); + PhoneNumber readTelephoneValue( VCARD::ContentLine * ); + + void addNValue( VCARD::VCard *, const Addressee & ); + void readNValue( VCARD::ContentLine *, Addressee & ); + + void addCustomValue( VCARD::VCard *, const TQString & ); + + void addAddressParam( VCARD::ContentLine *, int ); + int readAddressParam( VCARD::ContentLine * ); + + void addGeoValue( VCARD::VCard *, const Geo & ); + Geo readGeoValue( VCARD::ContentLine * ); + + void addUTCValue( VCARD::VCard *, const TimeZone & ); + TimeZone readUTCValue( VCARD::ContentLine * ); + + void addClassValue( VCARD::VCard *, const Secrecy & ); + Secrecy readClassValue( VCARD::ContentLine * ); + + void addKeyValue( VCARD::VCard *, const Key & ); + Key readKeyValue( VCARD::ContentLine * ); + + void addPictureValue( VCARD::VCard *, VCARD::EntityType, const Picture &, const Addressee &, bool ); + Picture readPictureValue( VCARD::ContentLine *, VCARD::EntityType, const Addressee &addr ); + + void addSoundValue( VCARD::VCard *, const Sound &, const Addressee &, bool ); + Sound readSoundValue( VCARD::ContentLine *, const Addressee &addr ); + + void addAgentValue( VCARD::VCard *, const Agent & ); + Agent readAgentValue( VCARD::ContentLine * ); +}; + +} +#endif diff --git a/tdeabc/vcardformatplugin.cpp b/tdeabc/vcardformatplugin.cpp new file mode 100644 index 000000000..83c4a8a7b --- /dev/null +++ b/tdeabc/vcardformatplugin.cpp @@ -0,0 +1,120 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqfile.h> + +#include "address.h" +#include "addressee.h" +#include "vcardconverter.h" + +#include "vcardformatplugin.h" + +using namespace TDEABC; + +VCardFormatPlugin::VCardFormatPlugin() +{ +} + +VCardFormatPlugin::~VCardFormatPlugin() +{ +} + +bool VCardFormatPlugin::load( Addressee &addressee, TQFile *file ) +{ + TQString data; + + TQTextStream t( file ); + t.setEncoding( TQTextStream::Latin1 ); + data = t.read(); + + VCardConverter converter; + Addressee::List l = converter.parseVCards( data ); + + if ( ! l.first().isEmpty() ) { + addressee = l.first(); + return true; + } + + return false; +} + +bool VCardFormatPlugin::loadAll( AddressBook*, Resource *resource, TQFile *file ) +{ + TQString data; + + TQTextStream t( file ); + t.setEncoding( TQTextStream::Latin1 ); + data = t.read(); + + VCardConverter converter; + + Addressee::List l = converter.parseVCards( data ); + + Addressee::List::iterator itr; + for ( itr = l.begin(); itr != l.end(); ++itr) { + Addressee addressee = *itr; + addressee.setResource( resource ); + addressee.setChanged( false ); + resource->insertAddressee( addressee ); + } + + return true; +} + +void VCardFormatPlugin::save( const Addressee &addressee, TQFile *file ) +{ + VCardConverter converter ; + Addressee::List vcardlist; + + + vcardlist.append( addressee ); + + TQTextStream t( file ); + t.setEncoding( TQTextStream::UnicodeUTF8 ); + t << converter.createVCards( vcardlist ); +} + +void VCardFormatPlugin::saveAll( AddressBook*, Resource *resource, TQFile *file ) +{ + VCardConverter converter; + Addressee::List vcardlist; + + Resource::Iterator it; + for ( it = resource->begin(); it != resource->end(); ++it ) { + (*it).setChanged( false ); + vcardlist.append( *it ); + } + + TQTextStream t( file ); + t.setEncoding( TQTextStream::UnicodeUTF8 ); + t << converter.createVCards( vcardlist ); +} + +bool VCardFormatPlugin::checkFormat( TQFile *file ) const +{ + TQString line; + + file->readLine( line, 1024 ); + line = line.stripWhiteSpace(); + if ( line == "BEGIN:VCARD" ) + return true; + else + return false; +} diff --git a/tdeabc/vcardformatplugin.h b/tdeabc/vcardformatplugin.h new file mode 100644 index 000000000..c9cc4f351 --- /dev/null +++ b/tdeabc/vcardformatplugin.h @@ -0,0 +1,56 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_VCARDFORMATPLUGIN_H +#define KABC_VCARDFORMATPLUGIN_H + +#include "formatplugin.h" + +namespace TDEABC { + +class AddressBook; +class Addressee; + +/** + @short Interface of vCard backend for address book. + + This class implements the file format interface of address book entries for + the vCard format. +*/ +class KABC_EXPORT VCardFormatPlugin : public FormatPlugin +{ + public: + VCardFormatPlugin(); + virtual ~VCardFormatPlugin(); + + bool load( Addressee &, TQFile *file ); + bool loadAll( AddressBook *, Resource *, TQFile *file ); + void save( const Addressee &, TQFile *file ); + void saveAll( AddressBook *, Resource *, TQFile *file ); + + bool checkFormat( TQFile *file ) const; + + private: + struct VCardFormatPrivate; + VCardFormatPrivate *d; +}; + +} +#endif diff --git a/tdeabc/vcardparser/CMakeLists.txt b/tdeabc/vcardparser/CMakeLists.txt new file mode 100644 index 000000000..15a2ce5c8 --- /dev/null +++ b/tdeabc/vcardparser/CMakeLists.txt @@ -0,0 +1,40 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdecore +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### headers ################################### + +install( FILES + vcard.h vcardline.h vcardparser.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeabc ) + + +##### vcards #################################### + +set( target vcards ) + +set( ${target}_SRCS + vcard.cpp vcardline.cpp vcardparser.cpp +) + +tde_add_library( ${target} STATIC_PIC + SOURCES ${${target}_SRCS} +) diff --git a/tdeabc/vcardparser/Makefile.am b/tdeabc/vcardparser/Makefile.am new file mode 100644 index 000000000..20c6ed45d --- /dev/null +++ b/tdeabc/vcardparser/Makefile.am @@ -0,0 +1,31 @@ +INCLUDES = -I$(top_builddir)/tdeabc -I$(top_srcdir)/tdeabc $(all_includes) + +noinst_LTLIBRARIES = libvcards.la +libvcards_la_SOURCES = vcard.cpp vcardline.cpp vcardparser.cpp + +vcardsincludedir = $(includedir)/tdeabc +vcardsinclude_HEADERS = vcard.h vcardline.h vcardparser.h + +check_PROGRAMS = testread testwrite testread2 + +testread_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testread_LDADD = libvcards.la $(top_builddir)/tdeabc/libkabc.la +testread_SOURCES = testread.cpp + +testread2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testread2_LDADD = libvcards.la $(top_builddir)/tdeabc/libkabc.la +testread2_SOURCES = testread2.cpp testutils.cpp + +testwrite_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +testwrite_LDADD = libvcards.la $(top_builddir)/tdeabc/libkabc.la +testwrite_SOURCES = testwrite.cpp + +TESTFILES = vcard1.vcf vcard2.vcf vcard3.vcf vcard4.vcf vcard6.vcf vcard7.vcf + +check-local: testread + rm -f FAILED; \ + for i in $(TESTFILES); \ + do perl $(top_srcdir)/tdeabc/vcardparser/checkvcard.pl \ + $(top_srcdir)/tdeabc/vcardparser/tests/$$i; \ + done; \ + [ ! -e FAILED ] diff --git a/tdeabc/vcardparser/README.testing b/tdeabc/vcardparser/README.testing new file mode 100644 index 000000000..a7794931d --- /dev/null +++ b/tdeabc/vcardparser/README.testing @@ -0,0 +1,15 @@ +For testing the vcardparser there are some test files and a small testsuite +automatically checking for regressions. The tests directory contains some vCard +files and correpsonding reference output files (with an additional ".ref" +suffix). For running the geression test do "make check". This will compile some +test programs, parse the test files, write them out as vCard again and compare +the output to the reference file. The check fails, if there are unexpected +differences and shows which lines differed. + +For creating a new test put a vCard file to be parsed into the tests directory. +Create a reference file by running "testread" on the test file. It will put out +the parsed data as vCard again on stdout. Carefully check the output, manually +correct any errors and save the result as reference file in the tests directory. +Now add the filename to the TESTFILES variable in Makefile.am and run "make +check". If the check fails adapt the reference file or fix the bugs in the +parser, whatever is appropriate. diff --git a/tdeabc/vcardparser/checkvcard.pl b/tdeabc/vcardparser/checkvcard.pl new file mode 100755 index 000000000..67160ea4a --- /dev/null +++ b/tdeabc/vcardparser/checkvcard.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +if ( @ARGV != 1 ) { + print STDERR "Missing arg: filename\n"; + exit 1; +} + +$file = $ARGV[0]; + +if ( !open( IN, "$file" ) ) { + print STDERR "Unable to open '$file'\n"; + exit 1; +} + +while( <IN> ) { + if (/^VERSION:(.*)$/ ) { + $version = $1; + if ( $version eq "2.1" ) { $options = "--vcard21"; } + } +} + +close IN; + +$ref = "$file.ref"; + +if ( !open( REF, "$ref" ) ) { + print STDERR "Unable to open $ref\n"; + exit 1; +} + +while( <REF> ) { + push @ref, $_; +} + +close REF; + +if ( !open( READ, "./testread $file $options 2> /dev/null |" ) ) { + print STDERR "Unable to open testread\n"; + exit 1; +} + +print "Checking '$file':\n"; + +$gotsomething = 0; +$error = 0; +$i = 0; +while( <READ> ) { + $gotsomething = 1; + $out = $_; + $ref = @ref[$i++]; + + if ( $out ne $ref ) { + if ( $ref =~ /^UID/ && $out =~ /^UID/ ) { next; } + $error++; + print " Expected : $ref"; + print " Parser output : $out"; + } +} + +close READ; + +if ( $gotsomething == 0 ) { + print "\n FAILED: testread didn't output anything\n"; + system "touch FAILED"; + exit 1; +} +if ( $error > 0 ) { + print "\n FAILED: $error errors found.\n"; + system "touch FAILED"; + exit 1; +} else { + print " OK\n"; +} + +exit 0; diff --git a/tdeabc/vcardparser/testread.cpp b/tdeabc/vcardparser/testread.cpp new file mode 100644 index 000000000..284526abd --- /dev/null +++ b/tdeabc/vcardparser/testread.cpp @@ -0,0 +1,89 @@ +/* + This file is part of libkabc. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <iostream> +#include <stdlib.h> + +#include <tqfile.h> +#include <tqtextstream.h> + +#include <kprocess.h> +#include <kdebug.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> + +#include "vcardconverter.h" +#include "vcard.h" + +static const TDECmdLineOptions options[] = +{ + {"vcard21", I18N_NOOP("vCard 2.1"), 0}, + {"+inputfile", I18N_NOOP("Input file"), 0}, + TDECmdLineLastOption +}; + +int main( int argc, char **argv ) +{ + TDEApplication::disableAutoDcopRegistration(); + + TDEAboutData aboutData( "testread", "vCard test reader", "0.1" ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app( false, false ); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + if ( args->count() != 1 ) { + std::cerr << "Missing argument" << std::endl; + return 1; + } + + TQString inputFile( args->arg( 0 ) ); + + TQFile file( inputFile ); + if ( !file.open( IO_ReadOnly ) ) { + tqDebug( "Unable to open file '%s' for reading!", file.name().latin1() ); + return 1; + } + + TQString text; + + TQTextStream s( &file ); + s.setEncoding( TQTextStream::Latin1 ); + text = s.read(); + file.close(); + + TDEABC::VCardConverter converter; + TDEABC::Addressee::List list = converter.parseVCards( text ); + + if ( args->isSet( "vcard21" ) ) { + text = converter.createVCards( list, TDEABC::VCardConverter::v2_1 ); // uses version 2.1 + } else { + text = converter.createVCards( list ); // uses version 3.0 + } + + std::cout << text.utf8(); + + return 0; +} diff --git a/tdeabc/vcardparser/testread2.cpp b/tdeabc/vcardparser/testread2.cpp new file mode 100644 index 000000000..bd0922670 --- /dev/null +++ b/tdeabc/vcardparser/testread2.cpp @@ -0,0 +1,42 @@ +#include "testutils.h" +#include <tdeabc/addressee.h> +#include <vcardconverter.h> +#include <kdebug.h> + +using namespace TDEABC; + +int +main() +{ + Addressee::List l = vCardsAsAddresseeList(); + TQString vcards = vCardsAsText(); + + VCardConverter vct; + + Addressee::List parsed = vct.parseVCards( vcards ); + + if ( l.size() != parsed.size() ) { + kdDebug()<<"\tSize - FAILED : "<<l.size()<<" vs. parsed "<<parsed.size()<<endl; + } else { + kdDebug()<<"\tSize - PASSED"<<endl; + } + + Addressee::List::iterator itr1; + Addressee::List::iterator itr2; + for ( itr1 = l.begin(), itr2 = parsed.begin(); + itr1 != l.end(); ++itr1, ++itr2 ) { + if ( (*itr1).fullEmail() == (*itr2).fullEmail() && + (*itr1).organization() == (*itr2).organization() && + (*itr1).phoneNumbers() == (*itr2).phoneNumbers() && + (*itr1).emails() == (*itr2).emails() && + (*itr1).role() == (*itr2).role() ) { + kdDebug()<<"\tAddressee - PASSED"<<endl; + kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl; + } else { + kdDebug()<<"\tAddressee - FAILED"<<endl; + (*itr1).dump(); + (*itr2).dump(); + //kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl; + } + } +} diff --git a/tdeabc/vcardparser/tests/vcard1.vcf b/tdeabc/vcardparser/tests/vcard1.vcf new file mode 100644 index 000000000..2c77b094c --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard1.vcf @@ -0,0 +1,13 @@ +BEGIN:vCard +VERSION:3.0 +FN:Frank Dawson +ORG:Lotus Development Corporation +ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive + ;Raleigh;NC;27613-3502;U.S.A. +TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 +TEL;TYPE=FAX,WORK:+1-919-676-9564 +EMAIL;TYPE=INTERNET,PREF:[email protected] +EMAIL;TYPE=INTERNET:[email protected] +URL:http://home.earthlink.net/~fdawson +END:vCard + diff --git a/tdeabc/vcardparser/tests/vcard1.vcf.ref b/tdeabc/vcardparser/tests/vcard1.vcf.ref new file mode 100644 index 000000000..073a7f31d --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard1.vcf.ref @@ -0,0 +1,15 @@ +BEGIN:VCARD
+ADR;TYPE=parcel;TYPE=postal;TYPE=work:;;6544 Battleford Drive;Raleigh;NC;27
+ 613-3502;U.S.A.
+EMAIL;TYPE=PREF:[email protected]
+EMAIL:[email protected]
+FN:Frank Dawson
+N:;;;;
+ORG:Lotus Development Corporation
+TEL;TYPE=MSG;TYPE=VOICE;TYPE=WORK:+1-919-676-9515
+TEL;TYPE=FAX;TYPE=WORK:+1-919-676-9564
+UID:gDVbA6LY3t
+URL:http://home.earthlink.net/~fdawson
+VERSION:3.0
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard2.vcf b/tdeabc/vcardparser/tests/vcard2.vcf new file mode 100644 index 000000000..a4136b1b8 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard2.vcf @@ -0,0 +1,11 @@ +BEGIN:vCard +VERSION:3.0 +FN:Tim Howes +ORG:Netscape Communications Corp. +ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View; + CA; 94043;U.S.A. +TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419 +TEL;TYPE=FAX,WORK:+1-415-528-4164 +EMAIL;TYPE=INTERNET:[email protected] +END:vCard + diff --git a/tdeabc/vcardparser/tests/vcard2.vcf.ref b/tdeabc/vcardparser/tests/vcard2.vcf.ref new file mode 100644 index 000000000..55151c797 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard2.vcf.ref @@ -0,0 +1,12 @@ +BEGIN:VCARD
+ADR;TYPE=work:;;501 E. Middlefield Rd.;Mountain View;CA; 94043;U.S.A.
+EMAIL:[email protected]
+FN:Tim Howes
+N:;;;;
+ORG:Netscape Communications Corp.
+TEL;TYPE=MSG;TYPE=VOICE;TYPE=WORK:+1-415-937-3419
+TEL;TYPE=FAX;TYPE=WORK:+1-415-528-4164
+UID:1UgvYejJMs
+VERSION:3.0
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard3.vcf b/tdeabc/vcardparser/tests/vcard3.vcf new file mode 100644 index 000000000..f3f649784 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard3.vcf @@ -0,0 +1,11 @@ +begin:vcard +n:geiser;ian +x-mozilla-html:FALSE +org:Source eXtreme +version:2.1 +email;internet:[email protected] +title:VP of Engineering +x-mozilla-cpt:;0 +fn:ian geiser +end:vcard + diff --git a/tdeabc/vcardparser/tests/vcard3.vcf.ref b/tdeabc/vcardparser/tests/vcard3.vcf.ref new file mode 100644 index 000000000..c91351769 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard3.vcf.ref @@ -0,0 +1,12 @@ +BEGIN:VCARD
+EMAIL:[email protected]
+FN:ian geiser
+N:geiser;ian;;;
+ORG:Source eXtreme
+TITLE:VP of Engineering
+UID:ebvq9Wo9rO
+VERSION:3.0
+X-mozilla-cpt:;0
+X-mozilla-html:FALSE
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard4.vcf b/tdeabc/vcardparser/tests/vcard4.vcf new file mode 100644 index 000000000..7152ceb05 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard4.vcf @@ -0,0 +1,14 @@ +BEGIN:VCARD +X-EVOLUTION-FILE-AS:Ximian, Inc. +FN +N: +LABEL;QUOTED-PRINTABLE;WORK:401 Park Drive 3 West=0ABoston, MA 02215=0AUSA +TEL;WORK;VOICE:(617) 236-0442 +TEL;WORK;FAX:(617) 236-8630 +EMAIL;INTERNET:[email protected] +URL:www.ximian.com/ +ORG:Ximian, Inc. +NOTE:Welcome to the Ximian Addressbook. +UID:pas-id-3E136F9B00000000 +END:VCARD + diff --git a/tdeabc/vcardparser/tests/vcard4.vcf.ref b/tdeabc/vcardparser/tests/vcard4.vcf.ref new file mode 100644 index 000000000..fc3b7a500 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard4.vcf.ref @@ -0,0 +1,14 @@ +BEGIN:VCARD
+EMAIL:[email protected]
+LABEL;TYPE=work:401 Park Drive 3 West\nBoston\, MA 02215\nUSA
+N:;;;;
+NOTE:Welcome to the Ximian Addressbook.
+ORG:Ximian\, Inc.
+TEL;TYPE=VOICE;TYPE=WORK:(617) 236-0442
+TEL;TYPE=FAX;TYPE=WORK:(617) 236-8630
+UID:pas-id-3E136F9B00000000
+URL:www.ximian.com/
+VERSION:3.0
+X-EVOLUTION-FILE-AS:Ximian\, Inc.
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard5.vcf b/tdeabc/vcardparser/tests/vcard5.vcf new file mode 100644 index 000000000..957a1e552 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard5.vcf @@ -0,0 +1,313 @@ +BEGIN:VCARD +ADR;TYPE=home;TYPE=pref:;;Buehlauer Strasse 45;Dresden;Sachsen;01327;German + y +ADR;TYPE=work:;;Prager Strasse 55;Dresden;Sachsen;01066;Germany +BDAY:1955-07-19T00:00:00Z +CATEGORIES:Friend +CLASS:CONFIDENTIAL +EMAIL;TYPE=PREF:[email protected] +EMAIL:[email protected] +FN:Mustermann, Heiko +GEO:19.283333;166.616669 +LOGO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVU + AAAOW0lEQVR4nO1df2hb1xX+OlyQwQEJXJAgBQlaiEwDsdqO2l1H47RjMe2gbjOoszG2dozG7aC + YMIqTjS7NYKSmbE1StsQpWxMXmsSF1WhlTeSwJlZY06gsSVXWUAkakKAGPajBDxrQ/jjnez8k27 + EjJdyU+/0jPz29X9L57jnnO+deAxYWFhYWFhYWFu3Hbe082XT2ZF3+WgAAdHZ0AgBqTg0A4H7DT + 7oAgNSdKQDAg99/sK33caPB53RqFQBA5PYIAMBdkOf6yc9+ct3P852W786irWjJMs/8+0wdACpV + sZTS50V5vSLb1UoVQMCCvnFDx0c65f3BHw4CABJ3RL19mwYfM4Y1e/+0V5h/VbbPXzwPACiVSgA + A15XnikVjAIB44Dli3TIKjL+2e0XPYxliGFZshSdzZ+r8OyKGjdl8AQCQfe84AKBaFUaUrojlRL + vEUpx5h0eGjo9EZH+kQ7Yz9/d71+vdkAYApO+W16d+/NQNZ8ye8T11ACiV5TkcR5jufCX3XyrLc + 9XmxUe6bvi5XH3OaNRnSKRL9vWsywAAstNTyz6HZYhhsD+IYbjmMPDxfz6uA0BMqQcAR96eAgBM + vSevtTkJa6tzQnVSNn2XOLSZ03ljHHQ7MLxlSIa2kg5pOrTVHHHu/hANRDrke4t2y3cy+KgEMPs + P7F/0O7EMMQzXtNxLn16qA8DUu1nvvcm3DgEAFlxxbo4jFpFYK4woXix8qxhxLYxuH6sDQG5Gvq + NSueLtcxwdNTTASemoUTi3+HdkGWIYlrTkj2clzC1ckGRv3xv7vH2VK7QAlUDuktA0f/bG+YpL5 + 4WpDDXv7TdPbjm472AdACbe9L+r4mdMHuW+42uTAIByuWwZciugY6kdER3zzn8iMkFt3pc93Kvy + d0QzvHYxI5h8Qq/BiK1YLur78nJw4mBIznj2V88ueg+HjxyrA0BEdE7EumLePp773u/e25b7jyb + kfAObh7z3SleELS40SVZ/u+2F0ToA7H99PHRtyxDD0GQZZ9RKKxUZ+/YdmAAAFD4peJ9hbF2dq7 + aHGSpn12p+dJI7PQsAcDS3YcxfmZPXnrt65F40P+pd3wsgwF69x/xHedlWNkfX+PlUep0ck0omA + ACxO+R10w82tfRch8leAJOas82ek+cho/sfkGtnT8xYhpiMJh9CiytVZayjYIgO37KCmWgrOPy3 + w3UAKKpsf/zd496+wkVhpOu5Lje0XS6X9X5lbJ49KxZIJqSSEu+Xrsj9V1Xw5OcBIPJBDoCfPw0 + 9IVn0sanpOgA8NXR9JYBILO7/rd8n/RV9SM1tPg6wDDEOTQxhFEKLYjbuBljBX9tjzyox/Q+xQO + crOf7I20cAAIVz+cCnVNJu8Alo3Nb43nEjoSfa8dIOAMDs6Zy+3wcAyM3kvCtUyZ6qXLd0WZj6z + E+fAeAX4FZbYo5Fmt9zXfeanwEsQ4xDE0Nqbi203ZhztANVZUb2PdF+imqZLgLX0OvSd7lLbPO+ + OFan1B8wGotEE3pCYfpWtX4A2L1rZ+gcHN+Pa8EtEpX3mR9tGlieKSf/dVJ9Ysl7j/fhMYTfuDa + ANMIyxDA0Z+r6Qy7MC1Mi3lge1PijTYetBNNTkjUfOjQJAMi+LzE6S7nJtX50krknE74hZQZbij + o19U7eKcfQAKuaP7lam+hRdZXl19kZX7Xe+PBG2acM7YzE9Bpi1UfeFN9G7Y6+77EfLR59UdGtV + X2G8D7IEPrf7PtZq2XdCmhiCBsUYnGxLJfxP5rzkI0Pb6wDwMypmWXHVupOk0eFEfQZIy+MAQB6 + 79OGhnSvd0yk4c5o4c7Xamlrwj7Nqck9uVf5eblGVnONqIY1W38+4h3DyJH1i6j6jFi3+B1GaPm + 8RGFsa9qrqu7zI6KfHXtHmM8KKq8ZfNZg/rMcLEMMQ5NlH/zLwVDz28SbomVRUxI0RDZJZrqici + biYmHFz8Q6cmox6bR8bsfOVwD44ylzH47dgK9lTf5dqpOzZ0V1Hnh0AIDfXMdmO7Zx0h8MaO2aT + JtQf7D16Se9a9CS0+uEofQVmV7ZjqhPmXhrIvQcnV2doeemv6UfIysAeNoVg9TMfdLqZH3ILYIl + x36Oi/v+Knp+/mwhsFfHcR0X2W3Su0Gy4ZrG3tU5GaOHtwhzXv3jqwB8ZgFiaezamFVWAMDO30u + OQAsjfvFL8QHpdFLOoPE8FQXG99UvxecMbhameOrCnB8tbh0WtjA3IZuYl6TXC1PoY/b9eRwAUL + hYDH3emXdD20EwX4p3SzS4VKWQsAwxDPYHMQxLlnDpJNlbSyEO8BvjvDKrJnZFlcxJ+biGkRT6Y + nf45VMAqHypXfMa0uY+8JM2Fpycr+QzfQ+JM0+nhPoMBHit3FFxuHT6FB8rGsYnusWZVsoBAVOH + QzrlkoqlcW1qSyQkOMmsE+c9sk2Gy+d//Xzo+Ago40RD3wsARKMrG6oIyxDDsCRDOAtodLsU44M + d3QtXKcnzLGELoXN7cos4y3jcl0QAYOFrOZ4ySLGooWqgOYBs4XVp+Qw9i2XZX1GyZtIJvQdhRi + Il23S4ntgYSNB67xcWTs2ouDmn97FRrlX6MlzUSt8jo8XQlq0AgMm3J8Ln1OfmnBBg9U2DliGGY + UmGEON7pE1lVNtWAGD2IwlPK1fF6jhziGMxE8eR54QhnWtUatY5hpS5ixfCPmexsDHRLedOeDK6 + YOARsdLxabHqVJIiozbvqQzvsZnvJ33r7dkgfuXQBWHC6NMSIrvqZ+grOTOsX+evPLlZRMlCXsv + GGsZn1osgOt7Q2rMaWIYYhmsyhAj+6tue2ybNZ59ruVfl5k614igL+90NvoNz9LT5jkJgKiVWS5 + 8CAOVSGYAv9FU0eezXaItsHHkkCQBI360RnDKBzODx7iKNGcPa1FCZk3JArZzT53FC5yB4DxGN8 + IY04d3+m+23AcDMqZmma6wWliGGYcUMCWL/G+HJJsNbhkPtPBxrGwv5pcufAgDcrzlPXayX430w + D2GMTx/CQlkqqUzokGO8MpZGUwtagqbASTAScuZ8ATOVlGa7wT6Jnnb/QacTaO4CFR0JFsXiiXj + oGrte3lUHgJ2/29ly46BliGG4LoY0YvLoZMgyjr9zXCKyTrEozuemsEfRjtEZfUq+4MvWjFxojd + ympTNqamq+iKjP8LJlln6VGQGxkj4hpS2lbJYeXC++xZuQpOxjO2hCi3f0lSxVtAOWIYahLQxpB + KXmijJjQed1R9nbptbNAhbbgRBoQYomxAobW0M5jvuWrpGQRj7MyFlsYg6RSDCS863ZnZf3EmuF + VcNPDMv9/FNKsfsPHAoxf/RFmbpWLLBtVa5JNvY90FcHWpueYRliGNrKkC/+90Ud8EucLjR7dtQ + 3qALLaCz7vsT9nO6V7vVXcqBi6jYUqHB7wyvCDWccz6kGpFU1ZqNCENWaKAWOMjZzn8RsbOTDgU + Ohz690vZJWYBliGNr6i1/6r0zM9LQqVXGZI3yqeQjfZ4ae2SCWyaY3QbhldOB7kqHHEuGaSiNe+ + a3UXlh2zeiaKYOPS7nW19uA8dekPB3TXGf0xVEAgXKv1oCok+VOCcs2DbY2oWc5WIYYhrb4kOms + tFgWL0tUlf9QNB0ygcwoXw5XzQY3D9YBIK7M4MQZwM87HM1dSmzP1KgrFgv7joUFNjlwqSF5efV + 1YUHurFj32PYx75gdL+uUhbyuf6UZeq9WFznJv6KqL33fjYRliGFoiSGc0FLUxQW8VsolmsAa4U + VCSRnng1PlqBPFNO/gKnVs76RP6WRuo35q6HHJsqkKsPZOto7v2e1dY+QF8RkDfaqIdZCVmsOo+ + swIjbX/GwnLEMPQEkPatZoomdE47QsAoHX6aDRcm+B4X/K6YbT+oYxg/ZttopzKxsmhgF8zrzR0 + 0bDjhp/l8iL508s3lbcDliGGwf4ghsGIFXWONaxHAvgrDMVUhmGLEfuA4xoiT70rgQQdrteBr6X + bktcoF94G/GY6hrO5U9pipAEAz1mttmfFipXAMsQw3BD5fbVwuJbUGl868UJMXdNEa0eIdocLUJ + wH8souSfI8eV7DYcr2lPqDgUNlPtzKSqawIMXQ+3rn418PLEMMgxE+hNirCxkDQK82SrgqBqY5K + 1eZUanK+94ahrpaUfGCyCCDm0VMpDBImb4SaHKgD/FWFVVmMGFl6Tl3Qgpok0eXXwS5HbAMMQxG + MSSIsZekXNp7v8zKymzo0T26WpHO42MjNxsmGHWx6a6/rz/0uWDBi+coFJRdnDHLiI4rTqxQCmo + HLEMMgxFR1mJgMOQ1YHO7S14b1zQhQ5iHsLXoiM6g9SbTICDPdIRbiLw5kyqpNK72djNgGWIYjG + VIPB5e+cBrauvSdh5tGWKbEHMJFrn6HxDf0bNOfE+Na7cEWaFPT+m+oNMjip9J/pE90Xrz9GphG + WIYjGUIW/zZyMysOcrGuTjXVAwXjbgST0WjKbZ70nXkC77VFy9r/jEXZteC077W0NXCMsQwGJuH + NGJsp+QlfZqXsHWHKi4n1xS0YZvToWc+lPLr+U+k2BSqgV31MnNjvgfLEMNgjGWsFFytiM3WcZW + BOUWgoj6kqv/Ii00RXBm7GljViBFXwaD/d2IZYhiMjbKWgreUhlb3OAFz4CHZz6aGWHd4hTnHFc + WWjeBAeJKpKbAMMQy3HEO45Mfecfl3qNSyuB5iRtt/XP43hK5w3nK+4rcBNa7FZQIsQwyDMdFFq + xh9UZb+6HtIlr1wF8SHFM6JPsVGueDiMzej8W21sAwxDPYHMQy3nFNfCmltrKuWRDrhv0HlUMWV + 8Rrn1JsGyxDDYLS1XA927ZZWooL+MzC29sycuHmNCq3AMsQwfGt8CFHISwEqskbDWwPlkeVgGWJ + xczH20lidTXe3AixDLCwsLCwsviX4P68/8cprSSqmAAAAAElFTkSuQmCC +N:Mustermann;Heiko;;; +NICKNAME:clown +NOTE:I'm a friendly note text,\nplease copy me to your address book... +ORG:KDE +PHOTO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pV + UAAAOW0lEQVR4nO1df2hb1xX+OlyQwQEJXJAgBQlaiEwDsdqO2l1H47RjMe2gbjOoszG2dozG7a + CYMIqTjS7NYKSmbE1StsQpWxMXmsSF1WhlTeSwJlZY06gsSVXWUAkakKAGPajBDxrQ/jjnez8k2 + 7EjJdyU+/0jPz29X9L57jnnO+deAxYWFhYWFhYWFu3Hbe082XT2ZF3+WgAAdHZ0AgBqTg0A4H7D + T7oAgNSdKQDAg99/sK33caPB53RqFQBA5PYIAMBdkOf6yc9+ct3P852W786irWjJMs/8+0wdACp + VsZTS50V5vSLb1UoVQMCCvnFDx0c65f3BHw4CABJ3RL19mwYfM4Y1e/+0V5h/VbbPXzwPACiVSg + AA15XnikVjAIB44Dli3TIKjL+2e0XPYxliGFZshSdzZ+r8OyKGjdl8AQCQfe84AKBaFUaUrojlR + LvEUpx5h0eGjo9EZH+kQ7Yz9/d71+vdkAYApO+W16d+/NQNZ8ye8T11ACiV5TkcR5jufCX3XyrL + c9XmxUe6bvi5XH3OaNRnSKRL9vWsywAAstNTyz6HZYhhsD+IYbjmMPDxfz6uA0BMqQcAR96eAgB + MvSevtTkJa6tzQnVSNn2XOLSZ03ljHHQ7MLxlSIa2kg5pOrTVHHHu/hANRDrke4t2y3cy+KgEMP + sP7F/0O7EMMQzXtNxLn16qA8DUu1nvvcm3DgEAFlxxbo4jFpFYK4woXix8qxhxLYxuH6sDQG5Gv + qNSueLtcxwdNTTASemoUTi3+HdkGWIYlrTkj2clzC1ckGRv3xv7vH2VK7QAlUDuktA0f/bG+YpL + 54WpDDXv7TdPbjm472AdACbe9L+r4mdMHuW+42uTAIByuWwZciugY6kdER3zzn8iMkFt3pc93Kv + yd0QzvHYxI5h8Qq/BiK1YLur78nJw4mBIznj2V88ueg+HjxyrA0BEdE7EumLePp773u/e25b7jy + bkfAObh7z3SleELS40SVZ/u+2F0ToA7H99PHRtyxDD0GQZZ9RKKxUZ+/YdmAAAFD4peJ9hbF2dq + 7aHGSpn12p+dJI7PQsAcDS3YcxfmZPXnrt65F40P+pd3wsgwF69x/xHedlWNkfX+PlUep0ck0om + AACxO+R10w82tfRch8leAJOas82ek+cho/sfkGtnT8xYhpiMJh9CiytVZayjYIgO37KCmWgrOPy + 3w3UAKKpsf/zd496+wkVhpOu5Lje0XS6X9X5lbJ49KxZIJqSSEu+Xrsj9V1Xw5OcBIPJBDoCfPw + 09IVn0sanpOgA8NXR9JYBILO7/rd8n/RV9SM1tPg6wDDEOTQxhFEKLYjbuBljBX9tjzyox/Q+xQ + OcrOf7I20cAAIVz+cCnVNJu8Alo3Nb43nEjoSfa8dIOAMDs6Zy+3wcAyM3kvCtUyZ6qXLd0WZj6 + zE+fAeAX4FZbYo5Fmt9zXfeanwEsQ4xDE0Nqbi203ZhztANVZUb2PdF+imqZLgLX0OvSd7lLbPO + +OFan1B8wGotEE3pCYfpWtX4A2L1rZ+gcHN+Pa8EtEpX3mR9tGlieKSf/dVJ9Ysl7j/fhMYTfuD + aANMIyxDA0Z+r6Qy7MC1Mi3lge1PijTYetBNNTkjUfOjQJAMi+LzE6S7nJtX50krknE74hZQZbi + jo19U7eKcfQAKuaP7lam+hRdZXl19kZX7Xe+PBG2acM7YzE9Bpi1UfeFN9G7Y6+77EfLR59UdGt + VX2G8D7IEPrf7PtZq2XdCmhiCBsUYnGxLJfxP5rzkI0Pb6wDwMypmWXHVupOk0eFEfQZIy+MAQB + 679OGhnSvd0yk4c5o4c7Xamlrwj7Nqck9uVf5eblGVnONqIY1W38+4h3DyJH1i6j6jFi3+B1GaP + m8RGFsa9qrqu7zI6KfHXtHmM8KKq8ZfNZg/rMcLEMMQ5NlH/zLwVDz28SbomVRUxI0RDZJZrqic + ibiYmHFz8Q6cmox6bR8bsfOVwD44ylzH47dgK9lTf5dqpOzZ0V1Hnh0AIDfXMdmO7Zx0h8MaO2a + TJtQf7D16Se9a9CS0+uEofQVmV7ZjqhPmXhrIvQcnV2doeemv6UfIysAeNoVg9TMfdLqZH3ILYI + lx36Oi/v+Knp+/mwhsFfHcR0X2W3Su0Gy4ZrG3tU5GaOHtwhzXv3jqwB8ZgFiaezamFVWAMDO30 + uOQAsjfvFL8QHpdFLOoPE8FQXG99UvxecMbhameOrCnB8tbh0WtjA3IZuYl6TXC1PoY/b9eRwAU + LhYDH3emXdD20EwX4p3SzS4VKWQsAwxDPYHMQxLlnDpJNlbSyEO8BvjvDKrJnZFlcxJ+biGkRT6 + Ynf45VMAqHypXfMa0uY+8JM2Fpycr+QzfQ+JM0+nhPoMBHit3FFxuHT6FB8rGsYnusWZVsoBAVO + HQzrlkoqlcW1qSyQkOMmsE+c9sk2Gy+d//Xzo+Ago40RD3wsARKMrG6oIyxDDsCRDOAtodLsU44 + Md3QtXKcnzLGELoXN7cos4y3jcl0QAYOFrOZ4ySLGooWqgOYBs4XVp+Qw9i2XZX1GyZtIJvQdhR + iIl23S4ntgYSNB67xcWTs2ouDmn97FRrlX6MlzUSt8jo8XQlq0AgMm3J8Ln1OfmnBBg9U2DliGG + YUmGEON7pE1lVNtWAGD2IwlPK1fF6jhziGMxE8eR54QhnWtUatY5hpS5ixfCPmexsDHRLedOeDK + 6YOARsdLxabHqVJIiozbvqQzvsZnvJ33r7dkgfuXQBWHC6NMSIrvqZ+grOTOsX+evPLlZRMlCXs + vGGsZn1osgOt7Q2rMaWIYYhmsyhAj+6tue2ybNZ59ruVfl5k614igL+90NvoNz9LT5jkJgKiVWS + 58CAOVSGYAv9FU0eezXaItsHHkkCQBI360RnDKBzODx7iKNGcPa1FCZk3JArZzT53FC5yB4DxGN + 8IY04d3+m+23AcDMqZmma6wWliGGYcUMCWL/G+HJJsNbhkPtPBxrGwv5pcufAgDcrzlPXayX430 + wD2GMTx/CQlkqqUzokGO8MpZGUwtagqbASTAScuZ8ATOVlGa7wT6Jnnb/QacTaO4CFR0JFsXiiX + joGrte3lUHgJ2/29ly46BliGG4LoY0YvLoZMgyjr9zXCKyTrEozuemsEfRjtEZfUq+4MvWjFxoj + dympTNqamq+iKjP8LJlln6VGQGxkj4hpS2lbJYeXC++xZuQpOxjO2hCi3f0lSxVtAOWIYahLQxp + BKXmijJjQed1R9nbptbNAhbbgRBoQYomxAobW0M5jvuWrpGQRj7MyFlsYg6RSDCS863ZnZf3Emu + FVcNPDMv9/FNKsfsPHAoxf/RFmbpWLLBtVa5JNvY90FcHWpueYRliGNrKkC/+90Ud8EucLjR7dt + Q3qALLaCz7vsT9nO6V7vVXcqBi6jYUqHB7wyvCDWccz6kGpFU1ZqNCENWaKAWOMjZzn8RsbOTDg + UOhz690vZJWYBliGNr6i1/6r0zM9LQqVXGZI3yqeQjfZ4ae2SCWyaY3QbhldOB7kqHHEuGaSiNe + +a3UXlh2zeiaKYOPS7nW19uA8dekPB3TXGf0xVEAgXKv1oCok+VOCcs2DbY2oWc5WIYYhrb4kOm + stFgWL0tUlf9QNB0ygcwoXw5XzQY3D9YBIK7M4MQZwM87HM1dSmzP1KgrFgv7joUFNjlwqSF5ef + V1YUHurFj32PYx75gdL+uUhbyuf6UZeq9WFznJv6KqL33fjYRliGFoiSGc0FLUxQW8VsolmsAa4 + UVCSRnng1PlqBPFNO/gKnVs76RP6WRuo35q6HHJsqkKsPZOto7v2e1dY+QF8RkDfaqIdZCVmsOo + +swIjbX/GwnLEMPQEkPatZoomdE47QsAoHX6aDRcm+B4X/K6YbT+oYxg/ZttopzKxsmhgF8zrzR + 00bDjhp/l8iL508s3lbcDliGGwf4ghsGIFXWONaxHAvgrDMVUhmGLEfuA4xoiT70rgQQdrteBr6 + XbktcoF94G/GY6hrO5U9pipAEAz1mttmfFipXAMsQw3BD5fbVwuJbUGl868UJMXdNEa0eIdocLU + JwH8souSfI8eV7DYcr2lPqDgUNlPtzKSqawIMXQ+3rn418PLEMMgxE+hNirCxkDQK82SrgqBqY5 + K1eZUanK+94ahrpaUfGCyCCDm0VMpDBImb4SaHKgD/FWFVVmMGFl6Tl3Qgpok0eXXwS5HbAMMQx + GMSSIsZekXNp7v8zKymzo0T26WpHO42MjNxsmGHWx6a6/rz/0uWDBi+coFJRdnDHLiI4rTqxQCm + oHLEMMgxFR1mJgMOQ1YHO7S14b1zQhQ5iHsLXoiM6g9SbTICDPdIRbiLw5kyqpNK72djNgGWIYj + GVIPB5e+cBrauvSdh5tGWKbEHMJFrn6HxDf0bNOfE+Na7cEWaFPT+m+oNMjip9J/pE90Xrz9Gph + GWIYjGUIW/zZyMysOcrGuTjXVAwXjbgST0WjKbZ70nXkC77VFy9r/jEXZteC077W0NXCMsQwGJu + HNGJsp+QlfZqXsHWHKi4n1xS0YZvToWc+lPLr+U+k2BSqgV31MnNjvgfLEMNgjGWsFFytiM3WcZ + WBOUWgoj6kqv/Ii00RXBm7GljViBFXwaD/d2IZYhiMjbKWgreUhlb3OAFz4CHZz6aGWHd4hTnHF + cWWjeBAeJKpKbAMMQy3HEO45Mfecfl3qNSyuB5iRtt/XP43hK5w3nK+4rcBNa7FZQIsQwyDMdFF + qxh9UZb+6HtIlr1wF8SHFM6JPsVGueDiMzej8W21sAwxDPYHMQy3nFNfCmltrKuWRDrhv0HlUMW + V8Rrn1JsGyxDDYLS1XA927ZZWooL+MzC29sycuHmNCq3AMsQwfGt8CFHISwEqskbDWwPlkeVgGW + JxczH20lidTXe3AixDLCwsLCwsviX4P68/8cprSSqmAAAAAElFTkSuQmCC +ROLE:Developer +SOUND;ENCODING=b:UklGRiQgAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAgAA + B/f39/f39/f39/f39/f4B/gH+Af4CAgIGBgYGBgYGBgYGBgYGBgYGBgIGAgICBgYGBgYGBgYCAg + YGAgICAgICAgIGBgICAgYCAgICBgICAgICAgICAgIGAgICAgYCAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAf4CAgICAgICAgICAgICAgIB/f4CAgICAgICAgIB/f4B/f39/f39/f3+AgICAf4CAf3 + 9/gIB/f4CAgH9/gICAgH+AgICAgICAgICAf4CAgIB/gICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgIB/gICAf39/f39/f3+Af4CAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgH9/f39/f39/f39/f39/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgIGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgYCAgICB + gICAgYGBgICAgICAgICAgIGAgICBgICBgYGBgYGBgYGAgYGBgYCBgYGBgYGBgYGBgYGBgYGBgYG + BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgICAgYGBgIGBgYGAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgH+AgICAgICAgICAgICAgICAgICAf4CAgIB/gH+Af4B/f39/f39/f + 39/f39/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgYG + BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY + GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAgIGBgYCAgICBgYCAgYGBgYCAgICBg + YCAgICAgICAgICAgICAgIGAgICAgICAgICAgICAgYGBgYGAgICAgIGBgYCAgICBgYGAgICAgIGA + gICAgICAgIGBgYCBgYGAgYGBgYGBgoGBgYGCgoGAgICBgYGBgYCBgYKCgYGBgYGBgYGAgYGBgH9 + /gIB/f3+AgIB/gH9/gICAf4CBgYB/f35+gIB/f4CBgX9/gYCAgYKCgYCAgYOBgICAgoGAf4GCgn + 9/gIB/gICBgH5/f4GAfX+BgYB+fn9/fn+Afn6Af39+f35+fn9+fn6AgH9/f4CAgYCAgYKCgH9/g + IKBf3+AgYJ/f4GCg4F/gIGCgoOBfoCDgYF/fH+BgYGAfn6Af4CCgn58gIN/fX+AgICBgYGAgYCB + goOCgICBgYB/fXyBhIGAgH5+f4GBgX9/f35+gIKCgXt9goN/f318f4GAf4B/fHt9fn5+fXx+fn5 + /gH9+fHx/gHx9f4CAfn18gIB9e4GBfn5+foCBfHyAgoGAfX6CgYCBgH+DgHt9gYN/fX2BhYB7en + 6AgH98foKCgH18foCAfoCAf4CAf31+fn+AgH1+goJ/fX5/gIKAgIGAfH6CgX17foCBf3+BgoB/g + YOBgIB/f4KDgoJ+e3+ChIOBfn1/gX+BfX2BgH59foCCfn1/gX99fICAgoB/f39/gISCf36AgoSB + foCBgYGAf4CCf4CCgX5/gYKDgYB/gH+BhIOBgYB/gIOEhIF9foGCg4OBgICBgoOCgICChIOBg4O + CgoSDgoKAgYKBgoODhISBf4CCg4SEgoGCg4SEgH6BhIWEgX+EhYKAgoKFhIB+gIKChYKAgYOCgo + B+gYWFhIKAg4WEg4ODhIWFhYaGhIWGhYWGh4eHhYOCgoSFg4B/gIB+fX1+fn57e3t7fHt6fH5/f + 4GDhYiMkJGQj5GVmZycmZiXlZGIfXRwcnZ4d3Nva2hoamppaWxvc3R0dXl+iJCPjZShqrCzvNHi + rFYxOmKSrJ6UmJOAbV1ZboSMjI6JfnNjW2JweYGFg4B/e3Z0c3Btc3p9fHp4fIGBf3+Dh4qLjJG + YnZuWkY6MhnpwbnN6fHlya2hlZmdmaW9ycXFzd3t/g42cpquzvMzd/sRADiBZkL6xpLa1jFpANV + iHoJ2ioJWGbEQ2VHaOm5aHhIFuYmZzgoVxZFxfdJCSgnt/kKewr7bDsopcSV6JopyRjpOQfmNXZ + HmGhYB8fXtvXExKXnyKgnJsc3t8fZC0ysfK0+vHTxEeXY6yr6rAxJRSNTdbh5+fp7KjglQ6PVx3 + ho6Ph3dmW15oa2x0hIuNkK3R18jJ0Ys8LUlxkqais8WtdlBFT2yDjpywro9mS0VVaXaBiIdyX2J + rcG5udYKKjaXT4dfV2Y82JkBpiaKkvdO2eE9GTGZ4hZu6u51yTUNOX2l9kZWKdl5PXG93dHeAip + KZut7j2tacRjJIYHCOo77XvoRdVlFYZniVuL+kfl9ST1Rcb4mTjoNxW1pqdXd5fH6CiKHN4d7k2 + 4E4N05Yaoqo1eO0emVbTU5ZdKDCuZV9b1tMSVlyiYp8dHl7cmpqdYCCgIqixNTR2OqnRTlPXFt3 + ksbnw4lzcFdKS2KMtLWZiIZwV0lPZXZ1b3uNinZqbXJ3dX2XxOPg4/zDUDRCTUhmiMXx1p+If1g + +O1J7pK+yspN3W0pGVGdugYmCen54b21rb3V9i6vZ7vD92WpAS0gzSny04tq3qp5qPDhHX3uVrs + KukXVhT0hRYnF/gnuCh31ubG9zdHeMs+Dr8P7KalFVOylJeq7QzMPIqmtIRUZOY4KovqicknhZS + 1BWXWh6gIeLiH91b21vc4GcyuXt/umTZGhGIjJfh6y+yt7LkGlfTD1GYYOipKKwnXhkXldVUFhs + dYOMjYWBem9ucoCWvNTm9+2weHdZMSpQboujvtnUrY6BZEdDUmV4jZypppeFd2dcWVFWWWh8hYS + Ii393c3Z7iJ3A1ePp3aGDfVYyOVZkfJe5zsavpJNsU1BTVmR9kpmcn5uGdGxoWU5VVGZ0fIKLh4 + F/d3Z6g4ufuc3e3depjoViPz9VWm2FqLu8tLGifmphWlJZbH+Lj5+elod+c19WU0xUZW11gISEg + nx6e3h6g4qWp7zM3NrSpZGIYkRFVVVlfZ6vsbW3qIl7b2BUWGVwe4ybn52TkIRuX2BVRVFjZmp7 + hIF9fX12cnZ6eX6LlZyousfP0c++jot6X0ZRXF9sgaCnqa6yn4eAdGZZYGlvd4mcnqCWnY91aWN + cSUtYYmJxf399f351cXFzcHF4foOIlZ+hp7CytLm8uLKNg4RtYF5oanN8j5qZnqGaioV9dGpqb3 + J1f42Rk5iZjIKAcmFcW1RXYGhwdXt+e3Z2c25tcXJxd3yChY2Tl5udn6Gho6ioq6uonoaHbWNzZ + GdxgoGPlZqdj5CJgHFzcWxwdH1/hYqOioSFfnFpaWBdX2Jqb3N5fHh4eHNxcXFxc3d7foOJjI6Q + lZOSlZOTl5eYnJucnpyZkYiEfnd1dnZ5fYKHio6QkIyHg394dHRzc3Z5fHt2enJrcG5obG9sbW9 + ucHJzdnh3eXp5eXt9foCDhoeJjI6OkJGSk5aYmZudn6Gjn5qLh4J3cnJ0dHR5g4GEi42Ih4aBfH + h4dXR1eHl4dXhuaW5rZ2ltaWttbW5vcnR1dHZ2dXV2d3d7fn+BhIeIiYuOjpCTlJWZnJueoKarr + ZuJhntvaW1ucnh+hIWJi4qFg4F7d3V1c3R3fH1/gHlvbXJnXmdpYmdtamtxcW9vbm9tamxtbG5z + dXZ5fHx7fX9+fH6AgoWHioyNj5CRlZeYmp2TiYyGenp9eXh9fX19foB/fH1/e3p8e3l5e3x7e3x + 6d3FxcnBwcG9vb29vb29wb25tbWxsbW5vb3Fyc3N1dXV1dnd4ent9fn+BgoGAgoWEhoqJiYyLi4 + yPioaLiYSEh4WDhIOCgoKAgX58fXx5eXp4eHl4dXZ1cnN0dHR1cnJycXBxcnJycW9ubGxsbW1ub + m5ub29vcXNzdHZ2dXh6enp+fn5/gYCBhIKFiYeGiomJi4qKjIuLjIyLiomKh4aKioeIiIWDgYB9 + fHx7e3l4eHh2dnd3d3l7enp6enp5ent7e3x7enl6e3t7fHx7e3p8fX5/gIKDg4GCg4KCg4OEhoe + Hh4iJiomLjIqLi4uLi46Pjo2OjouJiomHh4aDgH9/fXp5eXh3d3h4eHh4d3V2d3Z0dnd0dXd3d3 + p7fH59fX19fH5+fn+Af4CAf3+Af359f4KDgoSIiIeJjI6PkJOUk5SYmZiYmZqZmJqamJiZmJaWl + ZSTkZCQj46Ni4qHh4iFgoKBfn9+fn+AgYCAgYOCgoSEg4SFhIODg4OCgICBf35/gICAgYKCgYGD + hIOBgYOCgYGAgIGBgIGCgoKBgoSEg4KCgH9/f318fHt6e3t7enl5eHh5fH18foCAf4GDg4OFhoa + GhoeJh4aJioiIiYiIhoWGh4aGh4eHiImHh4mIiIeHh4iIiIqJioqJh4mKh4eJiYiHh4eHhoWGhY + OEhYWEhYWDg4SFhYWEg4SDgYKCgH+AgICBgoOCgYGBgYKEhoaGhoiIh4eJiYmKioqKiomKioiJi + oqJiYmJiIiIiYiHh4eHh4eGhYWFhISDgoKCgoKCgYGAf31+fXx9fn58e3x8fHx9fX19fX19fX19 + fHx9fn5/gICBgYGCgoKCg4OCgoODgoKDg4OCgoKCgoGBgYGBgYGCgYCBgIGCgoKDg4KCg4OEhIS + FhYWFhYWFhYWFhoWGhoWEhISDg4ODg4ODg4ODg4SDgoKDg4OCg4SDgoKDgoGBgoGAgIB/f35+fn + 9+fn9/f35+fn5/gICAgIGBgYKCg4ODg4SEg4OEhIODhIODhIODg4ODg4OCgoKBgoKCg4OCgoODg + 4ODg4OEhISEhIWEhIWFhISEhISEhIWEhISEhIODhISEg4ODg4ODg4ODg4ODgoKCgoKCg4KCgoKC + goKCgoKCgoOCgoKCgoKBgYKCgoKCgoGBgYGAgICAgYGBgYCAf39/f39/f3+Af39/f39/f39/gIC + AgIB/f39/f39/gICAgIB/f39/gIB/f39/gH9/f39/f39/fn5+f39/f39/fn5+fn5/f39/f39/fn + 5+fn9/f39/f35+fn5+fn9/f35/f39+fn5+fn9/fn5+fn5+fn5+f39+fn5+fn19fX5+fn5+fn5+f + X5+fn5+fn5+fn19fn5+fn5+fX19fX59fn5+fn19fX19fX1+fX19fX19fX19fX19fX19fX19fX19 + fX19fX19fX19fX19fX19fX19fX19fX19fXx9fX18fH19fXx8fXx9fXx8fHx8fHx8fH19fX19fXx + 9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX + 19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f + X19fX19fX19fX19fX19fX19fX19fX19fX1+fX5+fn19fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+ + fn5+fn5+fn5+fn5+f39/fn5/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f3 + 9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f + 39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/ + f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f39/f39/f39/f39/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3 + 9/f39/f39/f39/f39/f39/f35+fn5+f35/f39/f39/f39/f39/f39/f39/f39/f39/f39/f35+f + 39+fn5/fn5+f39/fn9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/ + f39/f39/f39/f39/f39+fn9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f4CAf39/f39/f39/gIB/f39/f39/f4B/f4CAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgIB/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAgIC + AgICAgICAgICAgICAgICAgICAgICAgIGBgYGAgYGBgICAgIGAgICBgYGAgYGBgYGBgYGBgYGBgY + GBgYGBgYGBgYGBgYGBgYGAgYCAgICAgICAgICAgICAgICAgICAgICAgICAgH+AgICAf39/gH9/f + 3+Af39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4CAgH9/gIB/f39/f4B/f3+AgICAf4CA + gICAgICAgICAgICAgH9/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgIB/f39/f39/f39/f4CAf39/f39/f39/f39/f39/f39+fn + 9/fn5+fn5+fn5+fn5+fX19fX19fX19fX19fX19fX19fn5+fn5+fn9/f39/f4CAgICAgICBgYGBg + YGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICAgICAgICAgICAgICAgYGAgICA + gICAgICAgICAgICBgYGAgICAgICAgICAgICAgICAgICAgICAgIB/gICAgH9/f39/f39/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAgICAf39/f39/gH+AgI + CAgICAgIB/f39/f39/f4B/f39/f39/f39/f39/f39/f39/f39/f39/f39/fn9/f39/f39/f39+f + 39/f39/f39/f39/f39/f39/f39/f4B/f4CAgICAf39/f39/gICAf39/gICAgICAgICAgICAgICA + gICAgIGAgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICBgYGBgYGBgYCBgYGBgYCAgIG + BgICAgICAgICAgICAgICAgICAgICAgICAgICBgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAf3+AgIB/f4CAf39/f39/f3+AgICAgH+AgICAf3+AgICAgICAgH9/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3 + 9/f39/f39/gH9/gICAgICAgICAgIB/gICAgH+AgIB/f39/f39/gICAgICAgH9/f3+AgH9/f4B/f + 39/f39/f39/f39/f3+AgICAgICAf3+AgIB/f4CAgIB/f4CAgICAgICAgICAf39/f3+AgIB/f4CA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAf39/f39 + /f4CAgH9/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f39/f39/gIB/f39/f39/f39/gH9/f3 + 9/f4CAgICAgIB/gICAgICAgICAgICAgICAgICAgICAgICAgH+AgICAf4CAgICAgICAgIB/gICAf + 4CAgICAgH+Af4CAgH9/f39/f39/f39/gICAgICAgICAgICAf39/f39/f4CAgH9/gICAf3+AgICA + gICAgICAgICAgICAgICAgICAgIB/f39/gIB/f4CAgIB/f4CAgH9/gICAf39/f39/f39/f39/f39 + /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3 + 9/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAf39/gH9/f3+AgH9/f39/f39/f39/f39/f + 39/f39/f39/f39/f39/f39/f39/gICAf3+AgH9/f3+AgH9/f4CAgH9/gICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAgICAgICBgYGBgIGBgYCAgYGAgICAgYCAgICAgICAgICAgICAgICAg + ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA + gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC + AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI + CAgICAgICAgICAgICAgICAf39/f39/f4CAgIB/f4CAgICAgICAgICAgICAgICAgICAgICAgICAg + ICAf39/f3+Af39/f39/f39/f4B/f39/f4CAgICAgICAgICAgA== +TEL;TYPE=HOME:0351 223344 +TEL;TYPE=WORK:0351 443322 +TEL;TYPE=CELL:0173 223344 +UID:P9HXg34Oav +URL:http://www.mustermann.de/~heiko/ +VERSION:3.0 +X-KADDRESSBOOK-X-Anniversary:1982-07-07 +X-KADDRESSBOOK-X-AssistantsName:Mr. Smithers +X-KADDRESSBOOK-X-Department:Edutainment +X-KADDRESSBOOK-X-IMAddress:122334455 +X-KADDRESSBOOK-X-ManagersName:Mr. Burnes +X-KADDRESSBOOK-X-Office:223 2nd stage +X-KADDRESSBOOK-X-Profession:Clown +X-KADDRESSBOOK-X-SpousesName:femal clown +END:VCARD + diff --git a/tdeabc/vcardparser/tests/vcard5.vcf.ref b/tdeabc/vcardparser/tests/vcard5.vcf.ref new file mode 100644 index 000000000..712b49494 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard5.vcf.ref @@ -0,0 +1,313 @@ +BEGIN:VCARD
+ADR;TYPE=home;TYPE=pref:;;Buehlauer Strasse 45;Dresden;Sachsen;01327;German
+ y
+ADR;TYPE=work:;;Prager Strasse 55;Dresden;Sachsen;01066;Germany
+BDAY:1955-07-19T00:00:00Z
+CATEGORIES:Friend
+CLASS:CONFIDENTIAL
+EMAIL;TYPE=PREF:[email protected]
+EMAIL:[email protected]
+FN:Mustermann, Heiko
+GEO:19.283333;166.616669
+LOGO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVU
+ AAAOW0lEQVR4nO1df2hb1xX+OlyQwQEJXJAgBQlaiEwDsdqO2l1H47RjMe2gbjOoszG2dozG7aC
+ YMIqTjS7NYKSmbE1StsQpWxMXmsSF1WhlTeSwJlZY06gsSVXWUAkakKAGPajBDxrQ/jjnez8k27
+ EjJdyU+/0jPz29X9L57jnnO+deAxYWFhYWFhYWFu3Hbe082XT2ZF3+WgAAdHZ0AgBqTg0A4H7DT
+ 7oAgNSdKQDAg99/sK33caPB53RqFQBA5PYIAMBdkOf6yc9+ct3P852W786irWjJMs/8+0wdACpV
+ sZTS50V5vSLb1UoVQMCCvnFDx0c65f3BHw4CABJ3RL19mwYfM4Y1e/+0V5h/VbbPXzwPACiVSgA
+ A15XnikVjAIB44Dli3TIKjL+2e0XPYxliGFZshSdzZ+r8OyKGjdl8AQCQfe84AKBaFUaUrojlRL
+ vEUpx5h0eGjo9EZH+kQ7Yz9/d71+vdkAYApO+W16d+/NQNZ8ye8T11ACiV5TkcR5jufCX3XyrLc
+ 9XmxUe6bvi5XH3OaNRnSKRL9vWsywAAstNTyz6HZYhhsD+IYbjmMPDxfz6uA0BMqQcAR96eAgBM
+ vSevtTkJa6tzQnVSNn2XOLSZ03ljHHQ7MLxlSIa2kg5pOrTVHHHu/hANRDrke4t2y3cy+KgEMPs
+ P7F/0O7EMMQzXtNxLn16qA8DUu1nvvcm3DgEAFlxxbo4jFpFYK4woXix8qxhxLYxuH6sDQG5Gvq
+ NSueLtcxwdNTTASemoUTi3+HdkGWIYlrTkj2clzC1ckGRv3xv7vH2VK7QAlUDuktA0f/bG+YpL5
+ 4WpDDXv7TdPbjm472AdACbe9L+r4mdMHuW+42uTAIByuWwZciugY6kdER3zzn8iMkFt3pc93Kvy
+ d0QzvHYxI5h8Qq/BiK1YLur78nJw4mBIznj2V88ueg+HjxyrA0BEdE7EumLePp773u/e25b7jyb
+ kfAObh7z3SleELS40SVZ/u+2F0ToA7H99PHRtyxDD0GQZZ9RKKxUZ+/YdmAAAFD4peJ9hbF2dq7
+ aHGSpn12p+dJI7PQsAcDS3YcxfmZPXnrt65F40P+pd3wsgwF69x/xHedlWNkfX+PlUep0ck0omA
+ ACxO+R10w82tfRch8leAJOas82ek+cho/sfkGtnT8xYhpiMJh9CiytVZayjYIgO37KCmWgrOPy3
+ w3UAKKpsf/zd496+wkVhpOu5Lje0XS6X9X5lbJ49KxZIJqSSEu+Xrsj9V1Xw5OcBIPJBDoCfPw0
+ 9IVn0sanpOgA8NXR9JYBILO7/rd8n/RV9SM1tPg6wDDEOTQxhFEKLYjbuBljBX9tjzyox/Q+xQO
+ crOf7I20cAAIVz+cCnVNJu8Alo3Nb43nEjoSfa8dIOAMDs6Zy+3wcAyM3kvCtUyZ6qXLd0WZj6z
+ E+fAeAX4FZbYo5Fmt9zXfeanwEsQ4xDE0Nqbi203ZhztANVZUb2PdF+imqZLgLX0OvSd7lLbPO+
+ OFan1B8wGotEE3pCYfpWtX4A2L1rZ+gcHN+Pa8EtEpX3mR9tGlieKSf/dVJ9Ysl7j/fhMYTfuDa
+ ANMIyxDA0Z+r6Qy7MC1Mi3lge1PijTYetBNNTkjUfOjQJAMi+LzE6S7nJtX50krknE74hZQZbij
+ o19U7eKcfQAKuaP7lam+hRdZXl19kZX7Xe+PBG2acM7YzE9Bpi1UfeFN9G7Y6+77EfLR59UdGtV
+ X2G8D7IEPrf7PtZq2XdCmhiCBsUYnGxLJfxP5rzkI0Pb6wDwMypmWXHVupOk0eFEfQZIy+MAQB6
+ 79OGhnSvd0yk4c5o4c7Xamlrwj7Nqck9uVf5eblGVnONqIY1W38+4h3DyJH1i6j6jFi3+B1GaPm
+ 8RGFsa9qrqu7zI6KfHXtHmM8KKq8ZfNZg/rMcLEMMQ5NlH/zLwVDz28SbomVRUxI0RDZJZrqici
+ biYmHFz8Q6cmox6bR8bsfOVwD44ylzH47dgK9lTf5dqpOzZ0V1Hnh0AIDfXMdmO7Zx0h8MaO2aT
+ JtQf7D16Se9a9CS0+uEofQVmV7ZjqhPmXhrIvQcnV2doeemv6UfIysAeNoVg9TMfdLqZH3ILYIl
+ x36Oi/v+Knp+/mwhsFfHcR0X2W3Su0Gy4ZrG3tU5GaOHtwhzXv3jqwB8ZgFiaezamFVWAMDO30u
+ OQAsjfvFL8QHpdFLOoPE8FQXG99UvxecMbhameOrCnB8tbh0WtjA3IZuYl6TXC1PoY/b9eRwAUL
+ hYDH3emXdD20EwX4p3SzS4VKWQsAwxDPYHMQxLlnDpJNlbSyEO8BvjvDKrJnZFlcxJ+biGkRT6Y
+ nf45VMAqHypXfMa0uY+8JM2Fpycr+QzfQ+JM0+nhPoMBHit3FFxuHT6FB8rGsYnusWZVsoBAVOH
+ QzrlkoqlcW1qSyQkOMmsE+c9sk2Gy+d//Xzo+Ago40RD3wsARKMrG6oIyxDDsCRDOAtodLsU44M
+ d3QtXKcnzLGELoXN7cos4y3jcl0QAYOFrOZ4ySLGooWqgOYBs4XVp+Qw9i2XZX1GyZtIJvQdhRi
+ Il23S4ntgYSNB67xcWTs2ouDmn97FRrlX6MlzUSt8jo8XQlq0AgMm3J8Ln1OfmnBBg9U2DliGGY
+ UmGEON7pE1lVNtWAGD2IwlPK1fF6jhziGMxE8eR54QhnWtUatY5hpS5ixfCPmexsDHRLedOeDK6
+ YOARsdLxabHqVJIiozbvqQzvsZnvJ33r7dkgfuXQBWHC6NMSIrvqZ+grOTOsX+evPLlZRMlCXsv
+ GGsZn1osgOt7Q2rMaWIYYhmsyhAj+6tue2ybNZ59ruVfl5k614igL+90NvoNz9LT5jkJgKiVWS5
+ 8CAOVSGYAv9FU0eezXaItsHHkkCQBI360RnDKBzODx7iKNGcPa1FCZk3JArZzT53FC5yB4DxGN8
+ IY04d3+m+23AcDMqZmma6wWliGGYcUMCWL/G+HJJsNbhkPtPBxrGwv5pcufAgDcrzlPXayX430w
+ D2GMTx/CQlkqqUzokGO8MpZGUwtagqbASTAScuZ8ATOVlGa7wT6Jnnb/QacTaO4CFR0JFsXiiXj
+ oGrte3lUHgJ2/29ly46BliGG4LoY0YvLoZMgyjr9zXCKyTrEozuemsEfRjtEZfUq+4MvWjFxojd
+ ympTNqamq+iKjP8LJlln6VGQGxkj4hpS2lbJYeXC++xZuQpOxjO2hCi3f0lSxVtAOWIYahLQxpB
+ KXmijJjQed1R9nbptbNAhbbgRBoQYomxAobW0M5jvuWrpGQRj7MyFlsYg6RSDCS863ZnZf3EmuF
+ VcNPDMv9/FNKsfsPHAoxf/RFmbpWLLBtVa5JNvY90FcHWpueYRliGNrKkC/+90Ud8EucLjR7dtQ
+ 3qALLaCz7vsT9nO6V7vVXcqBi6jYUqHB7wyvCDWccz6kGpFU1ZqNCENWaKAWOMjZzn8RsbOTDgU
+ Ohz690vZJWYBliGNr6i1/6r0zM9LQqVXGZI3yqeQjfZ4ae2SCWyaY3QbhldOB7kqHHEuGaSiNe+
+ a3UXlh2zeiaKYOPS7nW19uA8dekPB3TXGf0xVEAgXKv1oCok+VOCcs2DbY2oWc5WIYYhrb4kOms
+ tFgWL0tUlf9QNB0ygcwoXw5XzQY3D9YBIK7M4MQZwM87HM1dSmzP1KgrFgv7joUFNjlwqSF5efV
+ 1YUHurFj32PYx75gdL+uUhbyuf6UZeq9WFznJv6KqL33fjYRliGFoiSGc0FLUxQW8VsolmsAa4U
+ VCSRnng1PlqBPFNO/gKnVs76RP6WRuo35q6HHJsqkKsPZOto7v2e1dY+QF8RkDfaqIdZCVmsOo+
+ swIjbX/GwnLEMPQEkPatZoomdE47QsAoHX6aDRcm+B4X/K6YbT+oYxg/ZttopzKxsmhgF8zrzR0
+ 0bDjhp/l8iL508s3lbcDliGGwf4ghsGIFXWONaxHAvgrDMVUhmGLEfuA4xoiT70rgQQdrteBr6X
+ bktcoF94G/GY6hrO5U9pipAEAz1mttmfFipXAMsQw3BD5fbVwuJbUGl868UJMXdNEa0eIdocLUJ
+ wH8souSfI8eV7DYcr2lPqDgUNlPtzKSqawIMXQ+3rn418PLEMMgxE+hNirCxkDQK82SrgqBqY5K
+ 1eZUanK+94ahrpaUfGCyCCDm0VMpDBImb4SaHKgD/FWFVVmMGFl6Tl3Qgpok0eXXwS5HbAMMQxG
+ MSSIsZekXNp7v8zKymzo0T26WpHO42MjNxsmGHWx6a6/rz/0uWDBi+coFJRdnDHLiI4rTqxQCmo
+ HLEMMgxFR1mJgMOQ1YHO7S14b1zQhQ5iHsLXoiM6g9SbTICDPdIRbiLw5kyqpNK72djNgGWIYjG
+ VIPB5e+cBrauvSdh5tGWKbEHMJFrn6HxDf0bNOfE+Na7cEWaFPT+m+oNMjip9J/pE90Xrz9GphG
+ WIYjGUIW/zZyMysOcrGuTjXVAwXjbgST0WjKbZ70nXkC77VFy9r/jEXZteC077W0NXCMsQwGJuH
+ NGJsp+QlfZqXsHWHKi4n1xS0YZvToWc+lPLr+U+k2BSqgV31MnNjvgfLEMNgjGWsFFytiM3WcZW
+ BOUWgoj6kqv/Ii00RXBm7GljViBFXwaD/d2IZYhiMjbKWgreUhlb3OAFz4CHZz6aGWHd4hTnHFc
+ WWjeBAeJKpKbAMMQy3HEO45Mfecfl3qNSyuB5iRtt/XP43hK5w3nK+4rcBNa7FZQIsQwyDMdFFq
+ xh9UZb+6HtIlr1wF8SHFM6JPsVGueDiMzej8W21sAwxDPYHMQy3nFNfCmltrKuWRDrhv0HlUMWV
+ 8Rrn1JsGyxDDYLS1XA927ZZWooL+MzC29sycuHmNCq3AMsQwfGt8CFHISwEqskbDWwPlkeVgGWJ
+ xczH20lidTXe3AixDLCwsLCwsviX4P68/8cprSSqmAAAAAElFTkSuQmCC
+N:Mustermann;Heiko;;;
+NICKNAME:clown
+NOTE:I'm a friendly note text,\nplease copy me to your address book...
+ORG:KDE
+PHOTO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pV
+ UAAAOW0lEQVR4nO1df2hb1xX+OlyQwQEJXJAgBQlaiEwDsdqO2l1H47RjMe2gbjOoszG2dozG7a
+ CYMIqTjS7NYKSmbE1StsQpWxMXmsSF1WhlTeSwJlZY06gsSVXWUAkakKAGPajBDxrQ/jjnez8k2
+ 7EjJdyU+/0jPz29X9L57jnnO+deAxYWFhYWFhYWFu3Hbe082XT2ZF3+WgAAdHZ0AgBqTg0A4H7D
+ T7oAgNSdKQDAg99/sK33caPB53RqFQBA5PYIAMBdkOf6yc9+ct3P852W786irWjJMs/8+0wdACp
+ VsZTS50V5vSLb1UoVQMCCvnFDx0c65f3BHw4CABJ3RL19mwYfM4Y1e/+0V5h/VbbPXzwPACiVSg
+ AA15XnikVjAIB44Dli3TIKjL+2e0XPYxliGFZshSdzZ+r8OyKGjdl8AQCQfe84AKBaFUaUrojlR
+ LvEUpx5h0eGjo9EZH+kQ7Yz9/d71+vdkAYApO+W16d+/NQNZ8ye8T11ACiV5TkcR5jufCX3XyrL
+ c9XmxUe6bvi5XH3OaNRnSKRL9vWsywAAstNTyz6HZYhhsD+IYbjmMPDxfz6uA0BMqQcAR96eAgB
+ MvSevtTkJa6tzQnVSNn2XOLSZ03ljHHQ7MLxlSIa2kg5pOrTVHHHu/hANRDrke4t2y3cy+KgEMP
+ sP7F/0O7EMMQzXtNxLn16qA8DUu1nvvcm3DgEAFlxxbo4jFpFYK4woXix8qxhxLYxuH6sDQG5Gv
+ qNSueLtcxwdNTTASemoUTi3+HdkGWIYlrTkj2clzC1ckGRv3xv7vH2VK7QAlUDuktA0f/bG+YpL
+ 54WpDDXv7TdPbjm472AdACbe9L+r4mdMHuW+42uTAIByuWwZciugY6kdER3zzn8iMkFt3pc93Kv
+ yd0QzvHYxI5h8Qq/BiK1YLur78nJw4mBIznj2V88ueg+HjxyrA0BEdE7EumLePp773u/e25b7jy
+ bkfAObh7z3SleELS40SVZ/u+2F0ToA7H99PHRtyxDD0GQZZ9RKKxUZ+/YdmAAAFD4peJ9hbF2dq
+ 7aHGSpn12p+dJI7PQsAcDS3YcxfmZPXnrt65F40P+pd3wsgwF69x/xHedlWNkfX+PlUep0ck0om
+ AACxO+R10w82tfRch8leAJOas82ek+cho/sfkGtnT8xYhpiMJh9CiytVZayjYIgO37KCmWgrOPy
+ 3w3UAKKpsf/zd496+wkVhpOu5Lje0XS6X9X5lbJ49KxZIJqSSEu+Xrsj9V1Xw5OcBIPJBDoCfPw
+ 09IVn0sanpOgA8NXR9JYBILO7/rd8n/RV9SM1tPg6wDDEOTQxhFEKLYjbuBljBX9tjzyox/Q+xQ
+ OcrOf7I20cAAIVz+cCnVNJu8Alo3Nb43nEjoSfa8dIOAMDs6Zy+3wcAyM3kvCtUyZ6qXLd0WZj6
+ zE+fAeAX4FZbYo5Fmt9zXfeanwEsQ4xDE0Nqbi203ZhztANVZUb2PdF+imqZLgLX0OvSd7lLbPO
+ +OFan1B8wGotEE3pCYfpWtX4A2L1rZ+gcHN+Pa8EtEpX3mR9tGlieKSf/dVJ9Ysl7j/fhMYTfuD
+ aANMIyxDA0Z+r6Qy7MC1Mi3lge1PijTYetBNNTkjUfOjQJAMi+LzE6S7nJtX50krknE74hZQZbi
+ jo19U7eKcfQAKuaP7lam+hRdZXl19kZX7Xe+PBG2acM7YzE9Bpi1UfeFN9G7Y6+77EfLR59UdGt
+ VX2G8D7IEPrf7PtZq2XdCmhiCBsUYnGxLJfxP5rzkI0Pb6wDwMypmWXHVupOk0eFEfQZIy+MAQB
+ 679OGhnSvd0yk4c5o4c7Xamlrwj7Nqck9uVf5eblGVnONqIY1W38+4h3DyJH1i6j6jFi3+B1GaP
+ m8RGFsa9qrqu7zI6KfHXtHmM8KKq8ZfNZg/rMcLEMMQ5NlH/zLwVDz28SbomVRUxI0RDZJZrqic
+ ibiYmHFz8Q6cmox6bR8bsfOVwD44ylzH47dgK9lTf5dqpOzZ0V1Hnh0AIDfXMdmO7Zx0h8MaO2a
+ TJtQf7D16Se9a9CS0+uEofQVmV7ZjqhPmXhrIvQcnV2doeemv6UfIysAeNoVg9TMfdLqZH3ILYI
+ lx36Oi/v+Knp+/mwhsFfHcR0X2W3Su0Gy4ZrG3tU5GaOHtwhzXv3jqwB8ZgFiaezamFVWAMDO30
+ uOQAsjfvFL8QHpdFLOoPE8FQXG99UvxecMbhameOrCnB8tbh0WtjA3IZuYl6TXC1PoY/b9eRwAU
+ LhYDH3emXdD20EwX4p3SzS4VKWQsAwxDPYHMQxLlnDpJNlbSyEO8BvjvDKrJnZFlcxJ+biGkRT6
+ Ynf45VMAqHypXfMa0uY+8JM2Fpycr+QzfQ+JM0+nhPoMBHit3FFxuHT6FB8rGsYnusWZVsoBAVO
+ HQzrlkoqlcW1qSyQkOMmsE+c9sk2Gy+d//Xzo+Ago40RD3wsARKMrG6oIyxDDsCRDOAtodLsU44
+ Md3QtXKcnzLGELoXN7cos4y3jcl0QAYOFrOZ4ySLGooWqgOYBs4XVp+Qw9i2XZX1GyZtIJvQdhR
+ iIl23S4ntgYSNB67xcWTs2ouDmn97FRrlX6MlzUSt8jo8XQlq0AgMm3J8Ln1OfmnBBg9U2DliGG
+ YUmGEON7pE1lVNtWAGD2IwlPK1fF6jhziGMxE8eR54QhnWtUatY5hpS5ixfCPmexsDHRLedOeDK
+ 6YOARsdLxabHqVJIiozbvqQzvsZnvJ33r7dkgfuXQBWHC6NMSIrvqZ+grOTOsX+evPLlZRMlCXs
+ vGGsZn1osgOt7Q2rMaWIYYhmsyhAj+6tue2ybNZ59ruVfl5k614igL+90NvoNz9LT5jkJgKiVWS
+ 58CAOVSGYAv9FU0eezXaItsHHkkCQBI360RnDKBzODx7iKNGcPa1FCZk3JArZzT53FC5yB4DxGN
+ 8IY04d3+m+23AcDMqZmma6wWliGGYcUMCWL/G+HJJsNbhkPtPBxrGwv5pcufAgDcrzlPXayX430
+ wD2GMTx/CQlkqqUzokGO8MpZGUwtagqbASTAScuZ8ATOVlGa7wT6Jnnb/QacTaO4CFR0JFsXiiX
+ joGrte3lUHgJ2/29ly46BliGG4LoY0YvLoZMgyjr9zXCKyTrEozuemsEfRjtEZfUq+4MvWjFxoj
+ dympTNqamq+iKjP8LJlln6VGQGxkj4hpS2lbJYeXC++xZuQpOxjO2hCi3f0lSxVtAOWIYahLQxp
+ BKXmijJjQed1R9nbptbNAhbbgRBoQYomxAobW0M5jvuWrpGQRj7MyFlsYg6RSDCS863ZnZf3Emu
+ FVcNPDMv9/FNKsfsPHAoxf/RFmbpWLLBtVa5JNvY90FcHWpueYRliGNrKkC/+90Ud8EucLjR7dt
+ Q3qALLaCz7vsT9nO6V7vVXcqBi6jYUqHB7wyvCDWccz6kGpFU1ZqNCENWaKAWOMjZzn8RsbOTDg
+ UOhz690vZJWYBliGNr6i1/6r0zM9LQqVXGZI3yqeQjfZ4ae2SCWyaY3QbhldOB7kqHHEuGaSiNe
+ +a3UXlh2zeiaKYOPS7nW19uA8dekPB3TXGf0xVEAgXKv1oCok+VOCcs2DbY2oWc5WIYYhrb4kOm
+ stFgWL0tUlf9QNB0ygcwoXw5XzQY3D9YBIK7M4MQZwM87HM1dSmzP1KgrFgv7joUFNjlwqSF5ef
+ V1YUHurFj32PYx75gdL+uUhbyuf6UZeq9WFznJv6KqL33fjYRliGFoiSGc0FLUxQW8VsolmsAa4
+ UVCSRnng1PlqBPFNO/gKnVs76RP6WRuo35q6HHJsqkKsPZOto7v2e1dY+QF8RkDfaqIdZCVmsOo
+ +swIjbX/GwnLEMPQEkPatZoomdE47QsAoHX6aDRcm+B4X/K6YbT+oYxg/ZttopzKxsmhgF8zrzR
+ 00bDjhp/l8iL508s3lbcDliGGwf4ghsGIFXWONaxHAvgrDMVUhmGLEfuA4xoiT70rgQQdrteBr6
+ XbktcoF94G/GY6hrO5U9pipAEAz1mttmfFipXAMsQw3BD5fbVwuJbUGl868UJMXdNEa0eIdocLU
+ JwH8souSfI8eV7DYcr2lPqDgUNlPtzKSqawIMXQ+3rn418PLEMMgxE+hNirCxkDQK82SrgqBqY5
+ K1eZUanK+94ahrpaUfGCyCCDm0VMpDBImb4SaHKgD/FWFVVmMGFl6Tl3Qgpok0eXXwS5HbAMMQx
+ GMSSIsZekXNp7v8zKymzo0T26WpHO42MjNxsmGHWx6a6/rz/0uWDBi+coFJRdnDHLiI4rTqxQCm
+ oHLEMMgxFR1mJgMOQ1YHO7S14b1zQhQ5iHsLXoiM6g9SbTICDPdIRbiLw5kyqpNK72djNgGWIYj
+ GVIPB5e+cBrauvSdh5tGWKbEHMJFrn6HxDf0bNOfE+Na7cEWaFPT+m+oNMjip9J/pE90Xrz9Gph
+ GWIYjGUIW/zZyMysOcrGuTjXVAwXjbgST0WjKbZ70nXkC77VFy9r/jEXZteC077W0NXCMsQwGJu
+ HNGJsp+QlfZqXsHWHKi4n1xS0YZvToWc+lPLr+U+k2BSqgV31MnNjvgfLEMNgjGWsFFytiM3WcZ
+ WBOUWgoj6kqv/Ii00RXBm7GljViBFXwaD/d2IZYhiMjbKWgreUhlb3OAFz4CHZz6aGWHd4hTnHF
+ cWWjeBAeJKpKbAMMQy3HEO45Mfecfl3qNSyuB5iRtt/XP43hK5w3nK+4rcBNa7FZQIsQwyDMdFF
+ qxh9UZb+6HtIlr1wF8SHFM6JPsVGueDiMzej8W21sAwxDPYHMQy3nFNfCmltrKuWRDrhv0HlUMW
+ V8Rrn1JsGyxDDYLS1XA927ZZWooL+MzC29sycuHmNCq3AMsQwfGt8CFHISwEqskbDWwPlkeVgGW
+ JxczH20lidTXe3AixDLCwsLCwsviX4P68/8cprSSqmAAAAAElFTkSuQmCC
+ROLE:Developer
+SOUND;ENCODING=b:UklGRiQgAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAgAA
+ B/f39/f39/f39/f39/f4B/gH+Af4CAgIGBgYGBgYGBgYGBgYGBgYGBgIGAgICBgYGBgYGBgYCAg
+ YGAgICAgICAgIGBgICAgYCAgICBgICAgICAgICAgIGAgICAgYCAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAf4CAgICAgICAgICAgICAgIB/f4CAgICAgICAgIB/f4B/f39/f39/f3+AgICAf4CAf3
+ 9/gIB/f4CAgH9/gICAgH+AgICAgICAgICAf4CAgIB/gICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgIB/gICAf39/f39/f3+Af4CAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgH9/f39/f39/f39/f39/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgIGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgYCAgICB
+ gICAgYGBgICAgICAgICAgIGAgICBgICBgYGBgYGBgYGAgYGBgYCBgYGBgYGBgYGBgYGBgYGBgYG
+ BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgICAgYGBgIGBgYGAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgH+AgICAgICAgICAgICAgICAgICAf4CAgIB/gH+Af4B/f39/f39/f
+ 39/f39/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgYG
+ BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY
+ GBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAgIGBgYCAgICBgYCAgYGBgYCAgICBg
+ YCAgICAgICAgICAgICAgIGAgICAgICAgICAgICAgYGBgYGAgICAgIGBgYCAgICBgYGAgICAgIGA
+ gICAgICAgIGBgYCBgYGAgYGBgYGBgoGBgYGCgoGAgICBgYGBgYCBgYKCgYGBgYGBgYGAgYGBgH9
+ /gIB/f3+AgIB/gH9/gICAf4CBgYB/f35+gIB/f4CBgX9/gYCAgYKCgYCAgYOBgICAgoGAf4GCgn
+ 9/gIB/gICBgH5/f4GAfX+BgYB+fn9/fn+Afn6Af39+f35+fn9+fn6AgH9/f4CAgYCAgYKCgH9/g
+ IKBf3+AgYJ/f4GCg4F/gIGCgoOBfoCDgYF/fH+BgYGAfn6Af4CCgn58gIN/fX+AgICBgYGAgYCB
+ goOCgICBgYB/fXyBhIGAgH5+f4GBgX9/f35+gIKCgXt9goN/f318f4GAf4B/fHt9fn5+fXx+fn5
+ /gH9+fHx/gHx9f4CAfn18gIB9e4GBfn5+foCBfHyAgoGAfX6CgYCBgH+DgHt9gYN/fX2BhYB7en
+ 6AgH98foKCgH18foCAfoCAf4CAf31+fn+AgH1+goJ/fX5/gIKAgIGAfH6CgX17foCBf3+BgoB/g
+ YOBgIB/f4KDgoJ+e3+ChIOBfn1/gX+BfX2BgH59foCCfn1/gX99fICAgoB/f39/gISCf36AgoSB
+ foCBgYGAf4CCf4CCgX5/gYKDgYB/gH+BhIOBgYB/gIOEhIF9foGCg4OBgICBgoOCgICChIOBg4O
+ CgoSDgoKAgYKBgoODhISBf4CCg4SEgoGCg4SEgH6BhIWEgX+EhYKAgoKFhIB+gIKChYKAgYOCgo
+ B+gYWFhIKAg4WEg4ODhIWFhYaGhIWGhYWGh4eHhYOCgoSFg4B/gIB+fX1+fn57e3t7fHt6fH5/f
+ 4GDhYiMkJGQj5GVmZycmZiXlZGIfXRwcnZ4d3Nva2hoamppaWxvc3R0dXl+iJCPjZShqrCzvNHi
+ rFYxOmKSrJ6UmJOAbV1ZboSMjI6JfnNjW2JweYGFg4B/e3Z0c3Btc3p9fHp4fIGBf3+Dh4qLjJG
+ YnZuWkY6MhnpwbnN6fHlya2hlZmdmaW9ycXFzd3t/g42cpquzvMzd/sRADiBZkL6xpLa1jFpANV
+ iHoJ2ioJWGbEQ2VHaOm5aHhIFuYmZzgoVxZFxfdJCSgnt/kKewr7bDsopcSV6JopyRjpOQfmNXZ
+ HmGhYB8fXtvXExKXnyKgnJsc3t8fZC0ysfK0+vHTxEeXY6yr6rAxJRSNTdbh5+fp7KjglQ6PVx3
+ ho6Ph3dmW15oa2x0hIuNkK3R18jJ0Ys8LUlxkqais8WtdlBFT2yDjpywro9mS0VVaXaBiIdyX2J
+ rcG5udYKKjaXT4dfV2Y82JkBpiaKkvdO2eE9GTGZ4hZu6u51yTUNOX2l9kZWKdl5PXG93dHeAip
+ KZut7j2tacRjJIYHCOo77XvoRdVlFYZniVuL+kfl9ST1Rcb4mTjoNxW1pqdXd5fH6CiKHN4d7k2
+ 4E4N05Yaoqo1eO0emVbTU5ZdKDCuZV9b1tMSVlyiYp8dHl7cmpqdYCCgIqixNTR2OqnRTlPXFt3
+ ksbnw4lzcFdKS2KMtLWZiIZwV0lPZXZ1b3uNinZqbXJ3dX2XxOPg4/zDUDRCTUhmiMXx1p+If1g
+ +O1J7pK+yspN3W0pGVGdugYmCen54b21rb3V9i6vZ7vD92WpAS0gzSny04tq3qp5qPDhHX3uVrs
+ KukXVhT0hRYnF/gnuCh31ubG9zdHeMs+Dr8P7KalFVOylJeq7QzMPIqmtIRUZOY4KovqicknhZS
+ 1BWXWh6gIeLiH91b21vc4GcyuXt/umTZGhGIjJfh6y+yt7LkGlfTD1GYYOipKKwnXhkXldVUFhs
+ dYOMjYWBem9ucoCWvNTm9+2weHdZMSpQboujvtnUrY6BZEdDUmV4jZypppeFd2dcWVFWWWh8hYS
+ Ii393c3Z7iJ3A1ePp3aGDfVYyOVZkfJe5zsavpJNsU1BTVmR9kpmcn5uGdGxoWU5VVGZ0fIKLh4
+ F/d3Z6g4ufuc3e3depjoViPz9VWm2FqLu8tLGifmphWlJZbH+Lj5+elod+c19WU0xUZW11gISEg
+ nx6e3h6g4qWp7zM3NrSpZGIYkRFVVVlfZ6vsbW3qIl7b2BUWGVwe4ybn52TkIRuX2BVRVFjZmp7
+ hIF9fX12cnZ6eX6LlZyousfP0c++jot6X0ZRXF9sgaCnqa6yn4eAdGZZYGlvd4mcnqCWnY91aWN
+ cSUtYYmJxf399f351cXFzcHF4foOIlZ+hp7CytLm8uLKNg4RtYF5oanN8j5qZnqGaioV9dGpqb3
+ J1f42Rk5iZjIKAcmFcW1RXYGhwdXt+e3Z2c25tcXJxd3yChY2Tl5udn6Gho6ioq6uonoaHbWNzZ
+ GdxgoGPlZqdj5CJgHFzcWxwdH1/hYqOioSFfnFpaWBdX2Jqb3N5fHh4eHNxcXFxc3d7foOJjI6Q
+ lZOSlZOTl5eYnJucnpyZkYiEfnd1dnZ5fYKHio6QkIyHg394dHRzc3Z5fHt2enJrcG5obG9sbW9
+ ucHJzdnh3eXp5eXt9foCDhoeJjI6OkJGSk5aYmZudn6Gjn5qLh4J3cnJ0dHR5g4GEi42Ih4aBfH
+ h4dXR1eHl4dXhuaW5rZ2ltaWttbW5vcnR1dHZ2dXV2d3d7fn+BhIeIiYuOjpCTlJWZnJueoKarr
+ ZuJhntvaW1ucnh+hIWJi4qFg4F7d3V1c3R3fH1/gHlvbXJnXmdpYmdtamtxcW9vbm9tamxtbG5z
+ dXZ5fHx7fX9+fH6AgoWHioyNj5CRlZeYmp2TiYyGenp9eXh9fX19foB/fH1/e3p8e3l5e3x7e3x
+ 6d3FxcnBwcG9vb29vb29wb25tbWxsbW5vb3Fyc3N1dXV1dnd4ent9fn+BgoGAgoWEhoqJiYyLi4
+ yPioaLiYSEh4WDhIOCgoKAgX58fXx5eXp4eHl4dXZ1cnN0dHR1cnJycXBxcnJycW9ubGxsbW1ub
+ m5ub29vcXNzdHZ2dXh6enp+fn5/gYCBhIKFiYeGiomJi4qKjIuLjIyLiomKh4aKioeIiIWDgYB9
+ fHx7e3l4eHh2dnd3d3l7enp6enp5ent7e3x7enl6e3t7fHx7e3p8fX5/gIKDg4GCg4KCg4OEhoe
+ Hh4iJiomLjIqLi4uLi46Pjo2OjouJiomHh4aDgH9/fXp5eXh3d3h4eHh4d3V2d3Z0dnd0dXd3d3
+ p7fH59fX19fH5+fn+Af4CAf3+Af359f4KDgoSIiIeJjI6PkJOUk5SYmZiYmZqZmJqamJiZmJaWl
+ ZSTkZCQj46Ni4qHh4iFgoKBfn9+fn+AgYCAgYOCgoSEg4SFhIODg4OCgICBf35/gICAgYKCgYGD
+ hIOBgYOCgYGAgIGBgIGCgoKBgoSEg4KCgH9/f318fHt6e3t7enl5eHh5fH18foCAf4GDg4OFhoa
+ GhoeJh4aJioiIiYiIhoWGh4aGh4eHiImHh4mIiIeHh4iIiIqJioqJh4mKh4eJiYiHh4eHhoWGhY
+ OEhYWEhYWDg4SFhYWEg4SDgYKCgH+AgICBgoOCgYGBgYKEhoaGhoiIh4eJiYmKioqKiomKioiJi
+ oqJiYmJiIiIiYiHh4eHh4eGhYWFhISDgoKCgoKCgYGAf31+fXx9fn58e3x8fHx9fX19fX19fX19
+ fHx9fn5/gICBgYGCgoKCg4OCgoODgoKDg4OCgoKCgoGBgYGBgYGCgYCBgIGCgoKDg4KCg4OEhIS
+ FhYWFhYWFhYWFhoWGhoWEhISDg4ODg4ODg4ODg4SDgoKDg4OCg4SDgoKDgoGBgoGAgIB/f35+fn
+ 9+fn9/f35+fn5/gICAgIGBgYKCg4ODg4SEg4OEhIODhIODhIODg4ODg4OCgoKBgoKCg4OCgoODg
+ 4ODg4OEhISEhIWEhIWFhISEhISEhIWEhISEhIODhISEg4ODg4ODg4ODg4ODgoKCgoKCg4KCgoKC
+ goKCgoKCgoOCgoKCgoKBgYKCgoKCgoGBgYGAgICAgYGBgYCAf39/f39/f3+Af39/f39/f39/gIC
+ AgIB/f39/f39/gICAgIB/f39/gIB/f39/gH9/f39/f39/fn5+f39/f39/fn5+fn5/f39/f39/fn
+ 5+fn9/f39/f35+fn5+fn9/f35/f39+fn5+fn9/fn5+fn5+fn5+f39+fn5+fn19fX5+fn5+fn5+f
+ X5+fn5+fn5+fn19fn5+fn5+fX19fX59fn5+fn19fX19fX1+fX19fX19fX19fX19fX19fX19fX19
+ fX19fX19fX19fX19fX19fX19fX19fX19fXx9fX18fH19fXx8fXx9fXx8fHx8fHx8fH19fX19fXx
+ 9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX
+ 19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
+ X19fX19fX19fX19fX19fX19fX19fX19fX1+fX5+fn19fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+
+ fn5+fn5+fn5+fn5+f39/fn5/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f3
+ 9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f
+ 39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/
+ f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f39/f39/f39/f39/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3
+ 9/f39/f39/f39/f39/f39/f35+fn5+f35/f39/f39/f39/f39/f39/f39/f39/f39/f39/f35+f
+ 39+fn5/fn5+f39/fn9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/
+ f39/f39/f39/f39/f39+fn9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f4CAf39/f39/f39/gIB/f39/f39/f4B/f4CAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgIB/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgIGBgYGAgYGBgICAgIGAgICBgYGAgYGBgYGBgYGBgYGBgY
+ GBgYGBgYGBgYGBgYGBgYGAgYCAgICAgICAgICAgICAgICAgICAgICAgICAgH+AgICAf39/gH9/f
+ 3+Af39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f4CAgH9/gIB/f39/f4B/f3+AgICAf4CA
+ gICAgICAgICAgICAgH9/f4CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgIB/f39/f39/f39/f4CAf39/f39/f39/f39/f39/f39+fn
+ 9/fn5+fn5+fn5+fn5+fX19fX19fX19fX19fX19fX19fn5+fn5+fn9/f39/f4CAgICAgICBgYGBg
+ YGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICAgICAgICAgICAgICAgYGAgICA
+ gICAgICAgICAgICBgYGAgICAgICAgICAgICAgICAgICAgICAgIB/gICAgH9/f39/f39/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAgICAf39/f39/gH+AgI
+ CAgICAgIB/f39/f39/f4B/f39/f39/f39/f39/f39/f39/f39/f39/f39/fn9/f39/f39/f39+f
+ 39/f39/f39/f39/f39/f39/f39/f4B/f4CAgICAf39/f39/gICAf39/gICAgICAgICAgICAgICA
+ gICAgIGAgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYCAgICBgYGBgYGBgYCBgYGBgYCAgIG
+ BgICAgICAgICAgICAgICAgICAgICAgICAgICBgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAf3+AgIB/f4CAf39/f39/f3+AgICAgH+AgICAf3+AgICAgICAgH9/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3
+ 9/f39/f39/gH9/gICAgICAgICAgIB/gICAgH+AgIB/f39/f39/gICAgICAgH9/f3+AgH9/f4B/f
+ 39/f39/f39/f39/f3+AgICAgICAf3+AgIB/f4CAgIB/f4CAgICAgICAgICAf39/f3+AgIB/f4CA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAf39/f39
+ /f4CAgH9/f39/f39/f39/f39/f39/f39/f39/f39/f4B/f39/f39/gIB/f39/f39/f39/gH9/f3
+ 9/f4CAgICAgIB/gICAgICAgICAgICAgICAgICAgICAgICAgH+AgICAf4CAgICAgICAgIB/gICAf
+ 4CAgICAgH+Af4CAgH9/f39/f39/f39/gICAgICAgICAgICAf39/f39/f4CAgH9/gICAf3+AgICA
+ gICAgICAgICAgICAgICAgICAgIB/f39/gIB/f4CAgIB/f4CAgH9/gICAf39/f39/f39/f39/f39
+ /f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3
+ 9/f39/f39/f39/f39/f39/f39/f39/f39/f39/gICAf39/gH9/f3+AgH9/f39/f39/f39/f39/f
+ 39/f39/f39/f39/f39/f39/f39/gICAf3+AgH9/f3+AgH9/f4CAgH9/gICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAgICAgICBgYGBgIGBgYCAgYGAgICAgYCAgICAgICAgICAgICAgICAg
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA
+ gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
+ AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgICAgICAgICAgICAgICAf39/f39/f4CAgIB/f4CAgICAgICAgICAgICAgICAgICAgICAgICAg
+ ICAf39/f3+Af39/f39/f39/f4B/f39/f4CAgICAgICAgICAgA==
+TEL;TYPE=HOME:0351 223344
+TEL;TYPE=WORK:0351 443322
+TEL;TYPE=CELL:0173 223344
+UID:P9HXg34Oav
+URL:http://www.mustermann.de/~heiko/
+VERSION:3.0
+X-KADDRESSBOOK-X-Anniversary:1982-07-07
+X-KADDRESSBOOK-X-AssistantsName:Mr. Smithers
+X-KADDRESSBOOK-X-Department:Edutainment
+X-KADDRESSBOOK-X-IMAddress:122334455
+X-KADDRESSBOOK-X-ManagersName:Mr. Burnes
+X-KADDRESSBOOK-X-Office:223 2nd stage
+X-KADDRESSBOOK-X-Profession:Clown
+X-KADDRESSBOOK-X-SpousesName:femal clown
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard6.vcf b/tdeabc/vcardparser/tests/vcard6.vcf new file mode 100644 index 000000000..92339c798 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard6.vcf @@ -0,0 +1,10 @@ +BEGIN:VCARD +CLASS:PUBLIC +EMAIL;TYPE=PREF:[email protected] +EMAIL:[email protected] +FN:Test User +N:User;Test;;; +UID:uJTkVqH5Qt +VERSION:3.0 +END:VCARD + diff --git a/tdeabc/vcardparser/tests/vcard6.vcf.ref b/tdeabc/vcardparser/tests/vcard6.vcf.ref new file mode 100644 index 000000000..3cfde20b9 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard6.vcf.ref @@ -0,0 +1,10 @@ +BEGIN:VCARD
+CLASS:PUBLIC
+EMAIL;TYPE=PREF:[email protected]
+EMAIL:[email protected]
+FN:Test User
+N:User;Test;;;
+UID:uJTkVqH5Qt
+VERSION:3.0
+END:VCARD
+
diff --git a/tdeabc/vcardparser/tests/vcard7.vcf b/tdeabc/vcardparser/tests/vcard7.vcf new file mode 100644 index 000000000..8b5be8ec7 --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard7.vcf @@ -0,0 +1,7 @@ +BEGIN:VCARD +N: +LABEL;QUOTED-PRINTABLE;WORK:401 Park Drive 3 West=0ABoston, MA 02215=0AUSA=0A= +Herecomesyetanotherline +UID:pas-id-3E136F9B00000000 +END:VCARD + diff --git a/tdeabc/vcardparser/tests/vcard7.vcf.ref b/tdeabc/vcardparser/tests/vcard7.vcf.ref new file mode 100644 index 000000000..84ed6236b --- /dev/null +++ b/tdeabc/vcardparser/tests/vcard7.vcf.ref @@ -0,0 +1,8 @@ +BEGIN:VCARD
+LABEL;TYPE=work:401 Park Drive 3 West\nBoston\, MA 02215\nUSA\nHerecomesye
+ tanotherline
+N:;;;;
+UID:pas-id-3E136F9B00000000
+VERSION:3.0
+END:VCARD
+
diff --git a/tdeabc/vcardparser/testutils.cpp b/tdeabc/vcardparser/testutils.cpp new file mode 100644 index 000000000..6547445e5 --- /dev/null +++ b/tdeabc/vcardparser/testutils.cpp @@ -0,0 +1,99 @@ +#include <vcardparser.h> +#include <tdeabc/addressee.h> +#include <tqfile.h> + +using namespace TDEABC; + +Addressee +vcard1() +{ + Addressee addr; + + addr.setName( "Frank Dawson" ); + addr.setOrganization( "Lotus Development Corporation" ); + addr.setUrl( KURL( "http://home.earthlink.net/~fdawson") ); + addr.insertEmail( "[email protected]" ); + addr.insertEmail( "[email protected]", true ); + addr.insertPhoneNumber( PhoneNumber("+1-919-676-9515",PhoneNumber::Voice|PhoneNumber::Msg + |PhoneNumber::Work ) ); + addr.insertPhoneNumber( PhoneNumber("+1-919-676-9564",PhoneNumber::Fax |PhoneNumber::Work )); + Address a( Address::Work | Address::Postal | Address::Parcel ); + a.setStreet( "6544 Battleford Drive" ); + a.setLocality( "Raleigh" ); + a.setRegion( "NC" ); + a.setPostalCode( "27613-3502" ); + a.setCountry( "U.S.A." ); + addr.insertAddress( a ); + return addr; +} + +Addressee +vcard2() +{ + Addressee addr; + + addr.setName( "Tim Howes" ); + addr.setOrganization( "Netscape Communications Corp." ); + addr.insertEmail( "[email protected]" ); + addr.insertPhoneNumber( PhoneNumber("+1-415-937-3419",PhoneNumber::Voice|PhoneNumber::Msg + |PhoneNumber::Work) ); + addr.insertPhoneNumber( PhoneNumber("+1-415-528-4164",PhoneNumber::Fax |PhoneNumber::Work) ); + Address a( Address::Work ); + a.setStreet( "501 E. Middlefield Rd." ); + a.setLocality( "Mountain View" ); + a.setRegion( "CA" ); + a.setPostalCode( "94043" ); + a.setCountry( "U.S.A." ); + addr.insertAddress( a ); + return addr; +} + +Addressee +vcard3() +{ + Addressee addr; + + addr.setName( "ian geiser" ); + addr.setOrganization( "Source eXtreme" ); + addr.insertEmail( "[email protected]" ); + addr.setTitle( "VP of Engineering" ); + return addr; +} + + +QString +vcardAsText( const TQString& location ) +{ + TQString line; + TQFile file( location ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream stream( &file ); + if ( !stream.eof() ) { + line = stream.read(); + } + file.close(); + } + return line; +} + +Addressee::List +vCardsAsAddresseeList() +{ + Addressee::List l; + + l.append( vcard1() ); + l.append( vcard2() ); + l.append( vcard3() ); + + return l; +} + +QString +vCardsAsText() +{ + TQString vcards = vcardAsText( "tests/vcard1.vcf" ); + vcards += vcardAsText( "tests/vcard2.vcf" ); + vcards += vcardAsText( "tests/vcard3.vcf" ); + + return vcards; +} diff --git a/tdeabc/vcardparser/testutils.h b/tdeabc/vcardparser/testutils.h new file mode 100644 index 000000000..830f94332 --- /dev/null +++ b/tdeabc/vcardparser/testutils.h @@ -0,0 +1,14 @@ +#ifndef TESTUTILS_H +#define TESTUTILS_H + +#include <tdeabc/addressee.h> +#include <tqstring.h> + +TDEABC::Addressee vcard1(); +TDEABC::Addressee vcard2(); +TDEABC::Addressee vcard3(); +TDEABC::Addressee::List vCardsAsAddresseeList(); +TQString vCardAsText( const TQString& location ); +TQString vCardsAsText(); + +#endif diff --git a/tdeabc/vcardparser/testwrite.cpp b/tdeabc/vcardparser/testwrite.cpp new file mode 100644 index 000000000..c7df6df08 --- /dev/null +++ b/tdeabc/vcardparser/testwrite.cpp @@ -0,0 +1,134 @@ +/* + This file is part of libkabc. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tdeabc/addressee.h> +#include <tdeabc/phonenumber.h> +#include <tdeabc/address.h> +#include <tdeabc/key.h> +#include <tdeabc/picture.h> +#include <tdeabc/sound.h> +#include <tdeabc/secrecy.h> +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> + +#include <tqfile.h> +#include <tqtextstream.h> + +#include "vcardconverter.h" + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "testwrite", "vCard test writer", "0.1" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + + TDEApplication app( false, false ); + + + TDEABC::Addressee addressee; + + addressee.setNameFromString( "Mr. Tobias Koenig Jr." ); + addressee.setNickName( "tokoe" ); + addressee.setBirthday( TQDate( 1982, 7, 19 ) ); + addressee.setMailer( "mutt1.2" ); + addressee.setTimeZone( TDEABC::TimeZone( +2 ) ); + + TDEABC::Geo geo; + geo.setLatitude( 30 ); + geo.setLongitude( 51 ); + addressee.setGeo( geo ); + + addressee.setTitle( "nerd" ); + addressee.setRole( "Maintainer" ); + addressee.setOrganization( "KDE" ); + addressee.setNote( "nerver\ntouch a running system" ); + addressee.setProductId( "testId" ); + addressee.setRevision( TQDateTime::currentDateTime() ); + addressee.setSortString( "koenig" ); + addressee.setUrl( KURL( "http://wgess16.dyndns.org") ); + addressee.setSecrecy( TDEABC::Secrecy( TDEABC::Secrecy::Confidential ) ); +/* + TQImage img; + img.load( "testimg.png", "PNG" ); + TDEABC::Picture photo; + photo.setData( img ); + addressee.setPhoto( photo ); + + TQImage img2; + img2.load( "testimg.png", "PNG" ); + TDEABC::Picture logo; + logo.setData( img2 ); + addressee.setLogo( logo ); + + TQFile soundFile( "testsound.wav" ); + soundFile.open( IO_ReadOnly ); + TQByteArray data = soundFile.readAll(); + soundFile.close(); + TDEABC::Sound sound; + sound.setData( data ); + addressee.setSound( sound ); +*/ + addressee.insertEmail( "[email protected]", true ); + addressee.insertEmail( "[email protected]", true ); + + TDEABC::PhoneNumber phone1( "3541523475", TDEABC::PhoneNumber::Pref | TDEABC::PhoneNumber::Home ); + TDEABC::PhoneNumber phone2( "+46745673475", TDEABC::PhoneNumber::Work ); + addressee.insertPhoneNumber( phone1 ); + addressee.insertPhoneNumber( phone2 ); + + TDEABC::Key key( "secret key", TDEABC::Key::X509 ); + addressee.insertKey( key ); + + TQStringList categories; + categories << "Friends" << "School" << "KDE"; + addressee.setCategories( categories ); + + TDEABC::Address a( TDEABC::Address::Work | TDEABC::Address::Postal | TDEABC::Address::Parcel ); + a.setStreet( "6544 Battleford Drive" ); + a.setLocality( "Raleigh" ); + a.setRegion( "NC" ); + a.setPostalCode( "27613-3502" ); + a.setCountry( "U.S.A." ); + addressee.insertAddress( a ); + + addressee.insertCustom( "1hsdf", "ertuer", "iurt" ); + addressee.insertCustom( "2hsdf", "ertuer", "iurt" ); + addressee.insertCustom( "3hsdf", "ertuer", "iurt" ); + + TDEABC::Addressee::List list; + for ( int i = 0; i < 1000; ++i ) { + TDEABC::Addressee addr = addressee; + addr.setUid( TQString::number( i ) ); + list.append( addr ); + } + + TDEABC::VCardConverter converter; + TQString txt = converter.createVCards( list ); + + TQFile file( "out.vcf" ); + file.open( IO_WriteOnly ); + + TQTextStream s( &file ); + s.setEncoding( TQTextStream::UnicodeUTF8 ); + s << txt; + file.close(); + + return 0; +} diff --git a/tdeabc/vcardparser/vcard.cpp b/tdeabc/vcardparser/vcard.cpp new file mode 100644 index 000000000..f6841cbd9 --- /dev/null +++ b/tdeabc/vcardparser/vcard.cpp @@ -0,0 +1,109 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "vcard.h" + +using namespace TDEABC; + +VCard::VCard() +{ +} + +VCard::VCard( const VCard& vcard ) +{ + mLineMap = vcard.mLineMap; +} + +VCard::~VCard() +{ +} + +VCard& VCard::operator=( const VCard& vcard ) +{ + if ( &vcard == this ) + return *this; + + mLineMap = vcard.mLineMap; + + return *this; +} + +void VCard::clear() +{ + mLineMap.clear(); +} + +TQStringList VCard::identifiers() const +{ + return mLineMap.keys(); +} + +void VCard::addLine( const VCardLine& line ) +{ + mLineMap[ line.identifier() ].append( line ); +} + +VCardLine::List VCard::lines( const TQString& identifier ) const +{ + LineMap::ConstIterator it = mLineMap.find( identifier ); + if ( it == mLineMap.end() ) + return VCardLine::List(); + + return *it; +} + +VCardLine VCard::line( const TQString& identifier ) const +{ + LineMap::ConstIterator it = mLineMap.find( identifier ); + if ( it == mLineMap.end() ) + return VCardLine(); + + if ( (*it).isEmpty() ) + return VCardLine(); + else + return (*it).first(); +} + +void VCard::setVersion( Version version ) +{ + mLineMap.erase( "VERSION" ); + + VCardLine line; + line.setIdentifier( "VERSION" ); + if ( version == v2_1 ) + line.setIdentifier( "2.1" ); + else if ( version == v3_0 ) + line.setIdentifier( "3.0" ); + + mLineMap[ "VERSION" ].append( line ); +} + +VCard::Version VCard::version() const +{ + LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" ); + if ( versionEntry == mLineMap.end() ) + return v3_0; + + VCardLine line = ( *versionEntry )[ 0 ]; + if ( line.value() == "2.1" ) + return v2_1; + else + return v3_0; +} diff --git a/tdeabc/vcardparser/vcard.h b/tdeabc/vcardparser/vcard.h new file mode 100644 index 000000000..ad50b8657 --- /dev/null +++ b/tdeabc/vcardparser/vcard.h @@ -0,0 +1,91 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef VCARDPARSER_VCARD_H +#define VCARDPARSER_VCARD_H + +#include "vcardline.h" +#include <tqmap.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> + +namespace TDEABC { + +class VCard +{ + public: + typedef TQValueList<VCard> List; + typedef TQMap< TQString, VCardLine::List > LineMap; + + enum Version { v2_1, v3_0 }; + + VCard(); + VCard( const VCard& ); + + ~VCard(); + + VCard& operator=( const VCard& ); + + /** + * Removes all lines from the vCard. + */ + void clear(); + + /** + * Returns a list of all identifiers that exists in the + * vCard. + */ + TQStringList identifiers() const; + + /** + * Adds a VCardLine to the VCard + */ + void addLine( const VCardLine& line ); + + /** + * Returns all lines of the vcard with a special identifier. + */ + VCardLine::List lines( const TQString& identifier ) const; + + /** + * Returns only the first line of the vcard with a special identifier. + */ + VCardLine line( const TQString& identifier ) const; + + /** + * Set the version of the vCard. + */ + void setVersion( Version version ); + + /** + * Returns the version of this vCard. + */ + Version version() const; + + private: + LineMap mLineMap; + + class VCardPrivate; + VCardPrivate *d; +}; + +} + +#endif diff --git a/tdeabc/vcardparser/vcardline.cpp b/tdeabc/vcardparser/vcardline.cpp new file mode 100644 index 000000000..22d7f7e52 --- /dev/null +++ b/tdeabc/vcardparser/vcardline.cpp @@ -0,0 +1,151 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "vcardline.h" + +using namespace TDEABC; + +class VCardLine::VCardLinePrivate +{ + public: + TQString mGroup; +}; + +VCardLine::VCardLine() + : d( 0 ) +{ +} + +VCardLine::VCardLine( const TQString &identifier ) + : d( 0 ) +{ + mIdentifier = identifier; +} + +VCardLine::VCardLine( const TQString &identifier, const TQVariant &value ) + : d( 0 ) +{ + mIdentifier = identifier; + mValue = value; +} + +VCardLine::VCardLine( const VCardLine& line ) + : d( 0 ) +{ + mParamMap = line.mParamMap; + mValue = line.mValue; + mIdentifier = line.mIdentifier; +} + +VCardLine::~VCardLine() +{ + delete d; + d = 0; +} + +VCardLine& VCardLine::operator=( const VCardLine& line ) +{ + if ( &line == this ) + return *this; + + mParamMap = line.mParamMap; + mValue = line.mValue; + mIdentifier = line.mIdentifier; + + return *this; +} + +void VCardLine::setIdentifier( const TQString& identifier ) +{ + mIdentifier = identifier; +} + +TQString VCardLine::identifier() const +{ + return mIdentifier; +} + +void VCardLine::setValue( const TQVariant& value ) +{ + mValue = value; +} + +TQVariant VCardLine::value() const +{ + return mValue; +} + +void VCardLine::setGroup( const TQString& group ) +{ + if ( !d ) + d = new VCardLinePrivate(); + + d->mGroup = group; +} + +TQString VCardLine::group() const +{ + if ( d ) + return d->mGroup; + else + return TQString(); +} + +bool VCardLine::hasGroup() const +{ + if ( !d ) + return false; + else + return d->mGroup.isEmpty(); +} + +TQStringList VCardLine::parameterList() const +{ + return mParamMap.keys(); +} + +void VCardLine::addParameter( const TQString& param, const TQString& value ) +{ + TQStringList &list = mParamMap[ param ]; + if ( list.findIndex( value ) == -1 ) // not included yet + list.append( value ); +} + +TQStringList VCardLine::parameters( const TQString& param ) const +{ + ParamMap::ConstIterator it = mParamMap.find( param ); + if ( it == mParamMap.end() ) + return TQStringList(); + else + return *it; +} + +TQString VCardLine::parameter( const TQString& param ) const +{ + ParamMap::ConstIterator it = mParamMap.find( param ); + if ( it == mParamMap.end() ) + return TQString::null; + else { + if ( (*it).isEmpty() ) + return TQString::null; + else + return (*it).first(); + } +} diff --git a/tdeabc/vcardparser/vcardline.h b/tdeabc/vcardparser/vcardline.h new file mode 100644 index 000000000..78ce2a411 --- /dev/null +++ b/tdeabc/vcardparser/vcardline.h @@ -0,0 +1,115 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef VCARDLINE_H +#define VCARDLINE_H + +#include <tqstringlist.h> +#include <tqvaluelist.h> +#include <tqvariant.h> +#include <tqmap.h> +#include <tqstring.h> + +namespace TDEABC { + +class VCardLine +{ + public: + typedef TQValueList<VCardLine> List; + typedef TQMap<TQString, TQStringList> ParamMap; + + VCardLine(); + VCardLine( const TQString &identifier ); + VCardLine( const TQString &identifier, const TQVariant &value ); + VCardLine( const VCardLine& ); + + ~VCardLine(); + + VCardLine& operator=( const VCardLine& ); + + /** + * Sets the identifier of this line e.g. UID, FN, CLASS + */ + void setIdentifier( const TQString& identifier ); + + /** + * Returns the identifier of this line. + */ + TQString identifier() const; + + /** + * Sets the value of of this line. + */ + void setValue( const TQVariant& value ); + + /** + * Returns the value of this line. + */ + TQVariant value() const; + + /** + * Sets the group the line belongs to. + */ + void setGroup( const TQString& group ); + + /** + * Returns the group the line belongs to. + */ + TQString group() const; + + /** + * Returns whether the line belongs to a group. + */ + bool hasGroup() const; + + /** + * Returns all parameters. + */ + TQStringList parameterList() const; + + /** + * Add a new parameter to the line. + */ + void addParameter( const TQString& param, const TQString& value ); + + /** + * Returns the values of a special parameter. + * You can get a list of all parameters with paramList(). + */ + TQStringList parameters( const TQString& param ) const; + + /** + * Returns only the first value of a special parameter. + * You can get a list of all parameters with paramList(). + */ + TQString parameter( const TQString& param ) const; + + private: + ParamMap mParamMap; + TQString mIdentifier; + TQVariant mValue; + + class VCardLinePrivate; + VCardLinePrivate *d; +}; + +} + +#endif diff --git a/tdeabc/vcardparser/vcardparser.cpp b/tdeabc/vcardparser/vcardparser.cpp new file mode 100644 index 000000000..3cc38f5c8 --- /dev/null +++ b/tdeabc/vcardparser/vcardparser.cpp @@ -0,0 +1,297 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqregexp.h> +#include <tqtextcodec.h> + +#include <kmdcodec.h> + +#include "vcardparser.h" + +#define FOLD_WIDTH 75 + +using namespace TDEABC; + +static TQString backslash( "\\\\" ); +static TQString comma( "\\," ); +static TQString newline( "\\n" ); +static TQString cr( "\\r" ); + +static void addEscapes( TQString &str ) +{ + str.replace( '\\', backslash ); + str.replace( ',', comma ); + str.replace( '\r', cr ); + str.replace( '\n', newline ); +} + +static void removeEscapes( TQString &str ) +{ + str.replace( cr, "\\r" ); + str.replace( newline, "\n" ); + str.replace( comma, "," ); + str.replace( backslash, "\\" ); +} + +VCardParser::VCardParser() +{ +} + +VCardParser::~VCardParser() +{ +} + +VCard::List VCardParser::parseVCards( const TQString& text ) +{ + static TQRegExp sep( "[\x0d\x0a]" ); + + VCard currentVCard; + VCard::List vCardList; + TQString currentLine; + + const TQStringList lines = TQStringList::split( sep, text ); + TQStringList::ConstIterator it; + + bool inVCard = false; + TQStringList::ConstIterator linesEnd( lines.end() ); + for ( it = lines.begin(); it != linesEnd; ++it ) { + + if ( (*it).isEmpty() ) // empty line + continue; + + if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous + currentLine += TQString( *it ).remove( 0, 1 ); + continue; + } else { + if ( inVCard && !currentLine.isEmpty() ) { // now parse the line + int colon = currentLine.find( ':' ); + if ( colon == -1 ) { // invalid line + currentLine = (*it); + continue; + } + + VCardLine vCardLine; + const TQString key = currentLine.left( colon ).stripWhiteSpace(); + TQString value = currentLine.mid( colon + 1 ); + + TQStringList params = TQStringList::split( ';', key ); + + // check for group + if ( params[0].find( '.' ) != -1 ) { + const TQStringList groupList = TQStringList::split( '.', params[0] ); + vCardLine.setGroup( groupList[0] ); + vCardLine.setIdentifier( groupList[1] ); + } else + vCardLine.setIdentifier( params[0] ); + + if ( params.count() > 1 ) { // find all parameters + TQStringList::ConstIterator paramIt = params.begin(); + for ( ++paramIt; paramIt != params.end(); ++paramIt ) { + TQStringList pair = TQStringList::split( '=', *paramIt ); + if ( pair.size() == 1 ) { + // correct the 2.1 'standard' + if ( pair[0].lower() == "quoted-printable" ) { + pair[0] = "encoding"; + pair[1] = "quoted-printable"; + } else if ( pair[0].lower() == "base64" ) { + pair[0] = "encoding"; + pair[1] = "base64"; + } else { + pair.prepend( "type" ); + } + } + // This is pretty much a faster pair[1].contains( ',' )... + if ( pair[1].find( ',' ) != -1 ) { // parameter in type=x,y,z format + const TQStringList args = TQStringList::split( ',', pair[ 1 ] ); + TQStringList::ConstIterator argIt; + for ( argIt = args.begin(); argIt != args.end(); ++argIt ) + vCardLine.addParameter( pair[0].lower(), *argIt ); + } else + vCardLine.addParameter( pair[0].lower(), pair[1] ); + } + } + + removeEscapes( value ); + + TQByteArray output; + bool wasBase64Encoded = false; + + params = vCardLine.parameterList(); + if ( params.findIndex( "encoding" ) != -1 ) { // have to decode the data + TQByteArray input; + input = TQCString(value.latin1()); + if ( vCardLine.parameter( "encoding" ).lower() == "b" || + vCardLine.parameter( "encoding" ).lower() == "base64" ) { + KCodecs::base64Decode( input, output ); + wasBase64Encoded = true; + } + else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) { + // join any qp-folded lines + while ( value.at( value.length() - 1 ) == '=' && it != linesEnd ) { + value = value.remove( value.length() - 1, 1 ) + (*it); + ++it; + } + input = TQCString(value.latin1()); + KCodecs::quotedPrintableDecode( input, output ); + } + } else { + output = TQCString(value.latin1()); + } + + if ( params.findIndex( "charset" ) != -1 ) { // have to convert the data + TQTextCodec *codec = + TQTextCodec::codecForName( vCardLine.parameter( "charset" ).latin1() ); + if ( codec ) { + vCardLine.setValue( codec->toUnicode( output ) ); + } else { + vCardLine.setValue( TQString(TQString::fromUtf8( output )) ); + } + } else if ( wasBase64Encoded ) { + vCardLine.setValue( output ); + } else { // if charset not given, assume it's in UTF-8 (as used in previous KDE versions) + vCardLine.setValue( TQString(TQString::fromUtf8( output )) ); + } + + currentVCard.addLine( vCardLine ); + } + + // we do not save the start and end tag as vcardline + if ( (*it).lower().startsWith( "begin:vcard" ) ) { + inVCard = true; + currentLine.setLength( 0 ); + currentVCard.clear(); // flush vcard + continue; + } + + if ( (*it).lower().startsWith( "end:vcard" ) ) { + inVCard = false; + vCardList.append( currentVCard ); + currentLine.setLength( 0 ); + currentVCard.clear(); // flush vcard + continue; + } + + currentLine = (*it); + } + } + + return vCardList; +} + +TQString VCardParser::createVCards( const VCard::List& list ) +{ + TQString text; + TQString textLine; + TQString encodingType; + TQStringList idents; + TQStringList params; + TQStringList values; + TQStringList::ConstIterator identIt; + TQStringList::Iterator paramIt; + TQStringList::ConstIterator valueIt; + + VCardLine::List lines; + VCardLine::List::ConstIterator lineIt; + VCard::List::ConstIterator cardIt; + + bool hasEncoding; + + text.reserve( list.size() * 300 ); // reserve memory to be more efficient + + // iterate over the cards + VCard::List::ConstIterator listEnd( list.end() ); + for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) { + text.append( "BEGIN:VCARD\r\n" ); + + idents = (*cardIt).identifiers(); + for ( identIt = idents.constBegin(); identIt != idents.constEnd(); ++identIt ) { + lines = (*cardIt).lines( (*identIt) ); + + // iterate over the lines + for ( lineIt = lines.constBegin(); lineIt != lines.constEnd(); ++lineIt ) { + if ( !(*lineIt).value().asString().isEmpty() ) { + if ((*lineIt).identifier() != TQString("URI")) { + if ( (*lineIt).hasGroup() ) + textLine = (*lineIt).group() + "." + (*lineIt).identifier(); + else + textLine = (*lineIt).identifier(); + + params = (*lineIt).parameterList(); + hasEncoding = false; + if ( params.count() > 0 ) { // we have parameters + for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) { + if ( (*paramIt) == "encoding" ) { + hasEncoding = true; + encodingType = (*lineIt).parameter( "encoding" ).lower(); + } + + values = (*lineIt).parameters( *paramIt ); + for ( valueIt = values.constBegin(); valueIt != values.constEnd(); ++valueIt ) { + textLine.append( ";" + (*paramIt).upper() ); + if ( !(*valueIt).isEmpty() ) + textLine.append( "=" + (*valueIt) ); + } + } + } + + if ( hasEncoding ) { // have to encode the data + TQByteArray input, output; + if ( encodingType == "b" ) { + input = (*lineIt).value().toByteArray(); + KCodecs::base64Encode( input, output ); + } else if ( encodingType == "quoted-printable" ) { + input = (*lineIt).value().toString().utf8(); + input.resize( input.size() - 1 ); // strip \0 + KCodecs::quotedPrintableEncode( input, output, false ); + } + + TQString value( output ); + addEscapes( value ); + textLine.append( ":" + value ); + } else { + TQString value( (*lineIt).value().asString() ); + addEscapes( value ); + textLine.append( ":" + value ); + } + + if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line + for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i ) + text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" ); + } else + text.append( textLine + "\r\n" ); + } + else { + // URIs can be full of weird symbols, etc. so bypass all checks + textLine = (*lineIt).identifier(); + TQString value( (*lineIt).value().asString() ); + addEscapes( value ); + textLine.append( ":" + value ); + text.append( textLine + "\r\n" ); + } + } + } + } + + text.append( "END:VCARD\r\n" ); + text.append( "\r\n" ); + } + + return text; +} diff --git a/tdeabc/vcardparser/vcardparser.h b/tdeabc/vcardparser/vcardparser.h new file mode 100644 index 000000000..fc17d116b --- /dev/null +++ b/tdeabc/vcardparser/vcardparser.h @@ -0,0 +1,44 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef VCARDPARSER_H +#define VCARDPARSER_H + +#include "vcard.h" + +namespace TDEABC { + +class VCardParser +{ + public: + VCardParser(); + ~VCardParser(); + + static VCard::List parseVCards( const TQString& text ); + static TQString createVCards( const VCard::List& list ); + + private: + class VCardParserPrivate; + VCardParserPrivate *d; +}; + +} + +#endif diff --git a/tdeabc/vcardtool.cpp b/tdeabc/vcardtool.cpp new file mode 100644 index 000000000..2dd9752ac --- /dev/null +++ b/tdeabc/vcardtool.cpp @@ -0,0 +1,896 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <tqbuffer.h> +#include <tqdatastream.h> +#include <tqstring.h> + +#include "agent.h" +#include "key.h" +#include "picture.h" +#include "secrecy.h" +#include "sound.h" + +#include "vcardtool.h" + +using namespace TDEABC; + +static bool needsEncoding( const TQString &value ) +{ + uint length = value.length(); + for ( uint i = 0; i < length; ++i ) { + char c = value.at( i ).latin1(); + if ( (c < 33 || c > 126) && c != ' ' && c != '=' ) + return true; + } + + return false; +} + +VCardTool::VCardTool() +{ + mAddressTypeMap.insert( "dom", Address::Dom ); + mAddressTypeMap.insert( "intl", Address::Intl ); + mAddressTypeMap.insert( "postal", Address::Postal ); + mAddressTypeMap.insert( "parcel", Address::Parcel ); + mAddressTypeMap.insert( "home", Address::Home ); + mAddressTypeMap.insert( "work", Address::Work ); + mAddressTypeMap.insert( "pref", Address::Pref ); + + mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); + mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); + mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); + mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); + mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); + mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); + mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); + mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); + mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); + mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); + mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); + mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); + mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); + mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); +} + +VCardTool::~VCardTool() +{ +} + +// TODO: make list a const& +TQString VCardTool::createVCards( Addressee::List list, VCard::Version version ) +{ + VCard::List vCardList; + + Addressee::List::ConstIterator addrIt; + Addressee::List::ConstIterator listEnd( list.constEnd() ); + for ( addrIt = list.constBegin(); addrIt != listEnd; ++addrIt ) { + VCard card; + TQStringList::ConstIterator strIt; + + // ADR + LABEL + const Address::List addresses = (*addrIt).addresses(); + for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) { + TQStringList address; + + bool isEmpty = ( (*it).postOfficeBox().isEmpty() && + (*it).extended().isEmpty() && + (*it).street().isEmpty() && + (*it).locality().isEmpty() && + (*it).region().isEmpty() && + (*it).postalCode().isEmpty() && + (*it).country().isEmpty() ); + + address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); + address.append( (*it).extended().replace( ';', "\\;" ) ); + address.append( (*it).street().replace( ';', "\\;" ) ); + address.append( (*it).locality().replace( ';', "\\;" ) ); + address.append( (*it).region().replace( ';', "\\;" ) ); + address.append( (*it).postalCode().replace( ';', "\\;" ) ); + address.append( (*it).country().replace( ';', "\\;" ) ); + + VCardLine adrLine( "ADR", address.join( ";" ) ); + if ( version == VCard::v2_1 && needsEncoding( address.join( ";" ) ) ) { + adrLine.addParameter( "charset", "UTF-8" ); + adrLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + + VCardLine labelLine( "LABEL", (*it).label() ); + if ( version == VCard::v2_1 && needsEncoding( (*it).label() ) ) { + labelLine.addParameter( "charset", "UTF-8" ); + labelLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + + bool hasLabel = !(*it).label().isEmpty(); + TQMap<TQString, int>::ConstIterator typeIt; + for ( typeIt = mAddressTypeMap.constBegin(); typeIt != mAddressTypeMap.constEnd(); ++typeIt ) { + if ( typeIt.data() & (*it).type() ) { + adrLine.addParameter( "TYPE", typeIt.key() ); + if ( hasLabel ) + labelLine.addParameter( "TYPE", typeIt.key() ); + } + } + + if ( !isEmpty ) + card.addLine( adrLine ); + if ( hasLabel ) + card.addLine( labelLine ); + } + + // AGENT + card.addLine( createAgent( version, (*addrIt).agent() ) ); + + // BDAY + card.addLine( VCardLine( "BDAY", createDateTime( TQT_TQDATETIME_OBJECT((*addrIt).birthday()) ) ) ); + + // CATEGORIES + if ( version == VCard::v3_0 ) { + TQStringList categories = (*addrIt).categories(); + TQStringList::Iterator catIt; + for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) + (*catIt).replace( ',', "\\," ); + + VCardLine catLine( "CATEGORIES", categories.join( "," ) ); + if ( version == VCard::v2_1 && needsEncoding( categories.join( "," ) ) ) { + catLine.addParameter( "charset", "UTF-8" ); + catLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + + card.addLine( catLine ); + } + + // CLASS + if ( version == VCard::v3_0 ) { + card.addLine( createSecrecy( (*addrIt).secrecy() ) ); + } + + // EMAIL + const TQStringList emails = (*addrIt).emails(); + bool pref = true; + for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { + VCardLine line( "EMAIL", *strIt ); + if ( pref == true && emails.count() > 1 ) { + line.addParameter( "TYPE", "PREF" ); + pref = false; + } + card.addLine( line ); + } + + // FN + VCardLine fnLine( "FN", TQString((*addrIt).formattedName()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).formattedName() ) ) { + fnLine.addParameter( "charset", "UTF-8" ); + fnLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( fnLine ); + + // GEO + Geo geo = (*addrIt).geo(); + if ( geo.isValid() ) { + TQString str; + str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); + card.addLine( VCardLine( "GEO", str ) ); + } + + // KEY + const Key::List keys = (*addrIt).keys(); + Key::List::ConstIterator keyIt; + for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) + card.addLine( createKey( *keyIt ) ); + + // LOGO + card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); + + // MAILER + VCardLine mailerLine( "MAILER", TQString((*addrIt).mailer()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).mailer() ) ) { + mailerLine.addParameter( "charset", "UTF-8" ); + mailerLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( mailerLine ); + + // N + TQStringList name; + name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); + name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); + name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); + name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); + name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); + + VCardLine nLine( "N", name.join( ";" ) ); + if ( version == VCard::v2_1 && needsEncoding( name.join( ";" ) ) ) { + nLine.addParameter( "charset", "UTF-8" ); + nLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( nLine ); + + // NAME + VCardLine nameLine( "NAME", TQString((*addrIt).name()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).name() ) ) { + nameLine.addParameter( "charset", "UTF-8" ); + nameLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( nameLine ); + + // NICKNAME + if ( version == VCard::v3_0 ) + card.addLine( VCardLine( "NICKNAME", TQString((*addrIt).nickName()) ) ); + + // NOTE + VCardLine noteLine( "NOTE", TQString((*addrIt).note()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).note() ) ) { + noteLine.addParameter( "charset", "UTF-8" ); + noteLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( noteLine ); + + // ORG + TQStringList organization; + organization.append( ( *addrIt ).organization().replace( ';', "\\;" ) ); + if ( !( *addrIt ).department().isEmpty() ) + organization.append( ( *addrIt ).department().replace( ';', "\\;" ) ); + VCardLine orgLine( "ORG", organization.join( ";" ) ); + if ( version == VCard::v2_1 && needsEncoding( organization.join( ";" ) ) ) { + orgLine.addParameter( "charset", "UTF-8" ); + orgLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( orgLine ); + + // PHOTO + card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); + + // PROID + if ( version == VCard::v3_0 ) + card.addLine( VCardLine( "PRODID", TQString((*addrIt).productId()) ) ); + + // REV + card.addLine( VCardLine( "REV", createDateTime( TQT_TQDATETIME_OBJECT((*addrIt).revision()) ) ) ); + + // ROLE + VCardLine roleLine( "ROLE", TQString((*addrIt).role()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).role() ) ) { + roleLine.addParameter( "charset", "UTF-8" ); + roleLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( roleLine ); + + // SORT-STRING + if ( version == VCard::v3_0 ) + card.addLine( VCardLine( "SORT-STRING", TQString((*addrIt).sortString()) ) ); + + // SOUND + card.addLine( createSound( (*addrIt).sound() ) ); + + // TEL + const PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); + PhoneNumber::List::ConstIterator phoneIt; + for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { + VCardLine line( "TEL", (*phoneIt).number() ); + + TQMap<TQString, int>::ConstIterator typeIt; + for ( typeIt = mPhoneTypeMap.constBegin(); typeIt != mPhoneTypeMap.constEnd(); ++typeIt ) { + if ( typeIt.data() & (*phoneIt).type() ) + line.addParameter( "TYPE", typeIt.key() ); + } + + card.addLine( line ); + } + + // TITLE + VCardLine titleLine( "TITLE", TQString((*addrIt).title()) ); + if ( version == VCard::v2_1 && needsEncoding( (*addrIt).title() ) ) { + titleLine.addParameter( "charset", "UTF-8" ); + titleLine.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( titleLine ); + + // TZ + TimeZone timeZone = (*addrIt).timeZone(); + if ( timeZone.isValid() ) { + TQString str; + + int neg = 1; + if ( timeZone.offset() < 0 ) + neg = -1; + + str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), + ( timeZone.offset() / 60 ) * neg, + ( timeZone.offset() % 60 ) * neg ); + + card.addLine( VCardLine( "TZ", str ) ); + } + + // UID + card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); + + // UID + card.addLine( VCardLine( "URI", (*addrIt).uri() ) ); + + // URL + card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); + + // VERSION + if ( version == VCard::v2_1 ) + card.addLine( VCardLine( "VERSION", "2.1" ) ); + if ( version == VCard::v3_0 ) + card.addLine( VCardLine( "VERSION", "3.0" ) ); + + // X- + const TQStringList customs = (*addrIt).customs(); + for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { + TQString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); + TQString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); + if ( value.isEmpty() ) + continue; + + VCardLine line( identifier, value ); + if ( version == VCard::v2_1 && needsEncoding( value ) ) { + line.addParameter( "charset", "UTF-8" ); + line.addParameter( "encoding", "QUOTED-PRINTABLE" ); + } + card.addLine( line ); + } + + vCardList.append( card ); + } + + return VCardParser::createVCards( vCardList ); +} + +Addressee::List VCardTool::parseVCards( const TQString& vcard ) +{ + static const TQChar semicolonSep( ';' ); + static const TQChar commaSep( ',' ); + TQString identifier; + + Addressee::List addrList; + const VCard::List vCardList = VCardParser::parseVCards( vcard ); + + VCard::List::ConstIterator cardIt; + VCard::List::ConstIterator listEnd( vCardList.end() ); + for ( cardIt = vCardList.begin(); cardIt != listEnd; ++cardIt ) { + Addressee addr; + + const TQStringList idents = (*cardIt).identifiers(); + TQStringList::ConstIterator identIt; + TQStringList::ConstIterator identEnd( idents.end() ); + for ( identIt = idents.begin(); identIt != identEnd; ++identIt ) { + const VCardLine::List lines = (*cardIt).lines( (*identIt) ); + VCardLine::List::ConstIterator lineIt; + + // iterate over the lines + for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { + identifier = (*lineIt).identifier().lower(); + // ADR + if ( identifier == "adr" ) { + Address address; + const TQStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); + if ( addrParts.count() > 0 ) + address.setPostOfficeBox( addrParts[ 0 ] ); + if ( addrParts.count() > 1 ) + address.setExtended( addrParts[ 1 ] ); + if ( addrParts.count() > 2 ) + address.setStreet( addrParts[ 2 ] ); + if ( addrParts.count() > 3 ) + address.setLocality( addrParts[ 3 ] ); + if ( addrParts.count() > 4 ) + address.setRegion( addrParts[ 4 ] ); + if ( addrParts.count() > 5 ) + address.setPostalCode( addrParts[ 5 ] ); + if ( addrParts.count() > 6 ) + address.setCountry( addrParts[ 6 ] ); + + int type = 0; + + const TQStringList types = (*lineIt).parameters( "type" ); + for ( TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) + type += mAddressTypeMap[ (*it).lower() ]; + + address.setType( type ); + addr.insertAddress( address ); + } + + // AGENT + else if ( identifier == "agent" ) + addr.setAgent( parseAgent( *lineIt ) ); + + // BDAY + else if ( identifier == "bday" ) + addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); + + // CATEGORIES + else if ( identifier == "categories" ) { + const TQStringList categories = splitString( commaSep, (*lineIt).value().asString() ); + addr.setCategories( categories ); + } + + // CLASS + else if ( identifier == "class" ) + addr.setSecrecy( parseSecrecy( *lineIt ) ); + + // EMAIL + else if ( identifier == "email" ) { + const TQStringList types = (*lineIt).parameters( "type" ); + addr.insertEmail( (*lineIt).value().asString(), types.findIndex( "PREF" ) != -1 ); + } + + // FN + else if ( identifier == "fn" ) + addr.setFormattedName( (*lineIt).value().asString() ); + + // GEO + else if ( identifier == "geo" ) { + Geo geo; + + const TQStringList geoParts = TQStringList::split( ';', (*lineIt).value().asString(), true ); + geo.setLatitude( geoParts[ 0 ].toFloat() ); + geo.setLongitude( geoParts[ 1 ].toFloat() ); + + addr.setGeo( geo ); + } + + // KEY + else if ( identifier == "key" ) + addr.insertKey( parseKey( *lineIt ) ); + + // LABEL + else if ( identifier == "label" ) { + int type = 0; + + const TQStringList types = (*lineIt).parameters( "type" ); + for ( TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) + type += mAddressTypeMap[ (*it).lower() ]; + + bool available = false; + TDEABC::Address::List addressList = addr.addresses(); + TDEABC::Address::List::Iterator it; + for ( it = addressList.begin(); it != addressList.end(); ++it ) { + if ( (*it).type() == type ) { + (*it).setLabel( (*lineIt).value().asString() ); + addr.insertAddress( *it ); + available = true; + break; + } + } + + if ( !available ) { // a standalone LABEL tag + TDEABC::Address address( type ); + address.setLabel( (*lineIt).value().asString() ); + addr.insertAddress( address ); + } + } + + // LOGO + else if ( identifier == "logo" ) + addr.setLogo( parsePicture( *lineIt ) ); + + // MAILER + else if ( identifier == "mailer" ) + addr.setMailer( (*lineIt).value().asString() ); + + // N + else if ( identifier == "n" ) { + const TQStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); + if ( nameParts.count() > 0 ) + addr.setFamilyName( nameParts[ 0 ] ); + if ( nameParts.count() > 1 ) + addr.setGivenName( nameParts[ 1 ] ); + if ( nameParts.count() > 2 ) + addr.setAdditionalName( nameParts[ 2 ] ); + if ( nameParts.count() > 3 ) + addr.setPrefix( nameParts[ 3 ] ); + if ( nameParts.count() > 4 ) + addr.setSuffix( nameParts[ 4 ] ); + } + + // NAME + else if ( identifier == "name" ) + addr.setName( (*lineIt).value().asString() ); + + // NICKNAME + else if ( identifier == "nickname" ) + addr.setNickName( (*lineIt).value().asString() ); + + // NOTE + else if ( identifier == "note" ) + addr.setNote( (*lineIt).value().asString() ); + + // ORGANIZATION + else if ( identifier == "org" ) { + const TQStringList orgParts = splitString( semicolonSep, (*lineIt).value().asString() ); + if ( orgParts.count() > 0 ) + addr.setOrganization( orgParts[ 0 ] ); + if ( orgParts.count() > 1 ) + addr.setDepartment( orgParts[ 1 ] ); + } + + // PHOTO + else if ( identifier == "photo" ) + addr.setPhoto( parsePicture( *lineIt ) ); + + // PROID + else if ( identifier == "prodid" ) + addr.setProductId( (*lineIt).value().asString() ); + + // REV + else if ( identifier == "rev" ) + addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); + + // ROLE + else if ( identifier == "role" ) + addr.setRole( (*lineIt).value().asString() ); + + // SORT-STRING + else if ( identifier == "sort-string" ) + addr.setSortString( (*lineIt).value().asString() ); + + // SOUND + else if ( identifier == "sound" ) + addr.setSound( parseSound( *lineIt ) ); + + // TEL + else if ( identifier == "tel" ) { + PhoneNumber phone; + phone.setNumber( (*lineIt).value().asString() ); + + int type = 0; + + const TQStringList types = (*lineIt).parameters( "type" ); + for ( TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) + type += mPhoneTypeMap[(*it).upper()]; + + phone.setType( type ); + + addr.insertPhoneNumber( phone ); + } + + // TITLE + else if ( identifier == "title" ) + addr.setTitle( (*lineIt).value().asString() ); + + // TZ + else if ( identifier == "tz" ) { + TimeZone tz; + const TQString date = (*lineIt).value().asString(); + + int hours = date.mid( 1, 2).toInt(); + int minutes = date.mid( 4, 2 ).toInt(); + int offset = ( hours * 60 ) + minutes; + offset = offset * ( date[ 0 ] == '+' ? 1 : -1 ); + + tz.setOffset( offset ); + addr.setTimeZone( tz ); + } + + // UID + else if ( identifier == "uid" ) + addr.setUid( (*lineIt).value().asString() ); + + // URI + else if ( identifier == "uri" ) + addr.setUri( (*lineIt).value().asString() ); + + // URL + else if ( identifier == "url" ) + addr.setUrl( KURL( (*lineIt).value().asString() ) ); + + // X- + else if ( identifier.startsWith( "x-" ) ) { + const TQString key = (*lineIt).identifier().mid( 2 ); + int dash = key.find( "-" ); + addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() ); + } + } + } + + addrList.append( addr ); + } + + return addrList; +} + +TQDateTime VCardTool::parseDateTime( const TQString &str ) +{ + TQDateTime dateTime; + + if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd) + dateTime.setDate( TQDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(), + str.mid( 6, 2 ).toInt() ) ); + + if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss + dateTime.setTime( TQTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), + str.mid( 17, 2 ).toInt() ) ); + + } else { // is extended format yyyy-mm-dd + dateTime.setDate( TQDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(), + str.mid( 8, 2 ).toInt() ) ); + + if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss + dateTime.setTime( TQTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), + str.mid( 17, 2 ).toInt() ) ); + } + + return dateTime; +} + +TQString VCardTool::createDateTime( const TQDateTime &dateTime ) +{ + TQString str; + + if ( dateTime.date().isValid() ) { + str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(), + dateTime.date().day() ); + if ( dateTime.time().isValid() ) { + TQString tmp; + tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(), + dateTime.time().second() ); + str += tmp; + } + } + + return str; +} + +Picture VCardTool::parsePicture( const VCardLine &line ) +{ + Picture pic; + + const TQStringList params = line.parameterList(); + if ( params.findIndex( "encoding" ) != -1 ) { + TQImage img; + img.loadFromData( line.value().asByteArray() ); + pic.setData( img ); + } else if ( params.findIndex( "value" ) != -1 ) { + if ( line.parameter( "value" ).lower() == "uri" ) + pic.setUrl( line.value().asString() ); + } + + if ( params.findIndex( "type" ) != -1 ) + pic.setType( line.parameter( "type" ) ); + + return pic; +} + +VCardLine VCardTool::createPicture( const TQString &identifier, const Picture &pic ) +{ + VCardLine line( identifier ); + + if ( pic.isIntern() ) { + if ( !pic.data().isNull() ) { + TQByteArray input; + TQBuffer buffer( input ); + buffer.open( IO_WriteOnly ); + + TQImageIO iio( &buffer, "JPEG" ); + iio.setImage( pic.data() ); + iio.setQuality( 100 ); + iio.write(); + + line.setValue( input ); + line.addParameter( "encoding", "b" ); + line.addParameter( "type", "image/jpeg" ); + } + } else if ( !pic.url().isEmpty() ) { + line.setValue( pic.url() ); + line.addParameter( "value", "URI" ); + } + + return line; +} + +Sound VCardTool::parseSound( const VCardLine &line ) +{ + Sound snd; + + const TQStringList params = line.parameterList(); + if ( params.findIndex( "encoding" ) != -1 ) + snd.setData( line.value().asByteArray() ); + else if ( params.findIndex( "value" ) != -1 ) { + if ( line.parameter( "value" ).lower() == "uri" ) + snd.setUrl( line.value().asString() ); + } + +/* TODO: support sound types + if ( params.contains( "type" ) ) + snd.setType( line.parameter( "type" ) ); +*/ + + return snd; +} + +VCardLine VCardTool::createSound( const Sound &snd ) +{ + VCardLine line( "SOUND" ); + + if ( snd.isIntern() ) { + if ( !snd.data().isEmpty() ) { + line.setValue( snd.data() ); + line.addParameter( "encoding", "b" ); + // TODO: need to store sound type!!! + } + } else if ( !snd.url().isEmpty() ) { + line.setValue( snd.url() ); + line.addParameter( "value", "URI" ); + } + + return line; +} + +Key VCardTool::parseKey( const VCardLine &line ) +{ + Key key; + + const TQStringList params = line.parameterList(); + if ( params.findIndex( "encoding" ) != -1 ) + key.setBinaryData( line.value().asByteArray() ); + else + key.setTextData( line.value().asString() ); + + if ( params.findIndex( "type" ) != -1 ) { + if ( line.parameter( "type" ).lower() == "x509" ) + key.setType( Key::X509 ); + else if ( line.parameter( "type" ).lower() == "pgp" ) + key.setType( Key::PGP ); + else { + key.setType( Key::Custom ); + key.setCustomTypeString( line.parameter( "type" ) ); + } + } + + return key; +} + +VCardLine VCardTool::createKey( const Key &key ) +{ + VCardLine line( "KEY" ); + + if ( key.isBinary() ) { + if ( !key.binaryData().isEmpty() ) { + line.setValue( key.binaryData() ); + line.addParameter( "encoding", "b" ); + } + } else if ( !key.textData().isEmpty() ) + line.setValue( key.textData() ); + + if ( key.type() == Key::X509 ) + line.addParameter( "type", "X509" ); + else if ( key.type() == Key::PGP ) + line.addParameter( "type", "PGP" ); + else if ( key.type() == Key::Custom ) + line.addParameter( "type", key.customTypeString() ); + + return line; +} + +Secrecy VCardTool::parseSecrecy( const VCardLine &line ) +{ + Secrecy secrecy; + + if ( line.value().asString().lower() == "public" ) + secrecy.setType( Secrecy::Public ); + if ( line.value().asString().lower() == "private" ) + secrecy.setType( Secrecy::Private ); + if ( line.value().asString().lower() == "confidential" ) + secrecy.setType( Secrecy::Confidential ); + + return secrecy; +} + +VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) +{ + VCardLine line( "CLASS" ); + + int type = secrecy.type(); + + if ( type == Secrecy::Public ) + line.setValue( "PUBLIC" ); + else if ( type == Secrecy::Private ) + line.setValue( "PRIVATE" ); + else if ( type == Secrecy::Confidential ) + line.setValue( "CONFIDENTIAL" ); + + return line; +} + +Agent VCardTool::parseAgent( const VCardLine &line ) +{ + Agent agent; + + const TQStringList params = line.parameterList(); + if ( params.findIndex( "value" ) != -1 ) { + if ( line.parameter( "value" ).lower() == "uri" ) + agent.setUrl( line.value().asString() ); + } else { + TQString str = line.value().asString(); + str.replace( "\\n", "\r\n" ); + str.replace( "\\N", "\r\n" ); + str.replace( "\\;", ";" ); + str.replace( "\\:", ":" ); + str.replace( "\\,", "," ); + + const Addressee::List list = parseVCards( str ); + if ( list.count() > 0 ) { + Addressee *addr = new Addressee; + *addr = list[ 0 ]; + agent.setAddressee( addr ); + } + } + + return agent; +} + +VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) +{ + VCardLine line( "AGENT" ); + + if ( agent.isIntern() ) { + if ( agent.addressee() != 0 ) { + Addressee::List list; + list.append( *agent.addressee() ); + + TQString str = createVCards( list, version ); + str.replace( "\r\n", "\\n" ); + str.replace( ";", "\\;" ); + str.replace( ":", "\\:" ); + str.replace( ",", "\\," ); + line.setValue( str ); + } + } else if ( !agent.url().isEmpty() ) { + line.setValue( agent.url() ); + line.addParameter( "value", "URI" ); + } + + return line; +} + +TQStringList VCardTool::splitString( const TQChar &sep, const TQString &str ) +{ + TQStringList list; + TQString value( str ); + + int start = 0; + int pos = value.find( sep, start ); + + while ( pos != -1 ) { + if ( value[ pos - 1 ] != '\\' ) { + if ( pos > start && pos <= (int)value.length() ) + list << value.mid( start, pos - start ); + else + list << TQString::null; + + start = pos + 1; + pos = value.find( sep, start ); + } else { + if ( pos != 0 ) { + value.replace( pos - 1, 2, sep ); + pos = value.find( sep, pos ); + } else + pos = value.find( sep, pos + 1 ); + } + } + + int l = value.length() - 1; + if ( value.mid( start, l - start + 1 ).length() > 0 ) + list << value.mid( start, l - start + 1 ); + else + list << TQString::null; + + return list; +} diff --git a/tdeabc/vcardtool.h b/tdeabc/vcardtool.h new file mode 100644 index 000000000..0d67605d6 --- /dev/null +++ b/tdeabc/vcardtool.h @@ -0,0 +1,88 @@ +/* + This file is part of libkabc. + Copyright (c) 2003 Tobias Koenig <[email protected]> + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_VCARDTOOL_H +#define KABC_VCARDTOOL_H + +#include "addressee.h" +#include "vcardparser.h" + +class TQDateTime; + +namespace TDEABC { + +class Agent; +class Key; +class Picture; +class Secrecy; +class Sound; + +class KABC_EXPORT VCardTool +{ + public: + VCardTool(); + ~VCardTool(); + + /** + Creates a string that contains the addressees from the list in + the vCard format. + */ + TQString createVCards( Addressee::List list, VCard::Version version = VCard::v3_0 ); + + /** + Parses the string and returns a list of addressee objects. + */ + Addressee::List parseVCards( const TQString& vcard ); + + private: + /** + Split a string and replaces escaped separators on the fly with + unescaped ones. + */ + TQStringList splitString( const TQChar &sep, const TQString &value ); + + TQDateTime parseDateTime( const TQString &str ); + TQString createDateTime( const TQDateTime &dateTime ); + + Picture parsePicture( const VCardLine &line ); + VCardLine createPicture( const TQString &identifier, const Picture &pic ); + + Sound parseSound( const VCardLine &line ); + VCardLine createSound( const Sound &snd ); + + Key parseKey( const VCardLine &line ); + VCardLine createKey( const Key &key ); + + Secrecy parseSecrecy( const VCardLine &line ); + VCardLine createSecrecy( const Secrecy &secrecy ); + + Agent parseAgent( const VCardLine &line ); + VCardLine createAgent( VCard::Version version, const Agent &agent ); + + TQMap<TQString, int> mAddressTypeMap; + TQMap<TQString, int> mPhoneTypeMap; + + class VCardToolPrivate; + VCardToolPrivate *d; +}; + +} + +#endif |