--- kresources/slox/kabcresourceslox.cpp
+++ kresources/slox/kabcresourceslox.cpp	2005/05/24 12:14:20
@@ -20,7 +20,9 @@
 
 #include <qapplication.h>
 
+#include <dcopclient.h>
 #include <kabc/addressee.h>
+#include <kapplication.h>
 #include <kconfig.h>
 #include <kdebug.h>
 #include <klocale.h>
@@ -149,6 +151,30 @@
   }
 
   KURL url = mPrefs->url();
+  // check if the network is online.  Just use the cache and set it readonly if it is not
+  const int NetWorkStatusUnknown = 1;
+  const int NetWorkStatusOnline = 8;
+  QCString replyType;
+  QByteArray params;
+  QByteArray reply;
+
+  QDataStream stream( params, IO_WriteOnly );
+  stream << url.host();
+
+  if ( kapp->dcopClient()->call( "kded", "networkstatus", "status(QString)",
+                          params, replyType, reply ) && ( replyType == "int" ) )
+  {
+    int result;
+    QDataStream stream2(  reply, IO_ReadOnly );
+    stream2 >> result;
+    kdDebug() << k_funcinfo << "networkstatus status = " << result << endl;
+    // if it's not unknown (no networks announced by network control apps), and not offline, give up now
+    if ( ( result != NetWorkStatusUnknown ) && ( result != NetWorkStatusOnline ) )
+    {
+      return true;
+    }
+  }
+
   url.setPath( "/servlet/webdav.contacts/" );
   url.setUser( mPrefs->user() );
   url.setPass( mPrefs->password() );
--- kresources/slox/kcalresourceslox.cpp
+++ kresources/slox/kcalresourceslox.cpp	2005/05/24 12:14:20
@@ -26,6 +26,8 @@
 #include <qptrlist.h>
 #include <qfile.h>
 
+#include <dcopclient.h>
+#include <kapplication.h>
 #include <kdebug.h>
 #include <kurl.h>
 #include <kio/job.h>
@@ -163,17 +165,45 @@
     return false;
   }
 
+
   mCalendar.close();
 
   disableChangeNotification();
   loadCache();
   enableChangeNotification();
 
+  KURL url = mPrefs->url();
+  // check if the network is online.  Just use the cache and set it readonly if it is not
+  const int NetWorkStatusUnknown = 1;
+  const int NetWorkStatusOnline = 8;
+  QCString replyType;
+  QByteArray params;
+  QByteArray reply;
+
+  QDataStream stream( params, IO_WriteOnly );
+  stream << url.host();
+
+  if ( kapp->dcopClient()->call( "kded", "networkstatus", "status(QString)",
+                          params, replyType, reply ) && ( replyType == "int" ) )
+  {
+    int result;
+    QDataStream stream2(  reply, IO_ReadOnly );
+    stream2 >> result;
+    kdDebug() << k_funcinfo << "networkstatus status = " << result << endl;
+    // if it's not unknown (no networks announced by network control apps), and not offline, give up now
+    if ( ( result != NetWorkStatusUnknown ) && ( result != NetWorkStatusOnline ) )
+    {
+      loadCache();
+      emit resourceChanged( this );
+      return true;
+    }
+  }
+
   emit resourceChanged( this );
 
   clearChanges();
 
-  QString p = KURL( mPrefs->url() ).protocol();
+  QString p = url.protocol();
   if ( p != "http" && p != "https" && p != "webdav" && p != "webdavs" ) {
     QString err = i18n("Non-http protocol: '%1'").arg( p );
     kdDebug() << "KCalResourceSlox::load(): " << err << endl;
