[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdepim/kresources/groupwise/soap
From:       Will Stephenson <wstephenson () kde ! org>
Date:       2007-01-19 15:38:30
Message-ID: 1169221110.196756.20477.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 625234 by wstephens:

Workarounds for the GW server having 2 ideas about the same email address

 M  +3 -2      groupwiseserver.cpp  
 M  +38 -0     gwconverter.cpp  
 M  +1 -1      gwconverter.h  
 M  +5 -5      incidenceconverter.cpp  


--- branches/KDE/3.5/kdepim/kresources/groupwise/soap/groupwiseserver.cpp \
#625233:625234 @@ -1023,11 +1023,12 @@
   }
   else  // If I am not the organizer restrict my changes to accept or decline \
requests or task completion  {
-    // find myself as attendee.   
+    // find myself as attendee.
+    GWConverter conv( mSoap );
     KCal::Attendee::List attendees = incidence->attendees();
     KCal::Attendee::List::ConstIterator it;
     for( it = attendees.begin(); it != attendees.end(); ++it ) {
-      if ( (*it)->email() == mUserEmail ) {
+      if ( conv.emailsMatch( (*it)->email(), mUserEmail ) ) {
         if ( (*it)->status() == KCal::Attendee::Accepted )
           success &= acceptIncidence( incidence );
         else if ( (*it)->status() == KCal::Attendee::Declined )
--- branches/KDE/3.5/kdepim/kresources/groupwise/soap/gwconverter.cpp #625233:625234
@@ -131,3 +131,41 @@
   QDateTime utc = charToQDateTime( str );
   return KPimPrefs::utcToLocalTime( utc, timezone );
 }
+
+bool GWConverter::emailsMatch( const QString & email1, const QString & email2 )
+{
+    // eg demo3.po1.dom1@dmz1.provo.novell.com == demo3@dmz1.provo.novell.com
+    if ( email1 == email2 )
+        return true;
+
+    QString shorter, longer;
+    if ( email1.length() < email2.length() )
+    {
+        shorter = email1;
+        longer = email2;
+    }
+    else
+    {
+        shorter = email2;
+        longer = email1;
+    }
+
+    QString shortStem = shorter.section( '@', 0, 0 );
+    QString longStem = longer.section( '@', 0, 0 );
+    QString shortHost = shorter.section( '@', 1, 1 );
+    QString longHost = longer.section( '@', 1, 1 );
+
+    QString extension = longStem.right( longStem.length() - shortStem.length() );
+
+    kdDebug() << "gwconverter::emailsMatch(): " << shorter << " = " << longer << \
endl; +    kdDebug() << "shortStem: " << shortStem << ", longStem: " << longStem << \
", extension: " << extension << endl; +
+    if ( longStem.startsWith( shortStem ) && extension.startsWith( "." ) && (
+    shortHost == longHost ) )
+    {
+        kdDebug() << "Looks like a match!" << endl;
+        return true;
+    }
+    return false;
+}
+
--- branches/KDE/3.5/kdepim/kresources/groupwise/soap/gwconverter.h #625233:625234
@@ -56,7 +56,7 @@
     
     QDateTime stringToQDateTime( const std::string* );
 
-
+    bool emailsMatch( const QString & email1, const QString & email2 );
   private:
     struct soap* mSoap;
 };
--- branches/KDE/3.5/kdepim/kresources/groupwise/soap/incidenceconverter.cpp \
#625233:625234 @@ -626,20 +626,20 @@
     std::vector<ngwt__Recipient*>::const_iterator it;
 
     for ( it = recipients.begin(); it != recipients.end(); ++it ) {
-      kdDebug() << "---- recipient " << endl;
-    ngwt__Recipient *recipient = *it;
+      ngwt__Recipient *recipient = *it;
+      kdDebug() << "---- recipient " << recipient->email->c_str() << endl;
       KCal::Attendee *attendee = new KCal::Attendee(
         stringToQString( recipient->displayName ),
         stringToQString( recipient->email ) );
 
       // set our status
-      if ( *(recipient->email) == *(qStringToString( mFromEmail )) )
+      if ( emailsMatch( stringToQString(recipient->email), mFromEmail ) )
         if ( item->status->accepted )
           attendee->setStatus( ( *item->status->accepted ) ? \
KCal::Attendee::Accepted : KCal::Attendee::NeedsAction );  else 
-          kdDebug() << "---- not accepted" << endl;
+          kdDebug() << "---- found ourselves, but not accepted" << endl;
       else
-        kdDebug() << "---- '" << recipient->email->c_str() << "' != '" << \
(qStringToString( mFromEmail ))->c_str() << "'" << endl; +        kdDebug() << "---- \
'" <<  "' != '" << (qStringToString( mFromEmail ))->c_str() << "'" << endl;  
       incidence->addAttendee( attendee );
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic