summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-02 15:35:34 (UTC)
committer ulf69 <ulf69>2004-07-02 15:35:34 (UTC)
commitb21b6754c93e5aaa53638a060e26f4efea755d37 (patch) (side-by-side diff)
tree2a78ca54cda74c2bff11c1244741d1bc48994ad6
parentbb7ad945c1541684a02e853fdaabd0e3ba74f8df (diff)
downloadkdepimpi-b21b6754c93e5aaa53638a060e26f4efea755d37.zip
kdepimpi-b21b6754c93e5aaa53638a060e26f4efea755d37.tar.gz
kdepimpi-b21b6754c93e5aaa53638a060e26f4efea755d37.tar.bz2
removed references to Global::applicationFileName because this call creates the appdir
in ~/Applications/ which is not correct for MicroKDE
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp17
-rw-r--r--kaddressbook/mainembedded.cpp4
-rw-r--r--korganizer/main.cpp4
3 files changed, 9 insertions, 16 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 144a9dc..075f12f 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -1,239 +1,228 @@
/*
This file is part of libkabc.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
-/*US
-#include <stdlib.h>
-
-#include <kapplication.h>
-#include <kcrash.h>
-#include <ksimpleconfig.h>
-*/
-
-#ifndef DESKTOP_VERSION
-#include <qpe/global.h>
-#else
#include <qdir.h>
-#endif
-
#include "resource.h"
#include <kresources/manager.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstaticdeleter.h>
#include <kstandarddirs.h>
#include "stdaddressbook.h"
using namespace KABC;
StdAddressBook *StdAddressBook::mSelf = 0;
bool StdAddressBook::mAutomaticSave = true;
static KStaticDeleter<StdAddressBook> addressBookDeleter;
QString StdAddressBook::fileName()
{
return locateLocal( "data", "kabc/std.vcf" );
}
QString StdAddressBook::directoryName()
{
return locateLocal( "data", "kabc/stdvcf" );
}
void StdAddressBook::handleCrash()
{
StdAddressBook::self()->cleanUp();
}
StdAddressBook *StdAddressBook::self()
{
if ( !mSelf )
{
QString appdir = StdAddressBook::setTempAppDir();
kdDebug(5700) << "StdAddressBook::self()" << endl;
// US im am not sure why I have to use the other format here??
#ifdef KAB_EMBEDDED
mSelf = addressBookDeleter.setObject( new StdAddressBook );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
QString StdAddressBook::setTempAppDir()
{
QString appDIR = KStandardDirs::appDir();
#ifdef DESKTOP_VERSION
QString appdir = QDir::homeDirPath();
if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
appdir += "kaddressbook/";
else
appdir += "/kaddressbook/";
KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
#else
- KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) );
+ QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
+
+ KStandardDirs::setAppDir( appdir );
#endif
return appDIR;
}
StdAddressBook *StdAddressBook::self( bool onlyFastResources )
{
if ( !mSelf )
{
QString appdir =StdAddressBook::setTempAppDir();
#ifdef KAB_EMBEDDED
mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
StdAddressBook::StdAddressBook()
//US : AddressBook( "kabcrc" )
: AddressBook( locateLocal( "config", "kabcrc") )
{
init( false );
}
StdAddressBook::StdAddressBook( bool onlyFastResources )
//US : AddressBook( "kabcrc" )
: AddressBook( locateLocal( "config", "kabcrc") )
{
init( onlyFastResources );
}
StdAddressBook::~StdAddressBook()
{
if ( mAutomaticSave )
save();
}
void StdAddressBook::init( bool )
{
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( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
}
Resource *res = standardResource();
if ( !res ) {
res = manager->createResource( "file" );
if ( res )
{
addResource( res );
}
else
kdDebug(5700) << "No resource available!!!" << endl;
}
setStandardResource( res );
manager->writeConfig();
load();
}
bool StdAddressBook::save()
{
kdDebug(5700) << "StdAddressBook::save()" << endl;
bool ok = true;
AddressBook *ab = self();
ab->deleteRemovedAddressees();
KRES::Manager<Resource>::ActiveIterator it;
KRES::Manager<Resource> *manager = ab->resourceManager();
for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
if ( !(*it)->readOnly() && (*it)->isOpen() ) {
Ticket *ticket = ab->requestSaveTicket( *it );
// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
if ( !ticket ) {
ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
.arg( (*it)->resourceName() ) );
return false;
}
if ( !ab->save( ticket ) )
ok = false;
}
}
return ok;
}
void StdAddressBook::close()
{
//US destructObject is not defined on my system???. Is setObject(0) the same ???
//US addressBookDeleter.destructObject();
addressBookDeleter.setObject(0);
}
void StdAddressBook::setAutomaticSave( bool enable )
{
mAutomaticSave = enable;
}
bool StdAddressBook::automaticSave()
{
return mAutomaticSave;
}
// should get const for 4.X
Addressee StdAddressBook::whoAmI()
{
//US KConfig config( "kabcrc" );
KConfig config( locateLocal("config", "kabcrc") );
config.setGroup( "General" );
return findByUid( config.readEntry( "WhoAmI" ) );
}
void StdAddressBook::setWhoAmI( const Addressee &addr )
{
//US KConfig config( "kabcrc" );
KConfig config( locateLocal("config", "kabcrc") );
config.setGroup( "General" );
config.writeEntry( "WhoAmI", addr.uid() );
}
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 3f6f69d..47b5484 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,204 +1,206 @@
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#include <qpe/global.h>
#include <stdlib.h>
#else
#include <qapplication.h>
#include <qwindowsstyle.h>
#include <qplatinumstyle.h>
#include <qmainwindow.h>
#endif
#include <kstandarddirs.h>
#include <kglobal.h>
#include <stdio.h>
#include <qdir.h>
#include "kaddressbookmain.h"
int main( int argc, char **argv )
{
#ifndef DESKTOP_VERSION
QPEApplication a( argc, argv );
a.setKeepRunning ();
#else
QApplication a( argc, argv );
QApplication::setStyle( new QPlatinumStyle ());
#endif
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("KA/E command line commands:\n");
printf(" no command: Start KA/E in usual way\n");
printf(" -help: This output\n");
printf(" KA/E is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
KGlobal::setAppName( "kaddressbook" );
#ifndef DESKTOP_VERSION
- KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) );
+ QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName();
+
+ KStandardDirs::setAppDir( appdir );
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
#else
QString fileName ;
#ifndef _WIN32_
fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons16/";
#else
fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\icons16\\";
#endif
KGlobal::iconLoader()->setIconPath(fileName);
QString appdir = QDir::homeDirPath();
if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
appdir += "kaddressbook";
else
appdir += "/kaddressbook";
KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
// qDebug(" %s ",KStandardDirs::appDir().latin1() );
#endif // desktop
QDir app_dir;
if ( !app_dir.exists(KStandardDirs::appDir()) )
app_dir.mkdir (KStandardDirs::appDir());
KAddressBookMain* m = new KAddressBookMain();
//US MainWindow m;
//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
#ifndef DESKTOP_VERSION
a.showMainWidget(m );
m->showMaximized();
#else
a.setMainWidget(m );
m->show();
//m->resize( 640, 480 );
#endif
a.exec();
}
qDebug("KA: Bye! ");
}
/*
#include <stdlib.h>
#include <qstring.h>
#include <kabc/stdaddressbook.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kcrash.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstartupinfo.h>
#include <kuniqueapplication.h>
#include <kwin.h>
#include "kaddressbookmain.h"
#include "kabcore.h"
extern "C" {
void crashHandler( int )
{
KABC::StdAddressBook::handleCrash();
::exit( 0 );
}
}
class KAddressBookApp : public KUniqueApplication {
public:
KAddressBookApp() : mMainWin( 0 ) {}
~KAddressBookApp() {}
int newInstance();
private:
KAddressBookMain *mMainWin;
};
int KAddressBookApp::newInstance()
{
if ( isRestored() ) {
// There can only be one main window
if ( KMainWindow::canBeRestored( 1 ) ) {
mMainWin = new KAddressBookMain;
mMainWin->show();
mMainWin->restore( 1 );
}
} else {
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QCString addrStr = args->getOption( "addr" );
QCString uidStr = args->getOption( "uid" );
QString addr;
QString uid;
if ( !addrStr.isEmpty() )
addr = QString::fromLocal8Bit( addrStr );
if ( !uidStr.isEmpty() )
uid = QString::fromLocal8Bit( uidStr );
if ( args->isSet( "editor-only" ) ) {
if ( !mMainWin )
mMainWin = new KAddressBookMain;
KStartupInfo::appStarted();
mMainWin->hide();
} else {
if ( mMainWin ) {
mMainWin->show();
KWin::setActiveWindow( mMainWin->winId() );
} else {
mMainWin = new KAddressBookMain;
mMainWin->show();
}
}
// Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
if ( !addr.isEmpty() )
mMainWin->addEmail( addr );
if ( !uid.isEmpty() )
mMainWin->showContactEditor( uid );
if ( args->isSet( "new-contact" ) ) {
mMainWin->newContact();
}
}
KCrash::setEmergencySaveFunction( crashHandler );
return 0;
}
// the dummy argument is required, because KMail apparently sends an empty
// argument.
static KCmdLineOptions kmoptions[] =
{
{ "a", 0 , 0 },
{ "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
{ "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
{ "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
{ "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
{ "+[argument]", I18N_NOOP( "dummy argument" ), 0},
{ 0, 0, 0}
};
int main( int argc, char *argv[] )
{
KLocale::setMainCatalogue( "kaddressbook" );
KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
KCmdLineArgs::addCmdLineOptions( kmoptions );
KUniqueApplication::addCmdLineOptions();
if ( !KAddressBookApp::start() )
exit( 0 );
KAddressBookApp app;
KGlobal::locale()->insertCatalogue( "libkdepim" );
return app.exec();
}
*/
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index 6843595..a357988 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,107 +1,109 @@
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#include <qpe/global.h>
#include <stdlib.h>
#else
#include <qapplication.h>
#include <qstring.h>
#include <qwindowsstyle.h>
#include <qplatinumstyle.h>
#include <qsgistyle.h>
#endif
#include <qdir.h>
#include <kstandarddirs.h>
#include <kglobal.h>
#include <stdio.h>
#include "mainwindow.h"
int main( int argc, char **argv )
{
#ifndef DESKTOP_VERSION
QPEApplication a( argc, argv );
a.setKeepRunning ();
#else
QApplication a( argc, argv );
QApplication::setStyle( new QPlatinumStyle ());
#endif
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("KO/Pi command line commands:\n");
printf(" no command: Start KO/Pi in usual way\n");
printf(" -help: This output\n");
printf("Next Option: Open or Show after start:\n");
printf(" -newTodo: New Todo dialog\n");
printf(" -newEvent: New Event dialog\n");
printf(" -showList: List view\n");
printf(" -showDay: Day view\n");
printf(" -showWWeek: Work Week view\n");
printf(" -showWeek: Week view\n");
printf(" -showTodo: Todo view\n");
printf(" -showJournal: Journal view\n");
printf(" -showKO: Next Days view\n");
printf(" -showWNext: What's Next view\n");
printf(" -showNextXView: Next X View\n");
printf(" -new[Y] and -show[X] may be used togehther\n");
printf(" KO/Pi is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
KGlobal::setAppName( "korganizer" );
QString fileName ;
#ifndef DESKTOP_VERSION
- KStandardDirs::setAppDir( Global::applicationFileName( "korganizer", "" ) );
+ QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName();
+ KStandardDirs::setAppDir( appdir );
+
fileName = getenv("QPEDIR");
KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
#else
#ifndef _WIN32_
fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
#else
fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\";
#endif
KGlobal::iconLoader()->setIconPath(fileName);
QString appdir = QDir::homeDirPath();
//appdir = "C:\\";
if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
appdir += "korganizer";
else
appdir += "/korganizer";
KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
// qDebug(" %s ",KStandardDirs::appDir().latin1() );
#endif
QDir app_dir;
if ( !app_dir.exists(KStandardDirs::appDir()) )
app_dir.mkdir (KStandardDirs::appDir());
MainWindow m;
#ifndef DESKTOP_VERSION
QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
a.showMainWidget(&m );
#else
a.setMainWidget(&m );
m.show();
//m.resize( 800, 600 );
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
#endif
if ( argc > 1 ) {
QCString command = argv[1];
if ( argc > 2 )
command += argv[2];
qApp->processEvents();
m.recieve(command, QByteArray() );
}
a.exec();
}
qDebug("KO: Bye! ");
}