Wednesday, May 30, 2012

Using GoogleDocs as Team editor for Latex-files

We wrote our last project paper using Latex which creates very nice looking documents, but is absolutely painful to work in teams. Even using a code management system like SVN/GIT won't make it really comfortable as you don't have comments and see changes of other editors live.

So, we put our Latex document in GoogleDocs (simply copied the content into a New GDocs Text Document) and shared it with our team. We also formatted the document by applying GDocs styles to our Latex headings, so the text looks structured and easier to work with.

At first we simply copied the GDocs content to a local file and compiled it. In fact, the copy-and-paste task is really annoying and so we developed a small bash script that automatically downloads the latest GDocs version and compiles it locally. So, in any case you need to setup your latex tools correctly, but don't waste your time in the compilation step.

You only need to enable sharing by URL and from this URL copy the document id, which you need to download the file.

Here is the script:

wget -O soups-article.download "https://docs.google.com/document/export?format=txt&id=PLACE_YOUR_ID_HERE" && \
iconv -c --from-code=UTF-8 --to-code=ISO-8859-1 soups-article.download | sed 's/end{document}*/end{document}/' > myFile.tex && \
pdflatex myFile && \
evince soups-article.pdf &

Asterisk and MessageSend

We are using Asterisk (running on FreeBSD 9.0 port stock version: 10.0.0-rc2) as SIP registrar/proxy. We are using the Android softphone cSipSimple, which also provides SIP SIMPLE messaging functionality. To enable this on Asterisk add to sip.conf: accept_outofcallmessage=yes and outofcall_message=message (the name of the context handler).


However, we had some trouble setting up Asterisk to really do it. In the message-ctx Asterisk provides the information of the current message as variables/function: MESSAGE(to), MESSAGE(from) and MESSAGE(body).

(First problem)
The first problem is that MESSAGE(to) contains the complete address, e.g. sip:PHONENUMBER@SERVERIP. If you try to use this address asterisk sends the message to itself and complains on receive that their is no routing for the incoming message. So, we need to remove the @IP part using the CUT command from the TO and the FROM. Now we can send a message from one phone to another: MESSAGESEND(CUTED_TO, CUTED_FROM).
(Second probleme)
However, we cannot reply as the recipient got as sender address something like sip:UNKNOWN@SERVERIP.
In short use MESSAGESEND(CUTED_TO, CUTED_FROM <CUTED_FROM>) or as example MESSAGESEND(sip:1, SOMEBODY <1>). The first part of the FROM is the name shown to the user and the second part the reply to phone number (without sip:).


Here is our working context for messaging of the extensions.conf:

[message]

exten => _X.,1,Set(TO=${CUT(MESSAGE(to),@,1)})

exten => _X.,n,Set(FROM=${CUT(MESSAGE(from),:,2)})

exten => _X.,n,Set(FROM_PHONE_NUMBER=${CUT(FROM,@,1)})
 exten => _X.,n,MessageSend(${TO}, ${FROM_PHONE_NUMBER}<${FROM_PHONE_NUMBER}>) 
 ;DEBUG Print the status of the MessageSend
exten => _X.,n,Verbose(0, ${TO} ${MESSAGE(from)} ${FROM} ${MESSAGE_SEND_STATUS}) 

Thanks to Nicolas.