Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > media > main-src > by-pkgid > a6bc312ce50b5c8d0c51736e58ac32bc > files > 350

kdebase-3.4.2-55mdk.src.rpm

--- libkonq/konqbookmarkmanager.h--	2005-04-11 04:04:11.953452997 -0400
+++ libkonq/konqbookmarkmanager.h	2005-04-11 04:05:26.583288793 -0400
@@ -5,18 +5,92 @@
 #include <kstandarddirs.h>
 #include <libkonq_export.h>
 
+#include <stdlib.h>
+#include <qfile.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
 class LIBKONQ_EXPORT KonqBookmarkManager
 {
 public:
-    static KBookmarkManager * self() {
-        if ( !s_bookmarkManager )
-        {
-            QString bookmarksFile = locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
-            s_bookmarkManager = KBookmarkManager::managerForFile( bookmarksFile );
-        }
-        return s_bookmarkManager;
-    }
-
+  static KBookmarkManager * self() {
+    if ( !s_bookmarkManager )
+      {
+       internationalBookmarks();
+       QString bookmarksFile = locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
+       s_bookmarkManager = KBookmarkManager::managerForFile( bookmarksFile );
+      }
+    return s_bookmarkManager;
+  }
+  static void internationalBookmarks()
+  {
+    QString newBookmarksFile = locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
+    QString copyBookmarksFile;
+    switch(KStandardDirs::mandrake_distro_version())
+      {
+      case KStandardDirs::DOWNLOAD:
+       copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-download-%1.xml" );
+       break;
+      case KStandardDirs::POWERPACK:
+       copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-powerpack-%1.xml" );
+       break;
+      case KStandardDirs::DISCOVERY:
+       copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-discovery-%1.xml" );
+       break;
+      case KStandardDirs::POWERPACKPLUS:
+       copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-powerpackplus-%1.xml" );
+       break;
+      }
+    if ( !QFile( newBookmarksFile ).exists() )
+      {
+       QStringList langList = QStringList::split(":",QString::fromLocal8Bit(getenv("LANGUAGE")));
+       bool languageFound = false;
+       for ( QStringList::Iterator it = langList.begin(); it != langList.end(); ++it )
+         {
+           QString tmpFile = copyBookmarksFile.arg(*it);
+           if( QFile::exists(tmpFile))
+             {
+               copyBookmarksFile = tmpFile;
+               languageFound = true;
+               break;
+             }
+         }
+       if ( !languageFound )
+         {
+           //default
+           switch(KStandardDirs::mandrake_distro_version())
+             {
+             case KStandardDirs::DOWNLOAD:
+               copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-download.xml" );
+               break;
+             case KStandardDirs::POWERPACK:
+               copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-powerpack.xml" );
+               break;
+             case KStandardDirs::DISCOVERY:
+               copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-discovery.xml" );
+               break;
+             case KStandardDirs::POWERPACKPLUS:
+               copyBookmarksFile = QString("/usr/share/mdk/kde/bookmarks/bookmarks-powerpackplus.xml" );
+               break;
+             }
+           if( !QFile::exists(copyBookmarksFile))
+             copyBookmarksFile="";
+         }
+       if ( !copyBookmarksFile.isEmpty() )
+         {
+           QCString cmd = "cp ";
+           cmd += QFile::encodeName( copyBookmarksFile );
+           cmd += " ";
+           cmd += QFile::encodeName( newBookmarksFile );
+           system( cmd );
+         }
+      }
+  }
+		
 private:
     static KBookmarkManager *s_bookmarkManager;
 };
--- konqueror/keditbookmarks/main.cpp.international_bookmark	2005-04-08 12:02:39.000000000 -0400
+++ konqueror/keditbookmarks/main.cpp	2005-04-11 04:38:43.922324394 -0400
@@ -39,6 +39,7 @@
 
 #include <kbookmarkmanager.h>
 #include <kbookmarkexporter.h>
+#include <konqbookmarkmanager.h>
 
 static KCmdLineOptions options[] = {
     {"importmoz <filename>", I18N_NOOP("Import bookmarks from a file in Mozilla format"), 0},
@@ -137,7 +138,7 @@ extern "C" KDE_EXPORT int kdemain(int ar
     KApplication app(isGui, isGui);
 
     bool gotArg = (args->count() == 1);
-
+    KonqBookmarkManager::internationalBookmarks();
     QString filename = gotArg
         ? QString::fromLatin1(args->arg(0))
         : locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));