Accepting request 135463 from home:MargueriteSu:branches:M17N

fix build 11.4 and 12.1

OBS-URL: https://build.opensuse.org/request/show/135463
OBS-URL: https://build.opensuse.org/package/show/M17N/fcitx?expand=0&rev=49
This commit is contained in:
Marguerite Su 2012-09-23 14:19:32 +00:00 committed by Git OBS Bridge
parent 0a3f02cb4a
commit 77d8c38788
3 changed files with 67 additions and 0 deletions

View File

@ -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();

View File

@ -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

View File

@ -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