EionRobb / purple-mattermost

A libpurple/Pidgin plugin for Mattermost
GNU General Public License v3.0
93 stars 23 forks source link

macOS support? #28

Open richardklose opened 7 years ago

richardklose commented 7 years ago

Are there any plans to support macOS? Would like to see this in action with Adium on macOS.

menardorama commented 7 years ago

+1

EionRobb commented 7 years ago

Unfortunately I don't have a build system in place that could build for adium. It's possible to use macports to compile it for pidgin on osx though

jaroslawp commented 7 years ago

I'm afraid I don;t have one either: linux build env, here ...

barthel commented 7 years ago

Maybe I could help, but I'm not a C/C++ developer.

The required libraries I installed via homebrew:

$ brew install json-glib
$ brew install pidgin --without-gui

It installs the pidgin command client finch and the libpurple.

pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags returns:

-D_REENTRANT -I/usr/local/Cellar/pidgin/2.12.0/include/libpurple -I/usr/local/Cellar/json-glib/1.2.8/include/json-glib-1.0 -I/usr/local/Cellar/glib/2.52.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.52.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.40/include -L/usr/local/Cellar/pidgin/2.12.0/lib -L/usr/local/Cellar/json-glib/1.2.8/lib -L/usr/local/Cellar/glib/2.52.3/lib -L/usr/local/opt/gettext/lib -lpurple -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -Wl,-framework -Wl,CoreFoundation

Execute make in a fresh cloned purple-mattermost repository failed with:

$ make libmattermost.so
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.08.git.90dc0ea"' -shared -o libmattermost.so libmattermost.c -Wl,-z,relro  `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags`  -I/opt/local/include -lz  -Ipurple2compat -g -ggdb -lmarkdown

libmattermost.c:2358:1: error: function definition is not allowed here
{
^
libmattermost.c:2441:30: error: use of undeclared identifier 'mm_g_free_mattermost_attachment_field'
        g_list_free_full(flds_list, mm_g_free_mattermost_attachment_field); 
                                    ^
2 errors generated.
make: *** [libmattermost.so] Error 1

@EionRobb @jaroslawp Could one of yours tell me, what I have to do next?

jaroslawp commented 7 years ago

Looks like your gcc (BTW: what version is it ?: gcc -v) does not allow function definitions within functions: move lines 2351 - 2365 (struct and function defs) before 2337 (mm_process_attachment( ..) - then it should compile (hmm.. I thought all gcc versions allowed nesting functions i ? ...)

barthel commented 7 years ago
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
barthel commented 7 years ago

Moved lines like @jaroslawp expected.

$ make libmattermost.so
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.08.git.90dc0ea"' -shared -o libmattermost.so libmattermost.c -Wl,-z,relro  `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags`  -I/opt/local/include -lz  -Ipurple2compat -g -ggdb -lmarkdown
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libmattermost.so] Error 1
$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-278.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
LTO support using: LLVM version 8.1.0, (clang-802.0.42)
TAPI support using: Apple TAPI version 1.33.11

The man page of ld doesn't provide an option -z.

Add -v in LDFLAGS in Makefile:

$ make libmattermost.so
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.08.git.90dc0ea"' -shared -o libmattermost.so libmattermost.c -Wl,-z,-v,relro  `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags`  -I/opt/local/include -lz  -Ipurple2compat -g -ggdb -lmarkdown
@(#)PROGRAM:ld  PROJECT:ld64-278.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
    /usr/local/Cellar/pidgin/2.12.0/lib
    /usr/local/Cellar/json-glib/1.2.8/lib
    /usr/local/Cellar/glib/2.52.3/lib
    /usr/local/opt/gettext/lib
    /usr/lib
    /usr/local/lib
Framework search paths:
    /Library/Frameworks/
    /System/Library/Frameworks/
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libmattermost.so] Error 1
barthel commented 7 years ago

I step over this error by removing the -z,relro from LDFLAGS.

But now the markdown lib is missing.

$ make libmattermost.so
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.08.git.90dc0ea"' -shared -o libmattermost.so libmattermost.c -Wl `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags`  -I/opt/local/include -lz  -Ipurple2compat -g -ggdb -lmarkdown
warning: unknown warning option '-Wl' [-Wunknown-warning-option]
1 warning generated.
ld: library not found for -lmarkdown
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libmattermost.so] Error 1
barthel commented 7 years ago
$ brew install discount --with-shared

adds the required markdown lib.

Now it compiles:

$ make libmattermost.so
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.08.git.90dc0ea"' -shared -o libmattermost.so libmattermost.c -Wl `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags`  -I/opt/local/include -lz  -Ipurple2compat -g -ggdb -lmarkdown
warning: unknown warning option '-Wl' [-Wunknown-warning-option]
1 warning generated.

It seems it works in finch after I copied libmattermost.so into ~/.purple/plugins:

mattermost_on_macos

I can't check that deeper. I've no public mattermost account.

barthel commented 7 years ago

Adium is another level. It required a valid plugin. But the developer wiki (https://trac.adium.im/wiki/AdiumXtras) is down for now.

jaroslawp commented 7 years ago

Cool ! Could you please check this branch: https://github.com/EionRobb/purple-mattermost/tree/osx-build and tell me if it works for you ? (please also have a look at INSTALL.md, I've added a paragraph about MacOS X build) Thanks !

Indeed, Adium would require a wrapper around purple plugin (something like this: https://github.com/tieto/sipe/tree/launchpad/src/adium).

barthel commented 7 years ago

@jaroslawp 👍 But cpp doesn't like the --include option with two dashes. Using one dash works.

$ cpp -help
...
  -include <file>         Include file before parsing
...
$ make && sudo make install
gcc -fPIC -O2 -g -pipe -Wall -DMATTERMOST_PLUGIN_VERSION='"1.1.2017.07.09.git.3216bfd"' -I/opt/local/include -shared -o libmattermost.so libmattermost.c -lz  `pkg-config purple glib-2.0 json-glib-1.0 --libs --cflags` -Ipurple2compat -g -ggdb -lmarkdown
mkdir -p `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/16
mkdir -p `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/22
mkdir -p `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/48
install mattermost16.png `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/16/mattermost.png
install mattermost22.png `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/22/mattermost.png
install mattermost48.png `pkg-config --variable=datadir purple`/pixmaps/pidgin/protocols/48/mattermost.png
mkdir -p `pkg-config --variable=plugindir purple`
install -p libmattermost.so `pkg-config --variable=plugindir purple`
jaroslawp commented 7 years ago

yeah, indeed, single dash should be used. OK, created #59 , Thanks !

barthel commented 7 years ago

Maybe @tripplet (https://github.com/tripplet) could help out to create a Adium plugin?

tripplet commented 7 years ago

I'll look into it, should be doable (no promises 😉)

papertigers commented 7 years ago

@tripplet is adium-mattermost in a working state yet by any chance?

tripplet commented 7 years ago

Sadly no, I created the project and prepared everything for the adium wrapper: https://github.com/tripplet/adium-mattermost, it is recognized by adium but I was not able to connect it to a preview instance of mattermost (I used this docker container). I not sure why, there were some errors during connect and there seems to be debugging necessary, also I hard coded the connection details in my local version as there is additional work to be done to bridge over settings from adium to the libpurple side. Currently I only have the time to continue debugging on it occasionally on weekends (also it's summer vacation time), so if this only depends on my shoulders don't expect a working version in the next months 😫. Pull requests are welcome 😉