Release 0.4.3-3maemo with patches to disable menus/actions, add ScrollArea and fix...
[keepassx] / src / main_macx.cpp
1 /***************************************************************************
2  *   Copyright (C) 1992-2008 Trolltech ASA                                                                 *
3  *                                                                         *
4  *   Copyright (C) 2005-2008 by Tarek Saidi                                *
5  *   tarek.saidi@arcor.de                                                  *
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; version 2 of the License.               *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20  ***************************************************************************/
21
22 #include <QVarLengthArray>
23 #include <Carbon/Carbon.h>
24 #include "main.h"
25
26 void initAppPaths(int argc,char** argv) {
27         CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
28         //assert(bundleURL);
29         CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
30         //assert(cfPath);
31         CFIndex length = CFStringGetLength(cfPath);
32         const UniChar *chars = CFStringGetCharactersPtr(cfPath);
33         if (chars) {
34                 AppDir = QString(reinterpret_cast<const QChar *>(chars), length);
35         }
36         else {  
37                 QVarLengthArray<UniChar> buffer(length);
38                 CFStringGetCharacters(cfPath, CFRangeMake(0, length), buffer.data());
39                 AppDir = QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
40         }
41         AppDir.truncate(AppDir.lastIndexOf("/"));
42         HomeDir = QDir::homePath()+"/.keepassx";
43         DataDir=AppDir+"/../Resources/keepassx";        
44 }