loqui / im

Loqui IM allows you to use all your chat accounts in just one FirefoxOS or Ubuntu Touch app.
https://loqui.im
304 stars 112 forks source link

Port Loqui to Cordova #944

Open TitanNano opened 8 years ago

TitanNano commented 8 years ago

Hello Everyone,

Firefox OS is dying and by now it's not clear what's going to happen with it in the future. It might become a community driven project under a new name, but who knows....

So my idea is to continue our project by shifting our main platform to Cordova which will alow us to run our Application on Android and iOS. There is a plugin to use the chrome.socket.tcp API and we would just need to write a shim to translate it to the TCPSocket API from Mozilla so CoSeMe could use it.

Of course we also need to wrap some other APIs, but the TCP socket would be our main problem. An other issue we would be facing is that we need to make our CSS work with WebKit and Blink.

I'd be happy about some feedback, anyone interested to continue the project like this?

cmeerw commented 8 years ago

The main issue I am seeing is that CoSeMe still doesn't support end-to-end encryption and that's going to be a big problem in the very near future. There is a real risk that CoSeMe will stop working by the time any progress has been made on porting it to Cordova. (And if CoSeMe gains encryption support there is a risk that Facebook won't like the competition on the other platforms where there is an official WhatsApp client).

TitanNano commented 8 years ago

yes I'm aware of that. But were still providing a fine XMPP client for Mobile Phones, aren't we? So even if we need to drop WhatsApp support, it could be worth to continue the project?

03927e9c commented 8 years ago

The only reason I use Loqui is beause I can use Firefox OS. I don't mess with Android or any other OS. Just my 2 cents.

TitanNano commented 8 years ago

@03927e9c do you have any plans which OS you are going to use after Mozilla finally killed FxOS?

cmeerw commented 8 years ago

ok, so axolotl support seems to be possible in JavaScript... (as mentioned in #659)

Honk2 commented 8 years ago

Yes, the official support for FirefosOS will end soon. But I still like it and am willing to use it as long as possible. If it can be avoided, I will not use Android/Windowes or iOS, ever. The only reason for me to use loqui is the WhatsApp support. Most people, and this includes also my family and friends, are using WhatsApp. Does anyone know how may users use loqui for another messenger than WhatsApp? And of cause, cmeerw it right, Facebook will not accept any competition on platforms, supported by themself. Therefore it is not a good idea to shift to cordova, in my opinion. Loqui is a great WhatsApp client and I think on mid and long term, it can only survive on platforms that lack an official WhatsApp client while giving these platforms a boost, because there is a good WhatsApp client available.. So my whish is to continue with loqui and implement encryption, maybe my next phone will be UbuntuTouch, which is allready supported by loqui (according to the build output). Maybe also Sailfish could be supported to get another community involved? If you did not notice yet: WhatsApp announced to drop support for several platforms by end of 2016. Maybe this is the deadline until when encryption is needed.

03927e9c commented 8 years ago

ill use pidgin

cmeerw commented 8 years ago

BTW, I only had to make a few JavaScript changes to get Loqui to run in Chrome today (well, no TCP sockets so far, so only managed to configure a XMPP account via a WebSocket connection - but was able to send and receive XMPP messages).

For Chrome it will need to be packaged as a Chrome App to be able to access the TCP socket API.

I am not sure if Ubuntu or Tizen provide any raw socket API at all - and I am not sure how similar the rendering engines of Ubuntu and Tizen are to Chrome...

Gioyik commented 8 years ago

@cmeerw Ubuntu use the render provided by Qt, if I am not wrong it is Webkit, but don't trust on me.

Do you have an email? I would like to talk a few things with you :)

cmeerw commented 8 years ago

@Gioyik I believe Qt actually switched to Blink (same as Chrome/Chromium).

My email is cmeerw@cmeerw.org

cmeerw commented 8 years ago

I have added Chrome as a new target... So far text messages in WhatsApp (with encryption support) seem to work reasonably well. Unfortunately, STARTTLS for XMPP connections is even more broken in Chrome than in Firefox. User interface appears to be mostly fine in Chrome...

cmeerw commented 8 years ago

Just added a cordova target to the build, in dist/cordova you can then do

cordova platform add ubuntu
cordova run ubuntu

to run the basic application (but as usual, only XMPP via WebSockets works for now).

So I guess we will just need a few plugins to access some native facilities (like raw TCP sockets).

cmeerw commented 7 years ago

Ok, so I have added some support to fallback to a WebSocket proxy if there is no raw TCP socket support (like on Ubuntu Touch). But this means, that a small WebSocket proxy server is needed - I have made on at http://svn.cmeerw.net/src/nginetd/trunk/ , you just need to build wssrv-tcp and then (on Ubuntu) launch the webapp-container via wssrv-tcp:

wssrv-tcp -d -b 127.0.0.1 -- webapp-container --app-id=loqui.im --user-agent-string="WhatsApp/2.16.9 S40Version/14.26 Device/Nokia302" www/index.html

This should give you some very basic (but working) WhatsApp on Ubuntu (except that you don't have any contacts, but you can receive messages and respond)...

nfsprodriver commented 7 years ago

How do I build wssrv-tcp?

cmeerw commented 7 years ago

make wssrv-tcp

nfsprodriver commented 7 years ago

I just tried. udns.h seems to be missing...

cmeerw commented 7 years ago

Can you just install libudns-dev ?

nfsprodriver commented 7 years ago

Ah, thanks! I thought it's missing in the directory. I'll try to resolve the dependencies...

nfsprodriver commented 7 years ago

Well, I got around with this and when I try to start the app, it closes instantly and via terminal/ssh I get this output:

wssrv-tcp -d -b bananapim2:443 -- webapp-container --app-id=loqui.im --user-agent-string="WhatsApp/2.16.10 S40Version/14.26 Device/Nokia302" www/index.html

[Async_Worker] starting epoll_wait tid=3063501888 [Async_Worker] done epoll_wait tid=3063501888 [Async_Worker] got event 4, operation=16, data=0xbefd6054 [Async_Resolver] on_send [Async_Resolver] process timeout=-1 [Async_Worker] starting epoll_wait tid=3063501888 Loading module: 'libubuntu_application_api_touch_mirclient.so.3.0.0' UbuntuClientIntegration: connection to Mir server failed. Check that a Mir server is running, and the correct socket is being used and is accessible. The shell may have rejected the incoming connection, so check its log file [Async_Handler] posted CANCEL for worker threads [Async_Worker] done epoll_wait tid=3063501888 [Async_Worker] got event 16, operation=1, data=0x3c590 [Async_Handler] all worker threads have terminated So I know about the trouble launching apps via terminal/ssh on Ubuntu Touch, but what WebSocket server/port should I choose?
cmeerw commented 7 years ago

As mentioned in my previous comment -b 127.0.0.1 should work (which will use port 8080 - as that's currently hardcoded on the Javascript side).

nfsprodriver commented 7 years ago

At my Linux Mint 18 64bit it's working (except the decrypt errors). On my Ubuntu Phone it doesn't. Previously I had problems by getting some libs, which are available since xenial only so I used the serveral files for the vivid based phone. Maybe that's incompatible.

nfsprodriver commented 7 years ago

So my question: How can I make the wssrv-tcp tool make the LoquiIM webapp running under Ubuntu Touch?

nfsprodriver commented 7 years ago

Okay, finally got it running. Yay!!! But I've got nearly no fuctionallity: The messages are decrypted and I can't do effective actions. :(

nfsprodriver commented 7 years ago

Package with instructions can be downloaded from here: https://github.com/nfsprodriver/im/releases/download/v0.5.9/LoquiIM-Ubuntu-Touch.zip

SanderKlootwijk commented 7 years ago

Hi nfsprovider, I would like to test LoquiIM on Ubuntu Touch, but when you enable read-write mode and just edit the LoquiIM files, will the OTA-Updates still be available?

nfsprodriver commented 7 years ago

The one thing has nothing to do with the other thing so, yes. But be warned working in a writable root filesystem. By the way, after reboot the filesystem is read only again. After OTA-Updates you may do the steps again because some changes will be overwritten or removed during an update.

gabriel-lucas commented 7 years ago

Hello @nfsprodriver I followed your steps and managed to get Loqui installed in my Ubuntu phone but I´m facing and issue.

When I try to register my mobile phone I get the SMS with the code correctly but it get stuck verifying the mobile phone and code numbers. I managed to run it from the adb shell so I can get the trace log:

These are the two messages that look important: Refused to set unsafe header "User-Agent" {"status":"fail","reason":"missing"}

I checked this website but no luck. https://github.com/mgp25/Chat-API/wiki/WhatsApp-Registration-Flow

qml: JS Request: https://v.whatsapp.net/v2/register?cc=XX&in=XXXXXXXX&code=XX&id=XXXXX ~ at Logger.CoSeMe.namespace.Logger.log (file:///opt/click.ubuntu.com/com.ubuntu.loqui.im.loqui/0.5.9/www/scripts/mozillahispano/coseme.js:3477:10) [http] qml: JS Refused to set unsafe header "User-Agent"

qml: JS {"status":"fail","reason":"missing"} ~ at Logger.CoSeMe.namespace.Logger.log (file:///opt/click.ubuntu.com/com.ubuntu.loqui.im.loqui/0.5.9/www/scripts/mozillahispano/coseme.js:3477:10) [http]

The personal data has been replaced with XXXX

@aesedepece ¿me ayudas con esto?

nfsprodriver commented 7 years ago

Have you launched it with the right User Agent? It must be the ...2.16.10... one.

gabriel-lucas commented 7 years ago

hi @nfsprodriver thanks for your answer!

I take the user agent from whatsapp file. --user-agent-string="WhatsApp/2.16.10 S40Version/14.26 Device/Nokia302"

is this correct?

SanderKlootwijk commented 7 years ago

Hi,

Here is a small list of my experiences so far. I've tested a Whatsapp account on Ubuntu Touch and the following things work:

What doesn't work:

Also the other account types like Facebook and Hangouts doesn't work.

nfsprodriver commented 7 years ago

Seems you got more things working than me. Have you done anything different?

nfsprodriver commented 7 years ago

@gabriel-lucas Yes it should be ;)

gabriel-lucas commented 7 years ago

No idea why it fails. Neither, opening it from terminal through adb shell or directly from the Loqui icon works.

Do you know any way I can debug or search for a solution to this?

cheers!

nfsprodriver commented 7 years ago

What I can say now is to use the whatsapp file to launch the app. Be sure you've loaded the wssrv-tcp into the /bin/ directory, made it executable (sudo chmod +x) and installed all necessary dependencies (-> instructions).

gabriel-lucas commented 7 years ago

ls -l /bin/wssrv-tcp -rwxr-xr-x 1 root root 2908776 Oct 18 00:03 /bin/wssrv-tcp


$sudo apt-get install libudns-dev Reading package lists... Done Building dependency tree
Reading state information... Done libudns-dev is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


ls -l /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 lrwxrwxrwx 1 root root 19 Aug 20 2014 /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 -> libstdc++.so.6.0.20


ls -l whatsapp -rwxrwxr-x 1 phablet phablet 263 Oct 18 16:28 whatsapp


cat whatsapp wssrv-tcp -d -b 127.0.0.1 -- webapp-container --app-id=loqui.im --user-agent-string="WhatsApp/2.16.10 S40Version/14.26 Device/Nokia302" /opt/click.ubuntu.com/com.ubuntu.loqui.im.loqui/0.5.9/www/index.html --store-session-cookies --desktop_file_hint=/usr/share/applications/webbrowser-app.desktop


The problem is registering, could it be that the account might be blocked or something similar?

SanderKlootwijk commented 7 years ago

@nfsprodriver I guess that you haven't found out yet how to open the menu. It's a bit buggy but I can open it by following the next steps:

The menu will slide-in from the left side of the screen. Here you can access your (profile) settings and accounts.

nfsprodriver commented 7 years ago

Great, thanks!!!

cmeerw commented 7 years ago

BTW, just swiping right should work.

SanderKlootwijk commented 7 years ago

@cmeerw Swiping right doesn't seem to work on Ubuntu Touch ;(

nfsprodriver commented 7 years ago

@cmeerw Can you integrate all dependencies into wssrv-tcp like udnv and libstdc++ to make the installation as easy as possible?

cmeerw commented 7 years ago

@nfsprodriver I am surprised that there isn't a system libstdc++ available... Surely anything using Qt must also depend on libstdc++... Even if there isn't a system one, the so file can probably be packaged with the wssrv-tcp... It's just a bit difficult to find the best solution without having a device myself...

nfsprodriver commented 7 years ago

The thing is, I compile it on a Bananapi Ubuntu 16.04 arm with all the dependencies and use the compiled file in Ubuntu Touch, where I need to install libudns-dev and libstdc++. Second one isn't available for arm 15.04, so I use the 16.04 one from the Bananapi.

pharaone commented 7 years ago

Thanks for the Ubuntu touch port, I love it!

cmeerw commented 7 years ago

But please do not publish it as something for end users, it's not ready yet as can be seen by #1156 - please work on fixing it first!

TronFortyTwo commented 7 years ago

I'm not a developer of this program but I'd like to write something here. First of all I want to thank you all for all your work. I think is a good think to port it to Ubuntu Touch, and i found publish the app in the Open Store a good solution to open the app to developers and enthusiasts even if is a heavy work in progress.

cmeerw commented 7 years ago

Some design discussion points I hope to get some feedback from Ubuntu Touch devs:

Main problem is that LoquiIM needs some non-standard APIs, with the most important one being opening TCP connections - I think the others are then access to the phone address book and ability to read/write files on the local filesystem (oh, and some way to prevent the CPU from going back to sleep when it shouldn't)

Question is what is the best (and easiest) way to make these APIs available on Ubuntu Touch? For the moment I have written a simple WebSocket server that can be started on the device and that translates from a WebSocket connection to a plain TCP connection.

One other option could be Cordova, but I am not entirely sure yet how well that really is supported on Ubuntu Touch (it definitely doesn't have a TCP plugin) and I have issues with their plugin API which seems to essentially pass Javascript code as strings around that then gets executed - this seems like a disaster waiting to happen and is probably not ideal for something like TCP sockets or files where significant amounts of data can be transferred.

Is there any other way to access native APIs from HTML5 apps? Maybe something that provides a sane plugin interface? (yes, I really dislike Cordova)

So what would be the recommended way to solve this? Are there any existing examples of HTML5 web apps on Ubuntu Touch that need some native API access?

TronFortyTwo commented 7 years ago

I made some research and Ubuntu Touch seem supports Cordova, but about TCP I haven't found any documentation...

pharaone commented 7 years ago

This https://cordova.apache.org/docs/en/latest/guide/platforms/ubuntu/index.html can help you?

cmeerw commented 7 years ago

I am aware that there is some support of Cordova for Ubuntu Touch, but what level is that support and who is behind it (and is it the best technical solution)? (after all, LoquiIM is in the Ubuntu Open Store, but does that mean it's fully working and supported? No.)

sap-nocops commented 7 years ago

Hi, I'm an ubuntu touch user and a developer also. I'd really love to have this app on ubuntu and I'd love to help. Let me know if I can help somehow with testing and coding