-rw-r--r-- | kaddressbook/kabcore.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 46 | ||||
-rw-r--r-- | korganizer/koimportoldialog.cpp | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 |
4 files changed, 57 insertions, 8 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 980e436..1074a62 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -237,240 +237,244 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const // LP moved to addressbook init method mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, "X-Profession", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, "X-AssistantsName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, "X-ManagersName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, "X-SpousesName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, "X-Office", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, "X-IMAddress", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, "X-Anniversary", "KADDRESSBOOK" ); //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, "X-Gender", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, "X-Children", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, "X-FreeBusyUrl", "KADDRESSBOOK" ); #endif initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( const QString& ) ), SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mMessageTimer = new QTimer( this ); connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); mBRdisabled = 0; #ifndef DESKTOP_VERSION infrared = 0; #endif toggleBeamReceive( ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; +#ifndef DESKTOP_VERSION if ( infrared ) delete infrared; +#endif } void KABCore::receive( const QCString& cmsg, const QByteArray& data ) { qDebug("KA: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; recieve( fileName ); return; } } void KABCore::toggleBeamReceive( ) { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("AB disable BeamReceive "); delete infrared; infrared = 0; mActionBR->setChecked(false); return; } qDebug("AB enable BeamReceive "); mActionBR->setChecked(true); infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); #endif } void KABCore::disableBR(bool b) { +#ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive( ); - mBRdisabled = true; } + mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; - toggleBeamReceive( ); + //toggleBeamReceive( ); } } +#endif } void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); int count = mAddressBook->importFromFile( fn, true ); mViewManager->refreshView(); message(i18n("%1 contact(s) received!").arg( count )); topLevelWidget()->showMaximized(); topLevelWidget()->raise(); } void KABCore::restoreSettings() { mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; bool state; if (mMultipleViewsAtOnce) state = KABPrefs::instance()->mDetailsPageVisible; else state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); /*US QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } */ mViewManager->restoreSettings(); mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); #ifdef DESKTOP_VERSION int wid = width(); if ( wid < 10 ) wid = 400; #else int wid = QApplication::desktop()->width(); if ( wid < 640 ) wid = QApplication::desktop()->height(); #endif QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { //splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } } void KABCore::saveSettings() { KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); if ( mExtensionBarSplitter ) KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); #ifndef KAB_EMBEDDED KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); #endif //KAB_EMBEDDED mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); } KABC::AddressBook *KABCore::addressBook() const diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 10e3c76..848d8af 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp @@ -1,127 +1,128 @@ /* This file is part of KAddressbook/Pi. Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> This program 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 program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qframe.h> #include <qpixmap.h> #include <qlayout.h> #include <qprogressbar.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qdir.h> +#include <qregexp.h> #include <qapplication.h> #include <qhbox.h> #include <qheader.h> #include <qdatetime.h> #include <qlistview.h> #include <kdebug.h> #include <klocale.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kinputdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include <kabc/addresseelist.h> #include <kabc/phonenumber.h> #include "kaimportoldialog.h" #include "../outport/msoutl9.h" #include <ole2.h> #include <comutil.h> _Application gOlAppAB; QDateTime mDdate2Qdtr( DATE dt) { COleDateTime odt; SYSTEMTIME st; odt = dt; if ( odt.GetStatus() != 0 ) return QDateTime(); odt.GetAsSystemTime(st); if ( st.wYear > 4000 ) // this program as a year 4000 bug! return QDateTime(); // it seems so, that 1.1.4501 indicates: DATE invalid QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); return qdt; } class OLEListViewItem : public QCheckListItem { public: OLEListViewItem( QListView *parent, QString text ) : QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; OLEListViewItem( QListViewItem *after, QString text ) : QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; ~OLEListViewItem() {}; void setData( DWORD data ) {mData= data; }; DWORD data() { return mData ;}; private: DWORD mData; }; KAImportOLdialog::KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, QWidget *parent ) : KDialogBase( Plain, caption, User1 | Close, Ok, parent, caption, true, false, i18n("Import!") ) { QHBox * mw = new QHBox( this ); setMainWidget( mw ); mListView = new QListView( mw ); mListView->addColumn(i18n("Select Folder to import")); mListView->addColumn(i18n("Content Type")); mABook = aBook; connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); setupFolderView(); resize( sizeHint().width()+50, sizeHint().height()+50 ); } KAImportOLdialog::~KAImportOLdialog() { } KABC::Addressee::List KAImportOLdialog::getAddressList() { return mAList; } void KAImportOLdialog::setupFolderView() { SCODE sc = ::OleInitialize(NULL); if ( FAILED ( sc ) ) { KMessageBox::information(this,"OLE initialisation failed"); return; } if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ KMessageBox::information(this,"Sorry, cannot access Outlook"); return ; } MAPIFolder mfInbox; MAPIFolder mfRoot; @@ -174,522 +175,559 @@ void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent case 2: ts = i18n("Contacts"); break; case 3: ts = i18n("Todos"); break; case 4: ts = i18n("Journals"); break; case 5: ts = i18n("Notes"); break; default: ts = i18n("Unknown"); } hChild->setText( 1,ts); hChild->setData( (DWORD) mfChild.m_lpDispatch ); mfChild.m_lpDispatch->AddRef(); addFolder(hChild, mfChild.m_lpDispatch); } } void KAImportOLdialog::slotApply() { importedItems = 0; OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); while ( child ) { if ( child->isOn() ) readContactData( child->data() ); child = (OLEListViewItem*) child->itemBelow(); } QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); KMessageBox::information(this,mes); } void KAImportOLdialog::readContactData( DWORD folder ) { LPDISPATCH dispItem = (LPDISPATCH)folder; dispItem->AddRef(); MAPIFolder mf(dispItem); mf.m_lpDispatch->AddRef(); _Items folderItems; _variant_t indx((long)0); LPDISPATCH itm; int i; folderItems = mf.GetItems(); QProgressBar bar( folderItems.GetCount(),0 ); bar.setCaption (i18n("Importing - close to abort!") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _ContactItem * pItem = (_ContactItem *)&itm; ol2kapiContact( pItem ); itm->Release(); } } void KAImportOLdialog::slotOk() { QDialog::accept(); } void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) { KABC::Addressee addressee; addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); //GetLastModificationTime() //addressee.setName( const QString &name ); //addressee.setFormattedName( const QString &formattedName ); addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); if ( dtb.isValid() ) addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); //QString::fromUcs2(aItem->.GetBuffer()) //addressee.setMailer( const QString &mailer ); //addressee.setTimeZone( const TimeZone &timeZone ); //addressee.setGeo( const Geo &geo ); //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); - addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); + addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); + notesStr.replace( QRegExp("\\r"), ""); addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); //addressee.setRevision( const QDateTime &revision ); // addressee.setSortString( const QString &sortString ); addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); QString tempS; tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); if ( tempS.length() > 12 ) addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); - tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); + tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); dtb = mDdate2Qdtr(aItem->GetAnniversary()); if (dtb.isValid() ) { QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } int sec = aItem->GetSensitivity() ; if ( sec > 1 )// mapping pers -> private --sec; addressee.setSecrecy( sec ); //addressee.setLogo( const Picture &logo ); //addressee.setPhoto( const Picture &photo ); //addressee.setSound( const Sound &sound ); //addressee.setAgent( const Agent &agent ); - QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); + QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); addressee.setCategories( QStringList::split( ";", cat )); QString phoneS; phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); if ( ! phoneS.isEmpty()) addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); bool preferred = true; phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); if ( ! phoneS.isEmpty()) { addressee.insertEmail(phoneS , preferred ); preferred = false; } phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); if ( ! phoneS.isEmpty()) { addressee.insertEmail(phoneS , preferred ); preferred = false; } phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); if ( ! phoneS.isEmpty()) { addressee.insertEmail(phoneS , preferred ); preferred = false; } // is this the number of the preferred email? // long GetSelectedMailingAddress();??? KABC::Address addressHome; KABC::Address* addressAdd = &addressHome; bool insert = false; phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setCountry(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setRegion(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setLocality(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostalCode(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostOfficeBox(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setStreet(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { // redundant !addressAdd->setExtended(phoneS ); // insert = true; } addressAdd->setType( KABC::Address::Home ); if ( insert ) addressee.insertAddress( *addressAdd ); // ++++++++++++++++++++++ end of address KABC::Address addressWork; addressAdd = &addressWork; insert = false; phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setCountry(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setRegion(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setLocality(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostalCode(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostOfficeBox(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setStreet(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { // redundant !addressAdd->setExtended(phoneS ); // insert = true; } addressAdd->setType( KABC::Address::Work ); if ( insert ) addressee.insertAddress( *addressAdd ); // ++++++++++++++++++++++ end of address KABC::Address addressOther; addressAdd = &addressOther; insert = false; phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setCountry(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setRegion(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setLocality(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostalCode(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostOfficeBox(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setStreet(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); if ( ! phoneS.isEmpty()) { // redundant !addressAdd->setExtended(phoneS ); //insert = true; } //addressAdd->setId( ); if ( insert ) addressee.insertAddress( *addressAdd ); // ++++++++++++++++++++++ end of address KABC::Address addressMail; addressAdd = &addressMail; insert = false; phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setCountry(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setRegion(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setLocality(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostalCode(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setPostOfficeBox(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { addressAdd->setStreet(phoneS ); insert = true; } phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! phoneS.isEmpty()) { // redundant ! addressAdd->setExtended(phoneS ); // insert = true; } addressAdd->setType( KABC::Address::Postal ); if ( insert ) { addressee.insertAddress( *addressAdd ); } // the following code is disabled // it does not seem to be useful #if 0 if ( insert ) { addressAdd->setType( KABC::Address::Home ); if ( addressMail == addressHome ) { addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); addressee.insertAddress( addressHome ); } else { addressAdd->setType( KABC::Address::Work ); if ( addressMail == addressWork ){ addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); addressee.insertAddress( addressWork ); } else { addressAdd->setType( 0 ); if ( addressOther == addressMail ){ addressOther.setType( KABC::Address::Postal ); addressee.insertAddress( addressOther ); } else { addressee.insertAddress( *addressAdd ); } } } } #endif // ++++++++++++++++++++++ end of ALL addresses //GetUserProperties(); tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); int gen = aItem->GetGender(); if ( gen != 0 ) { // 0 undef - 1 female - 2 male if ( gen == 1 ) addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); else addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); } QString additionalInfo; QString tempAdd; tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nLanguage: "); additionalInfo += tempAdd; } tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nHobby: "); additionalInfo += tempAdd;; } tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nHomepage: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nBilling information: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nCustomer ID: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser1: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser2: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser3: "); additionalInfo += tempAdd;; } - tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); + tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); + phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser4: "); additionalInfo += tempAdd;; } if (!additionalInfo.isEmpty() ) { tempAdd = notesStr; notesStr = "+++++++++++++++++++++++++++\n"; notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); notesStr += additionalInfo; notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); notesStr += "+++++++++++++++++++++++++++\n"; notesStr += tempAdd; } addressee.setNote( notesStr ); #if 0 // pending - IM address: no clue where to get info about the helper ID -custom fields: difficult to implement - not implemented -keys: makes no sense #endif if ( addAddressee( addressee )) ++importedItems; } void KAImportOLdialog::slotCancel() { reject(); } bool KAImportOLdialog::addAddressee( KABC::Addressee a ) { bool add = true; KABC::Addressee::List::Iterator it; for ( it = mAList.begin(); it != mAList.end(); ++it ) { if ( (*it).uid() == a.uid() ) { add = false; break; } } if ( add ) { if ( mABook->findByUid(a.uid() ).isEmpty()) mAList.append ( a ); else add = false; } return add; } diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp index 0a3c2d5..c0bde0d 100644 --- a/korganizer/koimportoldialog.cpp +++ b/korganizer/koimportoldialog.cpp @@ -1,129 +1,130 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program 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 program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qtooltip.h> #include <qframe.h> #include <qpixmap.h> #include <qlayout.h> #include <qprogressbar.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qdir.h> #include <qapplication.h> #include <qhbox.h> +#include <qregexp.h> #include <qheader.h> #include <qdatetime.h> #include <qlistview.h> #include <kdebug.h> #include <klocale.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kinputdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include <kabc/stdaddressbook.h> #include "koprefs.h" #include "koglobals.h" #include "koimportoldialog.h" #include "../outport/msoutl9.h" #include <ole2.h> #include <comutil.h> _Application gOlApp; QDateTime mDdate2Qdtr( DATE dt) { COleDateTime odt; SYSTEMTIME st; odt = dt; odt.GetAsSystemTime(st); QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); return qdt; } class OLEListViewItem : public QCheckListItem { public: OLEListViewItem( QListView *parent, QString text ) : QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; OLEListViewItem( QListViewItem *after, QString text ) : QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; ~OLEListViewItem() {}; void setData( DWORD data ) {mData= data; }; DWORD data() { return mData ;}; private: DWORD mData; }; KOImportOLdialog::KOImportOLdialog( const QString &caption, Calendar *calendar, QWidget *parent ) : KDialogBase( Plain, caption, User1 | Close, Ok, parent, caption, true, false, i18n("Import!") ) { QHBox * mw = new QHBox( this ); setMainWidget( mw ); mListView = new QListView( mw ); mListView->addColumn(i18n("Select Folder to import")); mListView->addColumn(i18n("Content Type")); mCalendar = calendar; connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); setupFolderView(); resize( sizeHint().width()+50, sizeHint().height()+50 ); } KOImportOLdialog::~KOImportOLdialog() { } void KOImportOLdialog::setupFolderView() { SCODE sc = ::OleInitialize(NULL); if ( FAILED ( sc ) ) { KMessageBox::information(this,"OLE initialisation failed"); return; } if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ KMessageBox::information(this,"Sorry, cannot access Outlook"); return ; } MAPIFolder mfInbox; MAPIFolder mfRoot; CString szName; _NameSpace olNS; olNS = gOlApp.GetNamespace(_T("MAPI")); mfInbox = olNS.GetDefaultFolder(6); mfRoot = mfInbox.GetParent(); szName = mfRoot.GetName(); long iType = mfRoot.GetDefaultItemType(); QString mes; mes = QString::fromUcs2( szName.GetBuffer() ); @@ -157,193 +158,193 @@ void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent if ( iType != 1) hChild->setEnabled( false ); QString ts; switch( iType ) { case 0: ts = i18n("Mail"); break; case 1: ts = i18n("Calendar"); break; case 2: ts = i18n("Contacts"); break; case 3: ts = i18n("Todos"); break; case 4: ts = i18n("Journals"); break; case 5: ts = i18n("Notes"); break; default: ts = i18n("Unknown"); } hChild->setText( 1,ts); hChild->setData( (DWORD) mfChild.m_lpDispatch ); mfChild.m_lpDispatch->AddRef(); addFolder(hChild, mfChild.m_lpDispatch); } } void KOImportOLdialog::slotApply() { importedItems = 0; OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); while ( child ) { if ( child->isOn() ) readCalendarData( child->data() ); child = (OLEListViewItem*) child->itemBelow(); } QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); KMessageBox::information(this,mes); } void KOImportOLdialog::readCalendarData( DWORD folder ) { LPDISPATCH dispItem = (LPDISPATCH)folder; dispItem->AddRef(); MAPIFolder mf(dispItem); mf.m_lpDispatch->AddRef(); _Items folderItems; _variant_t indx((long)0); LPDISPATCH itm; int i; folderItems = mf.GetItems(); QProgressBar bar( folderItems.GetCount(),0 ); bar.setCaption (i18n("Importing - close to abort!") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _AppointmentItem * pItem = (_AppointmentItem *)&itm; ol2kopiCalendar( pItem ); itm->Release(); } } void KOImportOLdialog::slotOk() { QDialog::accept(); } void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) { KCal::Event* event = new KCal::Event(); if ( aItem->GetAllDayEvent() ){ event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); event->setFloats( true ); } else { event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); event->setFloats( false ); } event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); - event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()) ); + event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") ); QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); event->setCategories( QStringList::split( ";", cat )); if ( aItem->GetReminderSet() ) { event->clearAlarms(); Alarm* alarm = event->newAlarm(); alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); alarm->setEnabled( true ); if ( aItem->GetReminderPlaySound() ) { alarm->setType( Alarm::Audio ); alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); } else alarm->setType( Alarm::Display ); alarm->setRepeatCount( aItem->GetReplyTime() ); } // OL :pub 0 - pers 1 - priv 2 - conf 3 // KO : pub 0 - priv 1 - conf 2 int sec = aItem->GetSensitivity() ; if ( sec > 1 )// mapping pers -> private --sec; event->setSecrecy( sec ); if ( aItem->GetBusyStatus() == 0 ) event->setTransparency( Event::Transparent);// OL free else event->setTransparency( Event::Opaque);//OL all other if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur RecurrencePattern recpat = aItem->GetRecurrencePattern(); QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); int freq = recpat.GetInterval(); bool hasEndDate = !recpat.GetNoEndDate(); QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); QBitArray weekDays( 7 ); weekDays.fill(false ); uint weekDaysNum = recpat.GetDayOfWeekMask(); int i; int bb = 2; for( i = 1; i <= 6; ++i ) { weekDays.setBit( i - 1, ( bb & weekDaysNum )); bb = 4 << (i-1); //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); } if ( 1 & weekDaysNum) weekDays.setBit( 6 ); // int pos = 1;// pending Recurrence *r = event->recurrence(); int rtype = recpat.GetRecurrenceType(); //recurrence types are: /* olRecursDaily(0) olRecursWeekly(1) olRecursMonthly(2) olRecursMonthNth(3) olRecursYearly(5) olRecursYearNth(6) */ int duration = recpat.GetOccurrences(); if ( !hasEndDate ) duration = -1; //LPDISPATCH RecurrencePattern::GetExceptions() //long RecurrencePattern::GetMonthOfYear() if ( rtype == 0 ) { if ( hasEndDate ) r->setDaily( freq, endDate ); else r->setDaily( freq, duration ); } else if ( rtype == 1 ) { if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); else r->setWeekly( freq, weekDays, duration ); } else if ( rtype == 2 ) { if ( hasEndDate ) r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); else r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); //r->addMonthlyDay( startDate.day() ); r->addMonthlyDay( recpat.GetDayOfMonth() ); } else if ( rtype == 3 ) { if ( hasEndDate ) r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); else r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); QBitArray days( 7 ); days.fill( false ); days.setBit( startDate.dayOfWeek() - 1 ); int pos = (startDate.day()/7)+1; r->addMonthlyPos( pos, days ); //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); //KMessageBox::information(this,mes); } else if ( rtype == 5 ) { freq = 1; if ( hasEndDate ) r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9e215b9..63484d6 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -195,211 +195,217 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : //mView->setMaximumSize( splash->size() ); //mView->resize( splash->size() ); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); mView->readSettings(); bool newFile = false; if( !QFile::exists( defaultFileName() ) ) { QFileInfo finfo ( defaultFileName() ); QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); qDebug("oldfile %s ", oldFile.latin1()); QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } else { oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } } mView->saveCalendar( defaultFileName() ); newFile = true; } QTime neededSaveTime = QDateTime::currentDateTime().time(); mView->openCalendar( defaultFileName() ); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Calendar loading time: %d ms",msNeeded ); if ( KOPrefs::instance()->mLanguageChanged ) { KOPrefs::instance()->setCategoryDefaults(); int count = mView->addCategories(); KOPrefs::instance()->mLanguageChanged = false; } processIncidenceSelection( 0 ); connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processIncidenceSelection( Incidence * ) ) ); connect( mView, SIGNAL( modifiedChanged( bool ) ), SLOT( slotModifiedChanged( bool ) ) ); connect( mView, SIGNAL( tempDisableBR(bool) ), SLOT( disableBR(bool) ) ); connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); mView->setModified( false ); mBlockAtStartup = false; mView->setModified( false ); setCentralWidget( mView ); globalFlagBlockStartup = 0; mView->show(); delete splash; if ( newFile ) mView->updateConfig(); // qApp->processEvents(); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); //fillSyncMenu(); connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); mSyncManager->setDefaultFileName( defaultFileName()); connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); mSyncManager->fillSyncMenu(); mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); if ( showWarning ) { KMessageBox::information( this, "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); qApp->processEvents(); mView->dialogManager()->showSyncOptions(); } //US listen for result adressed from Ka/Pi #ifndef DESKTOP_VERSION connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); #endif #ifndef DESKTOP_VERSION infrared = 0; #endif mBRdisabled = false; toggleBeamReceive(); } MainWindow::~MainWindow() { //qDebug("MainWindow::~MainWindow() "); //save toolbar location delete mCalendar; delete mSyncManager; +#ifndef DESKTOP_VERSION if ( infrared ) delete infrared; +#endif } void MainWindow::disableBR(bool b) { +#ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive(); mBRdisabled = true; } + mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; - toggleBeamReceive(); + //makes no sense,because other cal ap is probably running + // toggleBeamReceive(); } } +#endif } bool MainWindow::beamReceiveEnabled() { #ifndef DESKTOP_VERSION return ( infrared != 0 ); #endif return false; } void MainWindow::toggleBeamReceive() { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("disable BeamReceive "); delete infrared; infrared = 0; brAction->setOn(false); return; } qDebug("enable BeamReceive "); brAction->setOn(true); infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); #endif } void MainWindow::showMaximized () { #ifndef DESKTOP_VERSION if ( ! globalFlagBlockStartup ) if ( mClosed ) mView->goToday(); #endif QWidget::showMaximized () ; mClosed = false; } void MainWindow::closeEvent( QCloseEvent* ce ) { if ( ! KOPrefs::instance()->mAskForQuit ) { saveOnClose(); mClosed = true; ce->accept(); return; } switch( QMessageBox::information( this, "KO/Pi", i18n("Do you really want\nto close KO/Pi?"), i18n("Close"), i18n("No"), 0, 0 ) ) { case 0: saveOnClose(); mClosed = true; ce->accept(); break; case 1: ce->ignore(); break; case 2: default: break; } } void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) { QDataStream stream( data, IO_ReadOnly ); // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); //QString datamess; //qDebug("message "); qDebug("KO: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; //qDebug("filename %s ", fileName.latin1()); showMaximized(); raise(); KOPrefs::instance()->mLastSyncedLocalFile = fileName ; mSyncManager->slotSyncMenu( 1002 ); return; } if ( cmsg == "-writeFile" ) { // I made from the "-writeFile" an "-writeAlarm" mView->viewManager()->showWhatsNextView(); mCalendar->checkAlarmForIncidence( 0, true); |