diff --git a/fcitx-4.2.6-openSUSE-12.1-QDBusConnection.patch b/fcitx-4.2.6-openSUSE-12.1-QDBusConnection.patch new file mode 100644 index 0000000..e98abca --- /dev/null +++ b/fcitx-4.2.6-openSUSE-12.1-QDBusConnection.patch @@ -0,0 +1,55 @@ +diff --git a/src/frontend/qt/fcitx-input-context.cpp b/src/frontend/qt/fcitx-input-context.cpp +index 5ba941b..6e5a9d9 100644 +--- a/src/frontend/qt/fcitx-input-context.cpp ++++ b/src/frontend/qt/fcitx-input-context.cpp +@@ -113,11 +113,37 @@ typedef QInputMethodEvent::Attribute QAttribute; + + static bool key_filtered = false; + ++QByteArray QFcitxInputContext::localMachineId() ++{ ++#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) ++ return QDBusConnection::localMachineId(); ++#else ++ QFile file1("/var/lib/dbus/machine-id"); ++ QFile file2("/etc/machine-id"); ++ QFile* fileToRead = NULL; ++ if (file1.open(QIODevice::ReadOnly)) { ++ fileToRead = &file1; ++ } ++ else if (file2.open(QIODevice::ReadOnly)) { ++ fileToRead = &file2; ++ } ++ if (fileToRead) { ++ QByteArray result = fileToRead->readLine(1024); ++ fileToRead->close(); ++ result = result.trimmed(); ++ if (!result.isEmpty()) ++ return result; ++ } ++ return "machine-id"; ++#endif ++} ++ + QString + QFcitxInputContext::socketFile() + { + char* addressFile = NULL; +- asprintf(&addressFile, "%s-%d", QDBusConnection::localMachineId().data(), fcitx_utils_get_display_number()); ++ ++ asprintf(&addressFile, "%s-%d", localMachineId().data(), fcitx_utils_get_display_number()); + + char* file = NULL; + +diff --git a/src/frontend/qt/fcitx-input-context.h b/src/frontend/qt/fcitx-input-context.h +index 6c7ecf4..ed7d2db 100644 +--- a/src/frontend/qt/fcitx-input-context.h ++++ b/src/frontend/qt/fcitx-input-context.h +@@ -102,6 +102,7 @@ private Q_SLOTS: + void updateCursor(); + #endif + private: ++ static QByteArray localMachineId(); + static QString socketFile(); + static QString address(); + void cleanUp(); diff --git a/fcitx.changes b/fcitx.changes index 2a2f503..9ef61d9 100644 --- a/fcitx.changes +++ b/fcitx.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sun Sep 23 13:32:25 UTC 2012 - i@marguerite.su + +- fix openSUSE 12.1 and below build + * 4.2.6 uses a Qt 4.8+ only function (QDBusConnection) so it fails on 12.1 and below. + * weng fix it. + ------------------------------------------------------------------- Sat Sep 15 18:04:19 UTC 2012 - i@marguerite.su diff --git a/fcitx.spec b/fcitx.spec index 1d819ea..dc36dfb 100644 --- a/fcitx.spec +++ b/fcitx.spec @@ -38,6 +38,8 @@ Source7: xinput-fcitx Source8: openSUSE-default.tar.gz #FIX-FOR-UPSTREAM i@marguerite.su - dont download online #Patch1: fix_fcitx_googlecode_resolv_error.patch +#FIX-FOR-OPENSUSE wengxt@gmail.com - fix QDBusConnection in Qt 4.7 +Patch2: fcitx-4.2.6-openSUSE-12.1-QDBusConnection.patch BuildRequires: cairo-devel %if 0%{?suse_version} BuildRequires: dbus-1-devel @@ -358,6 +360,9 @@ You can either use this package for download from kde-look.org using knewstaff i %prep %setup -q -n %{name}-%{version} #%patch1 -p1 +%if 0%{?suse_version} <= 1210 +%patch2 -p1 +%endif %build mkdir build