types.h
util.h)
+if(APPLE)
+ set(SOURCES ${SOURCES} mac_utils.cpp)
+ set(HEADERS ${HEADERS} mac_utils.h)
+endif(APPLE)
+
qt4_wrap_cpp(MOC ${MOC_HDRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) # for version.inc and version.gen
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES version.gen)
add_library(mod_common STATIC ${SOURCES} ${MOC})
+if(APPLE)
+ target_link_libraries(mod_common "-framework CoreServices" "-framework CoreFoundation")
+endif(APPLE)
\ No newline at end of file
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "identity.h"
+
#include <QMetaProperty>
#include <QVariantMap>
-#include "identity.h"
+#ifdef Q_OS_MAC
+# include <CoreServices/CoreServices.h>
+# include "mac_utils.h"
+#endif
Identity::Identity(IdentityId id, QObject *parent)
: SyncableObject(parent),
setAllowClientUpdates(true);
}
+QString Identity::defaultNick() {
+#ifdef Q_OS_MAC
+ return CFStringToQString(CSCopyUserName(true));
+#else
+ return QString("quassel%1").arg(qrand() & 0xff); // FIXME provide more sensible default nicks
+#endif
+}
+
+QString Identity::defaultRealName() {
+#ifdef Q_OS_MAC
+ return CFStringToQString(CSCopyUserName(false));
+#else
+ return tr("Quassel IRC User");
+#endif
+}
+
void Identity::setToDefaults() {
setIdentityName(tr("<empty>"));
- setRealName(tr("Quassel IRC User"));
+ setRealName(defaultRealName());
QStringList n;
- n << QString("quassel%1").arg(qrand() & 0xff); // FIXME provide more sensible default nicks
+ n << defaultNick();
setNicks(n);
setAwayNick("");
setAwayNickEnabled(false);
QString _ident, _kickReason, _partReason, _quitReason;
void init();
+ QString defaultNick();
+ QString defaultRealName();
friend QDataStream &operator>>(QDataStream &in, Identity &identity);
};
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "mac_utils.h"
+
+#include <QVarLengthArray>
+
+QString CFStringToQString(CFStringRef str) {
+ if(!str)
+ return QString();
+
+ CFIndex length = CFStringGetLength(str);
+ const UniChar *chars = CFStringGetCharactersPtr(str);
+ if(chars)
+ return QString(reinterpret_cast<const QChar *>(chars), length);
+
+ QVarLengthArray<UniChar> buffer(length);
+ CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());
+ return QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef MAC_UTILS_H
+#define MAC_UTILS_H
+
+#include <QString>
+#include <CoreFoundation/CoreFoundation.h>
+
+QString CFStringToQString(CFStringRef str);
+
+#endif //MAC_UTILS_H