Compare commits

..

7 commits

Author SHA1 Message Date
mj
94dd3be54f Merge pull request #423 from TiagoDanin-Forks/README
README: Fix Markdown
2017-10-17 07:52:34 +02:00
Tiago Danin
0e0958753c README: Fix Markdown 2017-10-15 19:01:24 -03:00
mj
5876c98f8a Merge pull request #422 from unansweredocd/add-remove-session-in-faq
Add remove old session info to README
2017-10-15 21:23:31 +02:00
Sam Form
d286c1f338 use the more common purple directory 2017-10-15 20:52:24 +02:00
Sam Form
a54c4e7dd2 add info on how to clean the telegram-purple directory to deal with revoked sessions 2017-10-15 20:07:03 +02:00
Ben Wiederhake
7aa6874074 Update nsi file to reflect changes in po/LINGUAS 2017-04-10 22:54:08 +02:00
Ben Wiederhake
065e0b7ac9 Silence warnings about bad .po files
Sadly, Transifex doesn't seem to acknowledge that the generated files
are bad.  Also, I don't want to introduce any infrastructure to
fix the files every time after I download them.
So they stay broken, and the warnings must be silenced.
Sadly, this means that future warnings will get ignored, too.
Let's hope this won't go too bad.
2017-04-10 22:17:54 +02:00
41 changed files with 462 additions and 732 deletions

View file

@ -14,9 +14,6 @@ script:
- ./configure $CONFIGURE_FLAGS
- make -j2
- make check
# Test both installation routines:
- sudo make install
- make local_install
compiler:
- clang
- gcc

View file

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
#
# Copyright Matthias Jentsch, Vitaly Valtman, Christopher Althaus, Markus Endres 2014-2017
# Copyright Matthias Jentsch, Vitaly Valtman, Christopher Althaus, Markus Endres 2014-2015
srcdir=@srcdir@
prefix=@prefix@
@ -22,14 +22,8 @@ datarootdir=@datarootdir@
localedir=@localedir@
gettext_package=@GETTEXT_PACKAGE@
CFLAGS_INTL=-DENABLE_NLS -DLOCALEDIR='"$(localedir)"'
CFLAGS_WARN=-Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter
CFLAGS_EXTRA=-I${srcdir} -I. -fno-strict-aliasing -fPIC -D_FORTIFY_SOURCE=2
CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ @DEFS@ ${CFLAGS_INTL} ${CFLAGS_WARN} ${CFLAGS_EXTRA}
LDFLAGS_EXTRA=-rdynamic -ggdb
LDFLAGS=@LDFLAGS@ @OPENSSL_LIBS@ @PURPLE_LIBS@ @LIBS@ ${LDFLAGS_EXTRA}
CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ @DEFS@ -DENABLE_NLS -DLOCALEDIR='"$(localedir)"' -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC -D_FORTIFY_SOURCE=2
LDFLAGS=@LDFLAGS@ @OPENSSL_LIBS@ @PURPLE_LIBS@ @LIBS@ -rdynamic -ggdb
DIR_PERM=0755
FILE_PERM=0644
@ -127,6 +121,7 @@ noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS)
mkdir -m $(DIR_PERM) -p $(DESTDIR)$(PLUGIN_DIR_PURPLE)
install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
mkdir -m $(DIR_PERM) -p $(DESTDIR)/etc/telegram-purple
install -m $(FILE_PERM) tg-server.tglpub $(DESTDIR)/etc/telegram-purple/server.tglpub
# Assume that the user does not use AppStream if she doesn't want icons
@for lang in $(LOCALES); do \
mkdir -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
@ -138,7 +133,7 @@ noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS)
noicon_uninstall:
rm -f $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
rm -f $(DESTDIR)/etc/telegram-purple/server.pub # TODO: Remove this in later versions
rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub # TODO: Remove this in later versions
rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub
# TODO: Delete all installed .mo's, no matter what LINGUAS says.
@for lang in $(LOCALES); do \
echo "removing $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
@ -173,11 +168,14 @@ uninstall: noicon_uninstall
local_install:
mkdir -m $(DIR_PERM) -p $(DESTDIR)$(HOME)/.purple/plugins
install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(HOME)/.purple/plugins/$(PRPL_NAME)
# See telegram-base.c, function get_user_pk_path for justification:
mkdir -m $(DIR_PERM) -p $(DESTDIR)$(HOME)/.purple/telegram-purple
install -m $(FILE_PERM) tg-server.tglpub $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub
.PHONY: local_uninstall
local_uninstall:
rm -f $(DESTDIR)$(HOME)/.purple/plugins/$(PRPL_NAME)
rm -f $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub # TODO: Remove this in later versions
rm -f $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub
### == Handling and maintenance. Subject to rapid change, shouldn't be used in scripts. == ###
@ -190,9 +188,7 @@ strip: $(PRPL_LIBNAME)
$(STRIP) --strip-unneeded $(PRPL_LIBNAME)
.PHONY: build-nsi
build-nsi: telegram-purple.nsi
telegram-purple.nsi: telegram-purple.nsi.awk telegram-purple.nsi.awk-in po/LINGUAS
build-nsi: telegram-purple.nsi.awk telegram-purple.nsi.awk-in
awk -f telegram-purple.nsi.awk telegram-purple.nsi.awk-in > telegram-purple.nsi
.PHONY: run

View file

@ -106,6 +106,7 @@ strip: $(PRPL_LIBNAME)
install: $(PRPL_LIBNAME) $(LOCALES)
mkdir -m $(DIR_PERM) -p $(PLUGIN_DIR_PURPLE)
install -m $(FILE_PERM) $(PRPL_LIBNAME) $(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
install -m $(FILE_PERM) tg-server.tglpub $(DATA_ROOT_DIR_PURPLE)/server.tglpub
ifeq ($(COPY_ICONS),no)
@echo "Not copying icons due to configure-option --disable-icons."
@echo " If you're using Finch, Empathy, or Telepathy, then this is a good idea."

View file

@ -3,7 +3,7 @@ Telegram-Purple Unofficial (Beta)
Telegram-purple is a Libpurple protocol plugin that adds support for the Telegram messenger.
I keep getting many questions about this plugin in my E-mail, so I've created a [telegram group chat] (https://goo.gl/VudXys) for
I keep getting many questions about this plugin in my E-mail, so I've created a [telegram group chat](https://goo.gl/VudXys) for
telegram-purple related discussions or questions.
Installation
@ -41,8 +41,10 @@ https://aur.archlinux.org/packages/telegram-purple/
#### Debian
You can build it from source (see following section) or build a `.deb` file
for your package manager.
At the time of writing, the package hasn't been accepted yet.
Please first check if it's already available to you: `sudo apt-get install telegram-purple`
If this doesn't work because the package doesn't exist (yet), please build it from source.
Building From Source
@ -83,6 +85,12 @@ this indicates that this version is in fact much further than just
##### Debian / Ubuntu
We are working on a Debian package! Please first check if it's already available to you: `sudo apt-get install telegram-purple`
If the above works, then you should stop here: It is now installed.
If the above fails: Don't worry, just continue building it by yourself. Next you need to install these dependencies:
sudo apt-get install libgcrypt20-dev libpurple-dev libwebp-dev gettext build-essential
@ -215,16 +223,17 @@ Building the Debian Package
If you just need a `.deb`, simply do:
sudo apt-get install debhelper
git checkout debian-master
git submodule update --recursive
fakeroot ./debian/rules binary
And you're done! The `telegram-purple_….deb` and `telegram-purple-dbgsym_….deb` files
are in the parent directory.
And you're done! The `.deb` is in the directory at which you started.
To show some info about it, try this:
dpkg --info telegram-purple_*.deb
Please note that installing the debugging symbols (`dbgsym`)
help a lot in troubleshooting, so please do install them, too!
`debian-master` always points to a version that was submitted to Debian. (Note that this doesn't exist yet, as we haven't released to Debian yet.)
`debian-develop` is the candidate for the next submission.
#### Debian Maintainers ####
@ -235,15 +244,16 @@ Here's how you can generate a `.orig.tar.gz`:
make dist
The following command requires the original tar to exist,
and will build all further files,
Note that these are incompatible with the old `debian/genorigtar.sh`
tarballs, and can't be made compatible easily. If you need the tarball
from "back then", see the documentation there.
This command requires the original tar to exist (and will fail otherwise,
although the error message will be misleading) will build all further files,
specifically `.debian.tar.xz`, `.dsc`, `.deb`, and `.changes`:
dpkg-buildpackage
If this fails with a cryptic error message,
first make sure that the `….orig.tar` really is in place.
For the upload, you should use `pbuilder` and similar to build the package
in a more minimalistic environment. That covers the official part of the work-flow.
@ -255,8 +265,6 @@ and `.dsc` files, do this:
false # Move tar to parent directory, by hand
dpkg-source -b .
Note that we no longer actively try to get it into the Debian repository.
Discussion / Help
-----------------
@ -265,11 +273,15 @@ Discussion / Help
As we want to avoid OpenSSL, it has become necessary to replace the PEM file format. This means that if you use a custom pubkey (which you really REALLY shouldn't be doing), you have to adapt, sorry.
We no longer read the public key of the Telegram servers from a file.
If you really need a different public key, and know what you're doing
(e.g., connecting to some kind of test environment internal to Telegram,
which also is a very bad idea), you need to find the call to `tgl_set_rsa_key_direct` in `telegram-purple.c`,
and provide the key directly by yourself.
We no longer ship `tg-server.pub` (old format), but instead `tg-server.tglpub` (new format). If you have a `.pub` and want to continue using telegram-purple, please use this (hopefully highly portable) tool: [pem2bignum](https://github.com/BenWiederhake/pem2bignum)
You can also write your own conversion tool if you prefer. The format is really simple:
1. `e`, the public exponent, encoded as big endian 32 bit fixed length (e.g. `0x00 01 00 01` for 65537)
2. `n_len`, the length of `n` in bytes, encoded as big endian 32 bit fixed length (e.g. `0x00 00 01 00` for a 2048-bit = 256-byte key)
3. `n_raw`, the raw modulus, encoded as big endian, using the previously indicated length (e.g. `0xC1 50 02 3E [248 bytes omitted] 21 79 25 1F` in the case of telegram's public RSA key.)
If you are interested in developing a non-OpenSSL-licensed converter, look into [insane-triangle-banana](https://github.com/BenWiederhake/insane-triangle-banana).
FAQ
@ -278,6 +290,15 @@ FAQ
- I receive pictures in a chat, but they aren't showing up
* A: Make sure that you don't have a plugin like "Conversation Colors" that strips HTML from messages and removes the pictures.
- I receive RPC_CALL_FAIL_401: SESSION REVOKED
* A: This basically means your session has been terminated but the program
doesn't handle terminated sessions properly yet. You have to clean the
~/.purple/telegram-purple/$PHONENUMBER directory to fix this issue.
For Arch Linux users that use Bitlbee you can find this directory in
`/var/lib/bitlbee/purple/telegram-purple/`
#### Group chat
Telegram group chat for telegram-purple or libtgl related discussions or questions:

View file

@ -24,7 +24,8 @@
/* Define to 1 if you have `z' library (-lz) */
#undef HAVE_LIBZ
/* Define to 1 if you have the `malloc' function. */
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
@ -90,5 +91,8 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

71
configure vendored
View file

@ -620,11 +620,11 @@ ac_includes_default="\
#endif"
ac_subst_vars='LTLIBOBJS
LIBOBJS
GETTEXT_PACKAGE
MSGFMT_PATH
CHECK_GETTEXT
PURPLE_CPPFLAGS
LIBOBJS
PURPLE_LIBS
PURPLE_CFLAGS
PKG_CONFIG_LIBDIR
@ -4444,7 +4444,74 @@ fi
# Checks for library functions.
for ac_func in malloc memset strdup
for ac_header in stdlib.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
if test "x$ac_cv_header_stdlib_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STDLIB_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
if ${ac_cv_func_malloc_0_nonnull+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_func_malloc_0_nonnull=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if defined STDC_HEADERS || defined HAVE_STDLIB_H
# include <stdlib.h>
#else
char *malloc ();
#endif
int
main ()
{
return ! malloc (0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_func_malloc_0_nonnull=yes
else
ac_cv_func_malloc_0_nonnull=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
if test $ac_cv_func_malloc_0_nonnull = yes; then :
$as_echo "#define HAVE_MALLOC 1" >>confdefs.h
else
$as_echo "#define HAVE_MALLOC 0" >>confdefs.h
case " $LIBOBJS " in
*" malloc.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS malloc.$ac_objext"
;;
esac
$as_echo "#define malloc rpl_malloc" >>confdefs.h
fi
for ac_func in memset strdup
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View file

@ -75,7 +75,8 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([malloc memset strdup])
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset strdup])
AC_SUBST(PURPLE_CFLAGS)
AC_SUBST(PURPLE_CPPFLAGS)

8
debian/.gitignore vendored
View file

@ -1,8 +0,0 @@
/files
/telegram-purple/
/telegram-purple.*
/.debhelper/
/autoreconf.after
/autoreconf.before
/debhelper-build-stamp

121
debian/README.source vendored
View file

@ -1,121 +0,0 @@
Packing, unpacking, and modifying (as per §4.14)
================================================
1. Generate the fully patched source, in a form ready for editing, that
would be built to create Debian packages.
This step does not need any special attention. The standard invocation
of "dpkg-source -x" does exactly what is needed.
2. Modify the source and save those modifications so that they will be
applied when building the package.
== AND ==
3. Remove source modifications that are currently being applied when
building the package.
There is no standard procedure for this package. Please note that:
- quilt seems to be the default tool for this kind of work.
- git-buildpackage (gbp) might not work as expected, so I refrained
from trying it for this task. See below.
So far, issues reported against the project have been resolved quickly
enough to avoid scenarios that usually need the d/patches/ directory.
4. Generate a *.orig.tar.gz from the git repository, e.g., upgrade the
Debian source package to a new upstream version.
Easy way:
use the provided orig-tars, e.g., 'telegram-purple_1.2.6.orig.tar.gz'
Hard way (the procedure used to create these files):
$ git clone --recursive --branch debian-master \
https://github.com/majn/telegram-purple.git
$ cd telegram-purple
...$ make dist
The output should look like this:
Refresh commit.h
./gen-origtar
mv -f bin/result.tar.gz telegram-purple_deb-v1.2.4-2-161-gb5272d4.orig.tar.gz
The following approaches do NOT work:
- Github's "download source tar", as this leaves out submodules.
- git-buildpackage (gpb). No support for submodules-within-submodules.
The file README.md of the project contains some hints about how to
build packages, so here's a cheat sheet:
- Just build a *.deb, ideal for local use:
fakeroot ./debian/rules binary
- Build the package for analysis, e.g. lintian:
dpkg-buildpackage
- Only produce a *.dsc and *.debian.tar.xz file:
( cd .. && dpkg-source -b telegram-purple )
- Run pbuilder (needs the previous step):
( cd .. && sudo pbuilder --build telegram-purple_*.dsc )
Package name
============
At the time of writing (2016-01-03), the Debian repository contained
the following libpurple-backends:
- pidgin-encryption
- pidgin-latex
- pidgin-otr
- pidgin-plugin-pack
- pidgin-privacy-please
So following that tradition, this package would be called "pidgin-telegram".
However, this would have a lot of disadvantages:
- This is a frontend-agnostic backend that works with Adium, pidgin,
and Finch. We hope that it works nicely with all other frontends, too.
Calling it "pidgin-something" would be highly misleading.
- All error messages and their translations would need to be adapted
- paths would need to change that aren't configurable
- some users are expecting the name to be "telegram-purple"
(at least initially)
Overall, we consider this a needlessly confusing convention, and
intentionally break with it.
Packaging libtgl separately (as per §4.13)
==========================================
No.
So far, ABI-compatibility was broken between virtually every other
commit to libtgl, and the library is still under development. The
latest "stable" release is heavily outdated and can no longer be used
productively (missing features, known breaking bugs, etc.), so if we were to
package tgl we would need to repackage it constantly, with no defined
concept of version, soname, or anything reliable. No other program
(*including* tg-cli) can be expected to use the same version of libtgl
as telegram-purple does. (This might happen every now and then, but
that would be random chance. Finally, it's highly unlikely that someone
installs and uses both telegram-purple and tg-cli.)
Packaging "tl-parser" or the intermediate "generate" program is also a
bad idea: One *could* do that, but it's only useful for libtgl. So
there is a significant lack of users.
Note that tl-parser is a relatively (in comparison to the rest of
libtgl) stable, portable application (not library). The output format
hasn't changed in a over a year. If you believe that these six files
will be used by a lot of people, I'll be happy to package tl-parser for
you. However, please note that this would require at least two
packages: tl-parser (binary), tl-parser-dev (headers), and possibly
libtl-parser (common object files).
In short: there's no set of component that could be packaged in a more
clever way.
About this document
===================
This is not written in Markdown. All formatting is in the hope of
making it easy to read.

27
debian/changelog vendored
View file

@ -1,27 +0,0 @@
telegram-purple (1.3.1-1) UNRELEASED; urgency=medium
* New upstream release
* No longer actively try to push it into Debian: too unstable.
If you really want a .deb file, see README.md in the toplevel directory.
-- Ben Wiederhake <Ben.Wiederhake@gmail.com> Mon, 10 Apr 2017 23:31:32 +0200
telegram-purple (1.3.0-1) unstable; urgency=medium
[ Hugues Morisset ]
* Initial Release (Closes: #833793)
[ Ben Wiederhake ]
* Please note that due to the format-switch in 1.2.6, the file
/etc/telegram-purple/server.pub is obsolete for all version after it.
It is ignored to allow for smooth transition from old, manual
installations, and may be removed in future versions.
* New upstream release
- Add translations and plural support
- Fix lots of bugs around secret chats (still not perfect, though)
- Fix behavior around hibernation
- Fix display errors and false warnings
- Fix crash on 'unsupported' media
- Support supergroups and channels
-- Ben Wiederhake <Ben.Wiederhake@gmail.com> Mon, 22 Aug 2016 20:59:47 +0200

1
debian/compat vendored
View file

@ -1 +0,0 @@
9

42
debian/control vendored
View file

@ -1,42 +0,0 @@
Source: telegram-purple
Section: net
Priority: optional
Maintainer: Ben Wiederhake <Ben.Wiederhake@gmail.com>
Uploaders:
Hugues Morisset <morisset.hugues@gmail.com>
Build-Depends:
autotools-dev,
debhelper (>= 9),
dh-autoreconf,
libgcrypt20-dev,
libglib2.0-dev,
libpurple-dev,
libwebp-dev,
pkg-config,
zlib1g-dev
Standards-Version: 3.9.8
Homepage: https://github.com/majn/telegram-purple
Vcs-Git: https://github.com/majn/telegram-purple.git
Vcs-Browser: https://github.com/majn/telegram-purple
Package: telegram-purple
Architecture: any
Depends:
${misc:Depends},
${shlibs:Depends}
Suggests:
pidgin | finch
Description: Purple plugin to support Telegram
Plugin for purple which lets you use and manage your Telegram account
like any other account in purple. Some features like self-destruct
messages are currently in development.
X-Comment: Traditionally, this plugin should be named "telegram-pidgin".
However, this plugin is also designed to work with at least Adium,
Finch, and hopefully all other libpurple-frontends, so this name would
be highly misleading. Furthermore, the plugin refers to itself as
"telegram-purple", and changing this (e.g. via a patch) would be highly
non-trivial and fragile. Finally, several users know this plugin under
the name telegram-purple only, so naming the Debian package differently
would be another source of confusion. Thus we intentionally break with
this tradition, and re-used the name telegram-purple from the original
project.

102
debian/copyright vendored
View file

@ -1,102 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pidgin-telegram
Source: https://github.com/majn/telegram-purple
Files: *
Copyright: 2014-2015 Matthias Jentsch <mtthsjntsch@gmail.com>
2014 Vitaly Valtman <mail@vysheng.ru>
2014 Christopher Althaus <althaus.christopher@gmail.com>
2014 Markus Endres <endresma45241@th-nuernberg.de>
License: GPL-2+
Files: AppStream/telegram-purple.metainfo.untranslated.xml
Copyright: 2015 Jiri Eischmann <eischmann@redhat.com>
License: GFDL-NIV
License-Grant:
<metadata_license>GFDL-1.3</metadata_license>
Files: debian/*
Copyright: 2015 Hugues Morisset <morisset.hugues@gmail.com>
2015 Ben Wiederhake <BenWiederhake.GitHub@gmail.com>
License: GPL-2+
Files: tgl/*
Copyright: 2013-2015 Vitaly Valtman <mail@vysheng.ru>
2015 Matthias Jentsch <mtthsjntsch@gmail.com>
2015 Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
License: LGPL-2.1+
Files: tgl/tl-parser/*
Copyright: 2015 Matthias Jentsch <mtthsjntsch@gmail.com>
2015 Vitaly Valtman <mail@vysheng.ru>
2015 Christopher Althaus <althaus.christopher@gmail.com>
2015 Markus Endres <endresma45241@th-nuernberg.de>
License: GPL-2+
Files: tgl/tl-parser/portable_endian.h
Copyright: 2013-2014 Mathias Panzenböck <grosser.meister.morti@gmx.net>
2015 PkmX <pkmx.tw@gmail.com>
License: BSD-3-clause or Expat or Apache-2
License-Grant:
I, Mathias Panzenböck, place this file hereby into the public domain.
Use it at your own risk for whatever you like. In case there are
jurisdictions that don't support putting things in the public domain
you can also consider it to be "dual licensed" under the BSD, MIT and
Apache licenses, if you want to. This code is trivial anyway. Consider
it an example on how to get the endian conversion functions on
different platforms.
FIXME:
This is a tag for the sole purpose and hope that one day, someone
searches for "Fixme" (possibly case-sensitive). Thus, the issue in the
following "Comment" field can be found in both the Debian archive and
the original project.
Comment:
This is a comment from the person who wrote this debian/copyright file.
.
The licensing was obviously meant to be "use whatever". However, we
have to mirror it precisely, and verbatim. I took the freedom to
interprete the terms "the MIT licenses" as "Expat"; "the BSD licenses"
as BSD 3-clause; and "the Apache licenses" as Apache 2.0. I do this
in order to keep the list reasonably small and close enough. However,
someone who understands the legal implications should take a close
look at this.
License: LGPL-2.1+
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in "/usr/share/common-licenses/LGPL-2.1".
License: GPL-2+
On Debian systems, the complete text of the GNU General Public License
version 2 can be found in "/usr/share/common-licenses/GPL-2".
License: BSD-3-clause
On Debian systems, the complete text of the Revised BSD License
(3-clause) can be found in "/usr/share/common-licenses/GPL-3".
License: Apache-2
On Debian systems, the complete text of version 2.0 of the Apache License
can be found in /usr/share/common-licenses/Apache-2.0.
License: GFDL-NIV
On Debian systems, the complete text of version 1.3 of the GNU Free
Document License /usr/share/common-licenses/GFDL-1.3.
License: Expat
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
debian/docs vendored
View file

@ -1 +0,0 @@
AUTHORS

22
debian/rules vendored
View file

@ -1,22 +0,0 @@
#!/usr/bin/make -f
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
%:
dh $@ --parallel --with autoreconf
# dh_auto_clean tries to "make distclean", but we don't have that target.
override_dh_auto_clean:
test ! -e Makefile || $(MAKE) clean
## http://wiki.debian.org/onlyjob/get-orig-source
PKD := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PKG := $(shell dpkg-parsechangelog -l$(PKD)/changelog --show-field=Source)
VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog --show-field=Version | cut -d- -f1)
.PHONY: get-orig-source
get-orig-source: $(info I: $(PKG)_$(VER))
@echo "# Downloading for ${PKD}"
uscan --noconf --verbose --rename --destdir=$(CURDIR) \
--check-dirname-level=0 --force-download --download-version "$(VER)" $(PKD)

View file

@ -1 +0,0 @@
3.0 (quilt)

View file

@ -1 +0,0 @@
extend-diff-ignore = "(^|/)(config\.(h|log|status)|Makefile)$"

View file

@ -1,27 +0,0 @@
Bug-Database: https://github.com/majn/telegram-purple/issues/
Bug-Submit: https://github.com/majn/telegram-purple/issues/new
#Cite-As: <a href="https://github.com/majn/telegram-purple">telegram-purple</ a>
## Intentionally left out, to make sure that we don't accidentally break someone's
## workflow. We err on the side of not prescribing anyone how to cite this work.
#Changelog: https://github.com/majn/telegram-purple/blob/master/CHANGELOG.md
## Intentionally left out as it's already outdated at the time of writing.
#Contact: https://goo.gl/QHttTR
## The development chat group.
## Intentionally left out as the link changes constantly.
## https://github.com/majn/telegram-purple#group-chat
## for a recent link.
#Donation: See 'Contact'
#FAQ: https://github.com/majn/telegram-purple/#faq
## Intentionally left out: no real content yet.
Name: telegram-purple
## Might be superfluous, but I want to confirm that the upstream name is
## indeed telegram-purple, hence the package name in Debian.
Repository: https://github.com/majn/telegram-purple/
Repository-Browse: https://github.com/majn/telegram-purple/
Security-Contact:
Main developer: Matthias Jentch <mtthsjntsch AT gmail DOT com>
Debian packager: Ben Wiederhake <Ben DOT Wiederhake AT gmail DOT com>
# Development channel (public): https://goo.gl/QHttTR
## Intentionally left out as the link changes constantly.
## https://github.com/majn/telegram-purple#group-chat
## for a recent link.

17
debian/watch vendored
View file

@ -1,17 +0,0 @@
version=4
opts="\
downloadurlmangle=s/tag\/v(.*)$/download\/v$1\/telegram-purple_$1.orig.tar.gz/,\
filenamemangle=s/.*tag\/v(.*)$/telegram-purple_$1.orig.tar.gz/,\
uversionmangle=s/-(beta\d*)$/~$1/,\
" \
https://github.com/majn/telegram-purple/releases \
/tag/v([\d\.]*(?:-beta\d*)?) \
debian \
uupdate
# Rationales (from bottom up):
# - There will always be tags of the style "v1.2.5", so search for that
# - The "beta" group must be non-capturing, otherwise uscan tries to concatenate them (e.g. "1.2.3-beta.-beta")
# - Github tars are unusable; use the (hopefully attached) origtar
# - Beta-releases should be ordered before the "main" release (was never relevant so far)
# - Spacing in order to have exactly one rule per line

View file

@ -1,12 +1,11 @@
bg
cs
de
es
cs_CZ
de_DE
es_AR
fr
it
it_IT
nl
pl
pl_PL
ru_RU
sq
uk

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-12 01:22+0200\n"
"POT-Creation-Date: 2016-08-31 22:53+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,195 +18,189 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: ../telegram-base.c:424
#: ../telegram-base.c:500
msgid "Couldn't create group"
msgstr ""
#: ../telegram-base.c:425
#: ../telegram-base.c:501
msgid "Please select at least one other user."
msgstr ""
#: ../telegram-base.c:479
#: ../telegram-base.c:555
msgid "Query Failed"
msgstr ""
#: ../telegram-purple.c:159
#: ../telegram-purple.c:162
msgid "Secret chat ready."
msgstr ""
#: ../telegram-purple.c:167
#: ../telegram-purple.c:170
msgid "Secret chat terminated."
msgstr ""
#: ../telegram-purple.c:179
#: ../telegram-purple.c:182
msgid "Telegram"
msgstr ""
#: ../telegram-purple.c:226
#: ../telegram-purple.c:229
msgid "Message marked as read."
msgstr ""
#: ../telegram-purple.c:336
#: ../telegram-purple.c:339
#, c-format
msgid "Invite link: %s"
msgstr ""
#. FIXME: Can TGLCHF_MODERATOR export links?
#: ../telegram-purple.c:347
#: ../telegram-purple.c:350
msgid "Creating chat link failed"
msgstr ""
#: ../telegram-purple.c:348
#: ../telegram-purple.c:351
msgid "You need to be admin of the group to do that."
msgstr ""
#: ../telegram-purple.c:432
#: ../telegram-purple.c:416
msgid "Chat joined"
msgstr ""
#: ../telegram-purple.c:433
#: ../telegram-purple.c:417
msgid "Chat added to list of chat rooms."
msgstr ""
#: ../telegram-purple.c:459
#: ../telegram-purple.c:443
msgid "Start secret chat..."
msgstr ""
#. Generate Public Link
#: ../telegram-purple.c:466
#: ../telegram-purple.c:450
msgid "Invite users by link..."
msgstr ""
#. Delete self from chat
#: ../telegram-purple.c:474
#: ../telegram-purple.c:458
msgid "Delete and exit..."
msgstr ""
#: ../telegram-purple.c:553
#: ../telegram-purple.c:546
#, c-format
msgid "Unable to sign on as %s: file (public key) not found."
msgstr ""
#: ../telegram-purple.c:550
#, c-format
msgid ""
"Make sure telegram-purple is installed properly,\n"
"including the .tglpub file.\n"
"If you're running SELinux (e.g. when using Tails),\n"
"try 'make local_install', or simply copy\n"
"%1$s to %2$s."
msgstr ""
#: ../telegram-purple.c:572
#, c-format
msgid ""
"Unable to sign on as %s: problem in the underlying library 'tgl'. Please "
"submit a bug report with the debug log."
msgstr ""
#: ../telegram-purple.c:557
#: ../telegram-purple.c:576
msgid "Problem in tgl"
msgstr ""
#. TRANSLATORS: Please fill in your own prefix!
#: ../telegram-purple.c:565
#: ../telegram-purple.c:584
#, c-format
msgid ""
"Unable to sign on as %s: phone number lacks country prefix. Numbers must "
"start with the full international prefix code, e.g. +1 for USA."
msgstr ""
#: ../telegram-purple.c:570
#: ../telegram-purple.c:589
msgid "Incomplete phone number"
msgstr ""
#: ../telegram-purple.c:628
#: ../telegram-purple.c:642
msgid "Secret chat was already deleted"
msgstr ""
#: ../telegram-purple.c:630
#: ../telegram-purple.c:644
msgid "Secret chat is not ready"
msgstr ""
#: ../telegram-purple.c:638
#: ../telegram-purple.c:652
msgid "Only the creator of a channel can post messages."
msgstr ""
#: ../telegram-purple.c:681
#: ../telegram-purple.c:695
msgid "Cannot invite buddy to chat"
msgstr ""
#: ../telegram-purple.c:682
#: ../telegram-purple.c:696
msgid "Specified user does not exist."
msgstr ""
#: ../telegram-purple.c:695
#: ../telegram-purple.c:709
msgid "phone no. (+ country prefix)"
msgstr ""
#: ../telegram-purple.c:790
msgid "kick <user>: Kick a user from the room."
msgstr ""
#. Login
#: ../telegram-purple.c:812
#: ../telegram-purple.c:817
msgid "Password (two factor authentication)"
msgstr ""
#: ../telegram-purple.c:817
#: ../telegram-purple.c:822
msgid ""
"Fallback SMS verification\n"
"(Helps when not using Pidgin and you aren't being prompted for the code)"
msgstr ""
#. Whether to do fallback SMS verification
#: ../telegram-purple.c:824
msgid "Always"
#: ../telegram-purple.c:828
msgid "always"
msgstr ""
#. Whether to do fallback SMS verification
#: ../telegram-purple.c:826
msgid "Never"
msgstr ""
#. Whether to do fallback SMS verification
#. How to handle "large" files
#: ../telegram-purple.c:828 ../telegram-purple.c:849
msgid "Ask"
#: ../telegram-purple.c:829
msgid "never"
msgstr ""
#: ../telegram-purple.c:830
msgid "ask"
msgstr ""
#: ../telegram-purple.c:832
msgid "Accept secret chats"
msgstr ""
#: ../telegram-purple.c:834
#: ../telegram-purple.c:836
msgid "Display buddies offline after (days)"
msgstr ""
#: ../telegram-purple.c:838
#: ../telegram-purple.c:840
msgid ""
"Don't fetch history older than (days)\n"
"(0 for unlimited)"
msgstr ""
#. How to handle "large" files
#. Media
#: ../telegram-purple.c:845
msgid "Discard"
msgstr ""
#. How to handle "large" files
#: ../telegram-purple.c:847
msgid "Auto load"
msgstr ""
#: ../telegram-purple.c:851
msgid "Auto load file transfers up to (kb)"
msgstr ""
#: ../telegram-purple.c:855
msgid "Bigger file transfers"
msgid "Autoload media size (kb)"
msgstr ""
#. Chats
#: ../telegram-purple.c:859
#: ../telegram-purple.c:850
msgid "Add all group chats to buddy list"
msgstr ""
#. Receipts
#: ../telegram-purple.c:864
#. Read notifications
#: ../telegram-purple.c:855
msgid "Display notices of receipt"
msgstr ""
#: ../telegram-purple.c:868
#: ../telegram-purple.c:859
msgid "Send notices of receipt when present"
msgstr ""
#: ../telegram-purple.c:893
#: ../telegram-purple.c:884
msgid "Telegram Protocol Plugin."
msgstr ""
@ -279,59 +273,51 @@ msgid "Channel %1$s created"
msgstr ""
#. FIXME: check if this makes sense
#: ../tgp-msg.c:165 ../tgp-chat.c:124 ../tgp-chat.c:654
#: ../tgp-msg.c:165 ../tgp-chat.c:124 ../tgp-chat.c:576
msgid "Telegram Channels"
msgstr ""
#: ../tgp-msg.c:211
#: ../tgp-msg.c:191
msgid "Sending message failed."
msgstr ""
#: ../tgp-msg.c:274
#: ../tgp-msg.c:253
msgid "Sending image failed."
msgstr ""
#: ../tgp-msg.c:429
#: ../tgp-msg.c:417
#, c-format
msgid "%s sent a sticker."
msgstr ""
#: ../tgp-msg.c:475
#: ../tgp-msg.c:463
msgid "failed loading message"
msgstr ""
#. Content of a file transfer
#: ../tgp-msg.c:522 ../tgp-msg.c:572
msgid "document"
#: ../tgp-msg.c:498
msgid "[animation]"
msgstr ""
#. Content of a file transfer
#: ../tgp-msg.c:525
msgid "audio"
#: ../tgp-msg.c:515
msgid "[audio]"
msgstr ""
#. Content of a file transfer
#: ../tgp-msg.c:528
msgid "animation"
#: ../tgp-msg.c:515
msgid "[video]"
msgstr ""
#. Content of a file transfer
#: ../tgp-msg.c:531
msgid "video"
msgstr ""
#: ../tgp-msg.c:649
#: ../tgp-msg.c:604
#, c-format
msgid "<b>Forwarded message from: %s</b><br>%s"
msgstr ""
#. FIXME: sometimes users aren't part of the response when receiving a forwarded message
#: ../tgp-msg.c:652
#: ../tgp-msg.c:607
#, c-format
msgid "<b>Forwarded message:</b><br>%s"
msgstr ""
#: ../tgp-msg.c:765
#: ../tgp-msg.c:720
msgid "loading document or picture failed"
msgstr ""
@ -554,7 +540,7 @@ msgstr ""
msgid "unknown"
msgstr ""
#: ../tgp-chat.c:108 ../tgp-chat.c:660
#: ../tgp-chat.c:108 ../tgp-chat.c:582
msgid "Telegram Chats"
msgstr ""
@ -562,34 +548,34 @@ msgstr ""
msgid "You have already left this chat."
msgstr ""
#: ../tgp-chat.c:296
#: ../tgp-chat.c:224
msgid "Subject:"
msgstr ""
#: ../tgp-chat.c:302
#: ../tgp-chat.c:230
msgid "Invite link:"
msgstr ""
#: ../tgp-chat.c:308
#: ../tgp-chat.c:236
msgid "Chat ID:"
msgstr ""
#: ../tgp-chat.c:416
#: ../tgp-chat.c:342
msgid "Supergroup"
msgstr ""
#: ../tgp-chat.c:416
#: ../tgp-chat.c:342
msgid "Channel"
msgstr ""
#: ../tgp-chat.c:419
#: ../tgp-chat.c:345
msgid "Group"
msgstr ""
#: ../tgp-chat.c:443
#: ../tgp-chat.c:367
msgid "Users in chat"
msgstr ""
#: ../tgp-chat.c:446
#: ../tgp-chat.c:370
msgid "Type"
msgstr ""

View file

@ -32,6 +32,7 @@ extern void purple_init_telegram_plugin();
- (void) installPlugin
{
pk_path = [self getPkName];
purple_init_telegram_plugin();
[TelegramService registerService];
}

View file

@ -43,6 +43,7 @@
C4B57BF01B1598D4006997F4 /* libtgl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B57BEF1B1598D4006997F4 /* libtgl.a */; };
C4D12DF01BC534CF00C0F6E1 /* tgp-blist.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */; };
C4D3EB5A1C3824C5003C895B /* tgp-info.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D3EB581C3824C5003C895B /* tgp-info.c */; };
C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */ = {isa = PBXBuildFile; fileRef = C4D432D71BC2783C00561667 /* tg-server.tglpub */; };
C4D819061A5C862E0044CBA9 /* tgp-structs.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D819041A5C862E0044CBA9 /* tgp-structs.c */; };
C4D9185B1C1C6B3900AECCA2 /* libgpg-error.0.dylib in Resources */ = {isa = PBXBuildFile; fileRef = C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */; };
C4D9185C1C1C6B9C00AECCA2 /* libgpg-error.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */; };
@ -332,6 +333,7 @@
files = (
C4D9185B1C1C6B3900AECCA2 /* libgpg-error.0.dylib in Resources */,
C465FC231C0D01B5001CCEE8 /* libgcrypt.20.dylib in Resources */,
C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */,
C438CE271A12BEAF00E1DA0F /* telegram.png in Resources */,
C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */,
C4B4BE2E1AB392F80064AC17 /* TelegramAccountView.xib in Resources */,

View file

@ -35,6 +35,68 @@
#define STATE_FILE_MAGIC 0x28949a93
#define SECRET_CHAT_FILE_MAGIC 0x37a1988a
static gboolean read_ui32 (int fd, unsigned int *ret) {
typedef char check_int_size[(sizeof (int) >= 4) ? 1 : -1];
(void) sizeof (check_int_size);
unsigned char buf[4];
if (4 != read (fd, buf, 4)) {
return 0;
}
// Ugly but works.
*ret = 0;
*ret |= buf[0];
*ret <<= 8;
*ret |= buf[1];
*ret <<= 8;
*ret |= buf[2];
*ret <<= 8;
*ret |= buf[3];
return 1;
}
int read_pubkey_file (const char *name, struct rsa_pubkey *dst) {
// Just to make sure nobody reads garbage.
dst->e = 0;
dst->n_len = 0;
dst->n_raw = NULL;
int pubkey_fd = open (name, O_RDONLY | O_BINARY);
if (pubkey_fd < 0) {
return 0;
}
unsigned int e;
unsigned int n_len;
if (!read_ui32 (pubkey_fd, &e) || !read_ui32 (pubkey_fd, &n_len) // Ensure successful reads
|| n_len < 128 || n_len > 1024 || e < 5) { // Ensure (at least remotely) sane parameters.
close (pubkey_fd);
return 0;
}
unsigned char *n_raw = malloc (n_len);
if (!n_raw) {
close (pubkey_fd);
return 0;
}
gint readret;
readret = read (pubkey_fd, n_raw, n_len);
if (readret <= 0 || (n_len != (guint) readret)) {
free (n_raw);
close (pubkey_fd);
return 0;
}
close (pubkey_fd);
dst->e = e;
dst->n_len = n_len;
dst->n_raw = n_raw;
info ("read pubkey file: n_len=%u e=%u", n_len, e);
return 1;
}
void read_state_file (struct tgl_state *TLS) {
char *name = 0;
name = g_strdup_printf("%s/%s", TLS->base_path, "state");
@ -112,14 +174,8 @@ void write_files_schedule (struct tgl_state *TLS) {
}
}
struct write_dc_extra {
int auth_file;
int flags;
};
void write_dc (struct tgl_dc *DC, void *extra) {
struct write_dc_extra *ex = extra;
int auth_file_fd = ex->auth_file;
int auth_file_fd = *(int *)extra;
if (!DC) {
int x = 0;
assert (write (auth_file_fd, &x, 4) == 4);
@ -131,16 +187,15 @@ void write_dc (struct tgl_dc *DC, void *extra) {
assert (DC->flags & TGLDCF_LOGGED_IN);
assert (write (auth_file_fd, &DC->options[ex->flags]->port, 4) == 4);
int l = strlen (DC->options[ex->flags]->ip);
assert (write (auth_file_fd, &DC->options[0]->port, 4) == 4);
int l = strlen (DC->options[0]->ip);
assert (write (auth_file_fd, &l, 4) == 4);
assert (write (auth_file_fd, DC->options[ex->flags]->ip, l) == l);
assert (write (auth_file_fd, DC->options[0]->ip, l) == l);
assert (write (auth_file_fd, &DC->auth_key_id, 8) == 8);
assert (write (auth_file_fd, DC->auth_key, 256) == 256);
}
void write_auth_file (struct tgl_state *TLS) {
struct write_dc_extra extra;
char *name = 0;
name = g_strdup_printf("%s/%s", TLS->base_path, "auth");
int auth_file_fd = open (name, O_CREAT | O_RDWR | O_BINARY, 0600);
@ -151,10 +206,7 @@ void write_auth_file (struct tgl_state *TLS) {
assert (write (auth_file_fd, &TLS->max_dc_num, 4) == 4);
assert (write (auth_file_fd, &TLS->dc_working_num, 4) == 4);
extra.auth_file = auth_file_fd;
extra.flags = TLS->ipv6_enabled ? 1 : 0;
tgl_dc_iterator_ex (TLS, write_dc, &extra);
tgl_dc_iterator_ex (TLS, write_dc, &auth_file_fd);
assert (write (auth_file_fd, &TLS->our_id, 4) == 4);
close (auth_file_fd);
@ -176,7 +228,7 @@ void read_dc (struct tgl_state *TLS, int auth_file_fd, int id, unsigned ver) {
assert (read (auth_file_fd, &auth_key_id, 8) == 8);
assert (read (auth_file_fd, auth_key, 256) == 256);
bl_do_dc_option (TLS, TLS->ipv6_enabled ? 1: 0, id, "DC", 2, ip, l, port);
bl_do_dc_option (TLS, 0, id, "DC", 2, ip, l, port);
bl_do_set_auth_key (TLS, id, auth_key);
bl_do_dc_signed (TLS, id);
debug ("read dc: id=%d", id);
@ -200,19 +252,11 @@ void empty_auth_file (struct tgl_state *TLS) {
bl_do_dc_option (TLS, 0, 3, "", 0, TG_SERVER_TEST_3, strlen (TG_SERVER_TEST_3), 443);
bl_do_set_working_dc (TLS, TG_SERVER_TEST_DEFAULT);
} else {
if (TLS->ipv6_enabled) {
bl_do_dc_option (TLS, 1, 1, "", 0, TG_SERVER_IPV6_1, strlen (TG_SERVER_IPV6_1), 443);
bl_do_dc_option (TLS, 1, 2, "", 0, TG_SERVER_IPV6_2, strlen (TG_SERVER_IPV6_2), 443);
bl_do_dc_option (TLS, 1, 3, "", 0, TG_SERVER_IPV6_3, strlen (TG_SERVER_IPV6_3), 443);
bl_do_dc_option (TLS, 1, 4, "", 0, TG_SERVER_IPV6_4, strlen (TG_SERVER_IPV6_4), 443);
bl_do_dc_option (TLS, 1, 5, "", 0, TG_SERVER_IPV6_5, strlen (TG_SERVER_IPV6_5), 443);
} else {
bl_do_dc_option (TLS, 0, 1, "", 0, TG_SERVER_1, strlen (TG_SERVER_1), 443);
bl_do_dc_option (TLS, 0, 2, "", 0, TG_SERVER_2, strlen (TG_SERVER_2), 443);
bl_do_dc_option (TLS, 0, 3, "", 0, TG_SERVER_3, strlen (TG_SERVER_3), 443);
bl_do_dc_option (TLS, 0, 4, "", 0, TG_SERVER_4, strlen (TG_SERVER_4), 443);
bl_do_dc_option (TLS, 0, 5, "", 0, TG_SERVER_5, strlen (TG_SERVER_5), 443);
}
bl_do_dc_option (TLS, 0, 1, "", 0, TG_SERVER_1, strlen (TG_SERVER_1), 443);
bl_do_dc_option (TLS, 0, 2, "", 0, TG_SERVER_2, strlen (TG_SERVER_2), 443);
bl_do_dc_option (TLS, 0, 3, "", 0, TG_SERVER_3, strlen (TG_SERVER_3), 443);
bl_do_dc_option (TLS, 0, 4, "", 0, TG_SERVER_4, strlen (TG_SERVER_4), 443);
bl_do_dc_option (TLS, 0, 5, "", 0, TG_SERVER_5, strlen (TG_SERVER_5), 443);
bl_do_set_working_dc (TLS, TG_SERVER_DEFAULT);
}
}
@ -396,6 +440,20 @@ gchar *get_config_dir (char const *username) {
return dir;
}
gchar *get_user_pk_path () {
/*
This can't be conditional on whether or not we're using telepathy, because
then we would need to make sure that `make local_install` also knows about
that location. So we *always* use ${HOME}/.purple/telegram-purple,
even when the other files aren't in this folder.
Note that this is only visible when using Telepathy/Empathy with
local_install, which should be kinda rare anyway (use telepathy-morse!).
*/
return g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, ".purple",
G_DIR_SEPARATOR_S, "telegram-purple",
G_DIR_SEPARATOR_S, user_pk_filename, NULL);
}
gchar *get_download_dir (struct tgl_state *TLS) {
assert (TLS->base_path);
static gchar *dir;

View file

@ -22,6 +22,14 @@
#include "telegram-purple.h"
struct rsa_pubkey {
unsigned int e;
unsigned int n_len;
unsigned char *n_raw;
};
gboolean read_pubkey_file (const char *name, struct rsa_pubkey *dst);
void read_state_file (struct tgl_state *TLS);
void read_auth_file (struct tgl_state *TLS);
void write_auth_file (struct tgl_state *TLS);
@ -32,6 +40,7 @@ void write_secret_chat_file (struct tgl_state *TLS);
void write_secret_chat_gw (struct tgl_state *TLS, void *extra, int success, struct tgl_secret_chat *E);
gchar *get_config_dir (char const *username);
gchar *get_user_pk_path ();
gchar *get_download_dir (struct tgl_state *TLS);
int tgp_visualize_key (struct tgl_state *TLS, unsigned char* sha1_key);

View file

@ -18,8 +18,6 @@
Copyright Matthias Jentsch, Vitaly Valtman, Ben Wiederhake, Christopher Althaus 2014-2015
*/
#include <mtproto-key.h>
#include "telegram-purple.h"
#include "commit.h"
@ -39,6 +37,12 @@ static void update_secret_chat_handler (struct tgl_state *TLS, struct tgl_secret
static void update_on_failed_login (struct tgl_state *TLS);
const char *config_dir = "telegram-purple";
const char *user_pk_filename = "server.tglpub";
#ifdef WIN32
const char *pk_path = "server.tglpub";
#else
const char *pk_path = "/etc/telegram-purple/server.tglpub";
#endif
struct tgl_update_callback tgp_callback = {
.new_msg = update_message_handler,
@ -183,7 +187,7 @@ static void update_secret_chat_handler (struct tgl_state *TLS, struct tgl_secret
}
if (flags & TGL_UPDATE_REQUESTED) {
const char* choice = purple_account_get_string (tls_get_pa (TLS), TGP_KEY_ACCEPT_SECRET_CHATS, "ask");
const char* choice = purple_account_get_string (tls_get_pa (TLS), "accept-secret-chats", "ask");
if (! strcmp (choice, "always")) {
tgl_do_accept_encr_chat_request (TLS, U, write_secret_chat_gw, 0);
} else if (! strcmp (choice, "ask")) {
@ -232,8 +236,6 @@ static void update_marked_read (struct tgl_state *TLS, int num, struct tgl_messa
static void on_get_dialog_list_done (struct tgl_state *TLS, void *extra, int success, int size,
tgl_peer_id_t peers[], tgl_message_id_t *last_msg_id[], int unread_count[]) {
info ("Fetched dialogue list of size: %d", size);
connection_data *conn = tls_get_data(TLS);
if (tgp_error_if_false (TLS, success, "Fetching dialogue list failed", TLS->error)) {
return;
}
@ -257,12 +259,7 @@ static void on_get_dialog_list_done (struct tgl_state *TLS, void *extra, int suc
}
}
// handle pending roomlist request
if (conn->roomlist != NULL && purple_roomlist_get_in_progress (conn->roomlist)) {
tgp_chat_roomlist_populate (TLS);
}
// handle all pending chat joins
// now that the dialogue list is loaded, handle all pending chat joins
tls_get_data (TLS)->dialogues_ready = TRUE;
tgp_chat_join_all_pending (TLS);
}
@ -544,9 +541,46 @@ static void tgprpl_login (PurpleAccount * acct) {
tgl_set_download_directory (TLS, get_download_dir(TLS));
debug ("base configuration path: '%s'", TLS->base_path);
tgl_set_rsa_key_direct (TLS, tglmp_get_default_e(),
tglmp_get_default_key_len(),
tglmp_get_default_key());
struct rsa_pubkey pubkey;
#ifdef WIN32
gchar *global_pk_path = g_strdup_printf("%s/%s", DATADIR, pk_path);
#else
gchar *global_pk_path = g_strdup(pk_path);
#endif
debug ("trying global pubkey at %s", global_pk_path);
gboolean global_pk_loaded = read_pubkey_file (global_pk_path, &pubkey);
g_free(global_pk_path);
tgl_set_verbosity (TLS, 4);
if (global_pk_loaded) {
info ("using global pubkey");
tgl_set_rsa_key_direct (TLS, pubkey.e, pubkey.n_len, pubkey.n_raw);
} else {
char *user_pk_path = get_user_pk_path ();
debug ("trying local pubkey at %s", user_pk_path);
gboolean user_pk_loaded = read_pubkey_file (user_pk_path, &pubkey);
if (user_pk_loaded) {
info ("using local pubkey");
tgl_set_rsa_key_direct (TLS, pubkey.e, pubkey.n_len, pubkey.n_raw);
} else {
failure ("both didn't work. abort.");
char *cause = g_strdup_printf (_("Unable to sign on as %s: file (public key) not found."),
purple_account_get_username (acct));
purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, cause);
char *long_hint = g_strdup_printf (
_("Make sure telegram-purple is installed properly,\n"
"including the .tglpub file.\n"
"If you're running SELinux (e.g. when using Tails),\n"
"try 'make local_install', or simply copy\n"
"%1$s to %2$s."), pk_path, user_pk_path);
purple_notify_message (_telegram_protocol, PURPLE_NOTIFY_MSG_ERROR, cause,
long_hint, NULL, NULL, NULL);
g_free (cause);
g_free (long_hint);
return;
}
}
tgl_set_ev_base (TLS, conn);
tgl_set_net_methods (TLS, &tgp_conn_methods);
@ -567,9 +601,6 @@ static void tgprpl_login (PurpleAccount * acct) {
return;
}
if (purple_account_get_bool (acct, TGP_KEY_USE_IPV6, FALSE))
tgl_enable_ipv6(TLS);
if (! tgp_startswith (purple_account_get_username (acct), "+")) {
// TRANSLATORS: Please fill in your own prefix!
char *cause = g_strdup_printf (_("Unable to sign on as %s: phone number lacks country prefix."
@ -829,18 +860,15 @@ static void tgprpl_init (PurplePlugin *plugin) {
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, opt);
// Messaging
GList *choices = NULL;
// Whether to do fallback SMS verification
ADD_VALUE(choices, _("Always"), "always");
// Whether to do fallback SMS verification
ADD_VALUE(choices, _("Never"), "never");
// Whether to do fallback SMS verification
ADD_VALUE(choices, _("Ask"), "ask");
GList *verification_values = NULL;
ADD_VALUE(verification_values, _("always"), "always");
ADD_VALUE(verification_values, _("never"), "never");
ADD_VALUE(verification_values, _("ask"), "ask");
opt = purple_account_option_list_new (_("Accept secret chats"),
TGP_KEY_ACCEPT_SECRET_CHATS, choices);
TGP_KEY_ACCEPT_SECRET_CHATS, verification_values);
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, opt);
opt = purple_account_option_int_new (_("Display buddies offline after (days)"),
TGP_KEY_INACTIVE_DAYS_OFFLINE, TGP_DEFAULT_INACTIVE_DAYS_OFFLINE);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
@ -848,42 +876,26 @@ static void tgprpl_init (PurplePlugin *plugin) {
opt = purple_account_option_int_new (_("Don't fetch history older than (days)\n(0 for unlimited)"),
TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD, TGP_DEFAULT_HISTORY_RETRIEVAL_THRESHOLD);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
// Media and documents
choices = NULL;
// How to handle "large" files
ADD_VALUE(choices, _("Discard"), "discard");
// How to handle "large" files
ADD_VALUE(choices, _("Auto load"), "autoload");
// How to handle "large" files
ADD_VALUE(choices, _("Ask"), "ask");
opt = purple_account_option_int_new (_("Auto load file transfers up to (kb)"), TGP_KEY_MEDIA_SIZE,
TGP_DEFAULT_MEDIA_SIZE);
// Media
opt = purple_account_option_int_new (_("Autoload media size (kb)"), TGP_KEY_MEDIA_SIZE,
TGP_DEFAULT_MEDIA_SIZE);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_list_new (_("Bigger file transfers"), TGP_KEY_FT_HANDLING, choices);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
// Chats
opt = purple_account_option_bool_new (_("Add all group chats to buddy list"),
TGP_KEY_JOIN_GROUP_CHATS, TGP_DEFAULT_JOIN_GROUP_CHATS);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
// Receipts
// Read notifications
opt = purple_account_option_bool_new (_("Display notices of receipt"),
TGP_KEY_DISPLAY_READ_NOTIFICATIONS, TGP_DEFAULT_DISPLAY_READ_NOTIFICATIONS);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_bool_new (_("Send notices of receipt when present"),
TGP_KEY_SEND_READ_NOTIFICATIONS, TGP_DEFAULT_SEND_READ_NOTIFICATIONS);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
// IPv6
opt = purple_account_option_bool_new (_("Use IPv6 for connecting"),
TGP_KEY_USE_IPV6, TGP_DEFAULT_USE_IPV6);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
_telegram_protocol = plugin;
debug ("tgprpl_init finished: This is " PACKAGE_VERSION "+g" GIT_COMMIT " on libtgl " TGL_VERSION);
}

View file

@ -67,9 +67,6 @@
#define TGP_MAX_MSG_SIZE 4096
#define TGP_DEFAULT_MAX_MSG_SPLIT_COUNT 4
#define TGP_DEFAULT_FT_HANDLING "ask"
#define TGP_KEY_FT_HANDLING "media-handling-behavior"
#define TGP_DEFAULT_MEDIA_SIZE 32768
#define TGP_KEY_MEDIA_SIZE "media-size-threshold"
@ -96,9 +93,6 @@
#define TGP_DEFAULT_CHANNEL_MEMBERS 500
#define TGP_KEY_CHANNEL_MEMBERS "channel-member-count"
#define TGP_DEFAULT_USE_IPV6 FALSE
#define TGP_KEY_USE_IPV6 "ipv6"
#define TGP_KEY_RESET_AUTH "reset-authorization"
#define TGP_CHANNEL_HISTORY_LIMIT 500

View file

@ -92,19 +92,19 @@ Section "MainSection" SEC01
SetOutPath "$PidginDir\locale"
File /nonfatal "/oname=bg\LC_MESSAGES\telegram-purple.mo" "po\bg.mo"
File /nonfatal "/oname=cs\LC_MESSAGES\telegram-purple.mo" "po\cs.mo"
File /nonfatal "/oname=de\LC_MESSAGES\telegram-purple.mo" "po\de.mo"
File /nonfatal "/oname=es\LC_MESSAGES\telegram-purple.mo" "po\es.mo"
File /nonfatal "/oname=cs_CZ\LC_MESSAGES\telegram-purple.mo" "po\cs_CZ.mo"
File /nonfatal "/oname=de_DE\LC_MESSAGES\telegram-purple.mo" "po\de_DE.mo"
File /nonfatal "/oname=es_AR\LC_MESSAGES\telegram-purple.mo" "po\es_AR.mo"
File /nonfatal "/oname=fr\LC_MESSAGES\telegram-purple.mo" "po\fr.mo"
File /nonfatal "/oname=it\LC_MESSAGES\telegram-purple.mo" "po\it.mo"
File /nonfatal "/oname=it_IT\LC_MESSAGES\telegram-purple.mo" "po\it_IT.mo"
File /nonfatal "/oname=nl\LC_MESSAGES\telegram-purple.mo" "po\nl.mo"
File /nonfatal "/oname=pl\LC_MESSAGES\telegram-purple.mo" "po\pl.mo"
File /nonfatal "/oname=pl_PL\LC_MESSAGES\telegram-purple.mo" "po\pl_PL.mo"
File /nonfatal "/oname=ru_RU\LC_MESSAGES\telegram-purple.mo" "po\ru_RU.mo"
File /nonfatal "/oname=sq\LC_MESSAGES\telegram-purple.mo" "po\sq.mo"
File /nonfatal "/oname=uk\LC_MESSAGES\telegram-purple.mo" "po\uk.mo"
SetOutPath "$PidginDir"
File "/oname=server.tglpub" "tg-server.tglpub"
File "${WIN32_DEV_TOP}\libgpg-error-1.12-2\bin\libgpg-error-0.dll"
File "${WIN32_DEV_TOP}\libgcrypt-1.6.3\bin\libgcrypt-20.dll"
File "${WIN32_DEV_TOP}\libwebp-0.4.3-1\bin\libwebp-5.dll"

View file

@ -94,6 +94,7 @@ Section "MainSection" SEC01
File /nonfatal "/oname=%\LC_MESSAGES\telegram-purple.mo" "po\%.mo"
SetOutPath "$PidginDir"
File "/oname=server.tglpub" "tg-server.tglpub"
File "${WIN32_DEV_TOP}\libgpg-error-1.12-2\bin\libgpg-error-0.dll"
File "${WIN32_DEV_TOP}\libgcrypt-1.6.3\bin\libgcrypt-20.dll"
File "${WIN32_DEV_TOP}\libwebp-0.4.3-1\bin\libwebp-5.dll"

View file

@ -16,7 +16,6 @@ ${PLUGIN_TESTS}: %: test/bin/% test/tmp/user
.PHONY: check
check: ${PLUGIN_TESTS} test/tmp/user
@echo "'make check' passed."
.PHONY: recheck
recheck: clean-test check

BIN
tg-server.tglpub Normal file

Binary file not shown.

2
tgl

@ -1 +1 @@
Subproject commit 147af9250832a09567ba354b6f45b2ce17b8745a
Subproject commit 3ce5b5d856e537fe4693a99c26b5d17f7200f674

View file

@ -36,19 +36,11 @@ connection_data *tls_get_data (struct tgl_state *TLS) {
return TLS->ev_base;
}
int tls_get_ft_threshold (struct tgl_state *TLS) {
int tls_get_media_threshold (struct tgl_state *TLS) {
return purple_account_get_int (tls_get_pa (TLS),
TGP_KEY_MEDIA_SIZE, TGP_DEFAULT_MEDIA_SIZE) << 10;
}
int tls_get_ft_autoload (struct tgl_state *TLS) {
return ! strcmp (purple_account_get_string (tls_get_pa (TLS), TGP_KEY_FT_HANDLING, TGP_DEFAULT_FT_HANDLING), "autoload");
}
int tls_get_ft_discard (struct tgl_state *TLS) {
return ! strcmp (purple_account_get_string (tls_get_pa (TLS), TGP_KEY_FT_HANDLING, TGP_DEFAULT_FT_HANDLING), "discard");
}
connection_data *gc_get_data (PurpleConnection *gc) {
return purple_connection_get_protocol_data (gc);
}

View file

@ -27,9 +27,7 @@
PurpleAccount *tls_get_pa (struct tgl_state *TLS);
PurpleConnection *tls_get_conn (struct tgl_state *TLS);
connection_data *tls_get_data (struct tgl_state *TLS);
int tls_get_ft_threshold (struct tgl_state *TLS);
int tls_get_ft_discard (struct tgl_state *TLS);
int tls_get_ft_autoload (struct tgl_state *TLS);
int tls_get_media_threshold (struct tgl_state *TLS);
connection_data *gc_get_data (PurpleConnection *gc);
connection_data *pa_get_data (PurpleAccount *pa);
connection_data *pbn_get_data (PurpleBlistNode *node);

View file

@ -285,9 +285,7 @@ void tgprpl_kick_from_chat (PurpleConnection *gc, int id, const char *who) {
g_return_if_fail(P != NULL);
tgl_peer_t *other_id = tgp_blist_lookup_peer_get (gc_get_tls (gc), who);
if (other_id == NULL) {
return;
}
g_return_if_fail(P != NULL);
tgl_do_del_user_from_chat (gc_get_tls (gc), P->id, other_id->id, tgp_notify_on_error_gw, NULL);
}
@ -402,7 +400,7 @@ char *tgprpl_get_chat_name (GHashTable * data) {
return g_strdup (g_hash_table_lookup (data, "subject"));
}
static void tgp_chat_roomlist_add (tgl_peer_t *P, void *extra) {
static void tgp_chat_roomlist_it (tgl_peer_t *P, void *extra) {
connection_data *conn = extra;
if ((tgl_get_peer_type (P->id) == TGL_PEER_CHAT || tgl_get_peer_type (P->id) == TGL_PEER_CHANNEL)
@ -424,26 +422,6 @@ static void tgp_chat_roomlist_add (tgl_peer_t *P, void *extra) {
}
}
void tgp_chat_roomlist_populate (struct tgl_state *TLS) {
connection_data *conn = tls_get_data (TLS);
g_return_if_fail(purple_roomlist_get_in_progress (conn->roomlist));
GList *fields = NULL;
PurpleRoomlistField *f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_STRING, "", "id", TRUE);
fields = g_list_append (fields, f);
f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_INT, _("Users in chat"), "users", FALSE);
fields = g_list_append (fields, f);
f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_STRING, _("Type"), "type", FALSE);
fields = g_list_append (fields, f);
purple_roomlist_set_fields (conn->roomlist, fields);
tgl_peer_iterator_ex (conn->TLS, tgp_chat_roomlist_add, conn);
purple_roomlist_set_in_progress (conn->roomlist, FALSE);
}
PurpleRoomlist *tgprpl_roomlist_get_list (PurpleConnection *gc) {
debug ("tgprpl_roomlist_get_list()");
connection_data *conn = gc_get_data (gc);
@ -451,16 +429,21 @@ PurpleRoomlist *tgprpl_roomlist_get_list (PurpleConnection *gc) {
if (conn->roomlist) {
purple_roomlist_unref (conn->roomlist);
}
conn->roomlist = purple_roomlist_new (purple_connection_get_account (gc));
purple_roomlist_set_in_progress (conn->roomlist, TRUE);
// spectrum2 calls this function when the account is still connection
// all roomlists in progress are being initialised by tgp_on_ready
if (conn->dialogues_ready) {
tgp_chat_roomlist_populate (conn->TLS);
}
GList *fields = NULL;
PurpleRoomlistField *f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_STRING, "", "id", TRUE);
fields = g_list_append (fields, f);
f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_INT, _("Users in chat"), "users", FALSE);
fields = g_list_append (fields, f);
f = purple_roomlist_field_new (PURPLE_ROOMLIST_FIELD_STRING, _("Type"), "type", FALSE);
fields = g_list_append (fields, f);
purple_roomlist_set_fields (conn->roomlist, fields);
tgl_peer_iterator_ex (conn->TLS, tgp_chat_roomlist_it, conn);
return conn->roomlist;
}

View file

@ -52,7 +52,6 @@ void tgprpl_chat_join (PurpleConnection *gc, GHashTable *data);
GList *tgprpl_chat_join_info (PurpleConnection *gc);
PurpleRoomlist *tgprpl_roomlist_get_list (PurpleConnection *gc);
void tgprpl_roomlist_cancel (PurpleRoomlist *list);
void tgp_chat_roomlist_populate (struct tgl_state *TLS);
GHashTable *tgprpl_chat_info_defaults (PurpleConnection *gc, const char *chat_name);
void tgp_chat_join_all_pending (struct tgl_state *TLS);
void tgprpl_kick_from_chat (PurpleConnection *gc, int id, const char *who);

146
tgp-msg.c
View file

@ -186,26 +186,6 @@ static char *format_geo_link_osm (double lat, double lon) {
return link;
}
static char *format_document (const char *path, const char *filename, const char* caption, const char *mime, long long size) {
gchar *format;
gchar *capt = g_markup_escape_text (caption, -1);
gchar *pth = g_markup_escape_text (path, -1);
gchar *fle = g_markup_escape_text (filename, -1);
gchar *mme = g_markup_escape_text (mime, -1);
gchar *fsize = g_format_size (size);
format = g_strdup_printf ("[%s <a href=\"file:///%s\">%s</a> %s %s]", capt, pth, fle, mme, fsize);
g_free (capt);
g_free (pth);
g_free (fle);
g_free (mme);
g_free (fsize);
return format;
}
static void tgp_msg_send_done (struct tgl_state *TLS, void *callback_extra, int success, struct tgl_message *M) {
if (! success) {
char *err = _("Sending message failed.");
@ -316,16 +296,6 @@ static char *tgp_msg_markdown_convert (const char *msg) {
int len = (int) strlen (msg);
char *html = g_new0(gchar, 3 * len);
// strip any known-breaking html tags
#define STRIP_BROKEN_HTML(PREFIX,SUFFIX) \
if (g_str_has_prefix (msg, (PREFIX)) && g_str_has_suffix (msg, (SUFFIX))) { \
msg += sizeof(PREFIX) - 1; \
len -= (sizeof(PREFIX) - 1) + (sizeof(SUFFIX) - 1); \
}
STRIP_BROKEN_HTML("<SPAN style=\"direction:rtl;text-align:right;\">","</SPAN>");
// more STRIP_BROKEN_HTML invocations here, if necessary
#undef STRIP_BROKEN_HTML
int open = FALSE;
int i, j;
for (i = 0, j = 0; i < len; i ++) {
@ -351,6 +321,7 @@ static char *tgp_msg_markdown_convert (const char *msg) {
}
int tgp_msg_send (struct tgl_state *TLS, const char *message, tgl_peer_id_t to) {
// send all inline images
GList *imgs = tgp_msg_imgs_parse (message);
debug ("parsed %d images in messages", g_list_length (imgs));
@ -405,6 +376,15 @@ int tgp_msg_send (struct tgl_state *TLS, const char *message, tgl_peer_id_t to)
return 0;
}
static char *tgp_msg_file_display (const char *path, const char *filename, const char* caption, const char *mime, long long size) {
gchar *fsize = g_format_size(size);
gchar *format;
format = g_strdup_printf ("[%s <a href=\"file:///%s\">%s</a> %s %s]", g_markup_escape_text (caption, -1), g_markup_escape_text (path, -1),
g_markup_escape_text (filename, -1), g_markup_escape_text (mime, -1), fsize);
g_free (fsize);
return format;
}
static char *tgp_msg_photo_display (struct tgl_state *TLS, const char *filename, int *flags) {
connection_data *conn = TLS->ev_base;
int img = p2tgl_imgstore_add_with_id (filename);
@ -510,61 +490,55 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) {
}
break;
}
case tgl_message_media_document:
case tgl_message_media_video:
case tgl_message_media_audio:
if (M->media.document->flags & TGLDF_STICKER) {
g_return_if_fail(C->data != NULL);
text = tgp_msg_sticker_display (TLS, M->from_id, C->data, &flags);
} else if (M->media.document->flags & TGLDF_IMAGE && !(M->media.document->flags & TGLDF_ANIMATED)) {
} else if (M->media.document->flags & TGLDF_ANIMATED) {
g_return_if_fail(C->data != NULL);
text = tgp_msg_file_display (C->data, M->media.document->caption, _("animation"),
M->media.document->mime_type, M->media.document->size);
} else if (M->media.document->flags & TGLDF_IMAGE) {
g_return_if_fail(C->data != NULL);
text = tgp_msg_photo_display (TLS, C->data, &flags);
} else {
// Automatically loaded files have C->data set to the file path
if (C->data) {
const char* path = C->data;
// Content of a file transfer
const char *caption = _("document");
if (M->media.document->flags & TGLDF_AUDIO) {
// Content of a file transfer
caption = _("audio");
} else if (M->media.document->flags & TGLDF_ANIMATED) {
// Content of a file transfer
caption = _("animation");
} else if (M->media.document->flags & TGLDF_VIDEO) {
// Content of a file transfer
caption = _("video");
}
const char *filename = M->media.document->caption;
if (! str_not_empty (filename)) {
// audio and video snippets recorded from Telegram don't have captions
const char *segment = path + strlen(path) - 1;
while (segment > (char *)path && *segment != G_DIR_SEPARATOR) {
segment --;
}
filename = segment + 1;
}
const char *mime = "";
if (str_not_empty (M->media.document->mime_type)) {
mime = M->media.document->mime_type;
}
text = format_document (path, filename, caption, mime, M->media.document->size);
} else {
if (! tgp_our_msg (TLS, M) && ! tls_get_ft_discard (TLS)) {
if (! tgp_our_msg (TLS, M)) {
if (C->data) {
text = tgp_msg_file_display (C->data, M->media.document->caption, _("document"),
M->media.document->mime_type, M->media.document->size);
} else {
tgprpl_recv_file (tls_get_conn (TLS), tgp_blist_lookup_purple_name (TLS, M->from_id), M);
return;
}
return;
}
}
break;
case tgl_message_media_video:
case tgl_message_media_audio: {
if (! tgp_our_msg (TLS, M)) {
if (C->data) {
const char *filename = C->data + strlen(C->data) - 1;
while (filename > (char *)C->data && *filename != G_DIR_SEPARATOR) {
filename --;
}
filename ++;
text = tgp_msg_file_display (C->data, filename,
M->media.type == tgl_message_media_audio ? _("audio") : _("video"),
M->media.document->mime_type, M->media.document->size);
} else {
tgprpl_recv_file (tls_get_conn (TLS), tgp_blist_lookup_purple_name (TLS, M->from_id), M);
return;
}
}
}
break;
case tgl_message_media_document_encr:
if (M->media.encr_document->flags & TGLDF_STICKER) {
g_return_if_fail(C->data != NULL);
@ -577,8 +551,7 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) {
} else {
if (! tgp_our_msg (TLS, M)) {
if (C->data) {
// Content of a file transfer
text = format_document (C->data, M->media.encr_document->caption, _("document"),
text = tgp_msg_file_display (C->data, M->media.encr_document->caption, _("document"),
M->media.encr_document->mime_type, M->media.encr_document->size);
} else {
@ -863,7 +836,6 @@ void tgp_msg_recv (struct tgl_state *TLS, struct tgl_message *M, GList *before)
}
if (! (M->flags & TGLMF_SERVICE)) {
debug ("service msg");
// handle all messages that need to load content before they can be displayed
if (M->media.type != tgl_message_media_none) {
@ -882,35 +854,43 @@ void tgp_msg_recv (struct tgl_state *TLS, struct tgl_message *M, GList *before)
// documents that are stickers or images will be displayed just like regular photo messages
// and need to be loaded beforehand
case tgl_message_media_document:
case tgl_message_media_video:
case tgl_message_media_audio:
if (M->media.document->flags & (TGLDF_STICKER | TGLDF_IMAGE)) {
++ C->pending;
tgl_do_load_document (TLS, M->media.document, tgp_msg_on_loaded_document, C);
} else {
// adium doesn't support printing an inline file link to the downloaded file
// adium doesn't support file links, autoloading media would mean that it
// wouldn't be possible to show a usable link to the user
#ifndef __ADIUM_
if (M->media.document->size <= tls_get_ft_threshold (TLS) || tls_get_ft_autoload (TLS)) {
if (M->media.document->size <= tls_get_media_threshold (TLS)) {
++ C->pending;
if (M->media.document->flags & TGLDF_AUDIO) {
tgl_do_load_audio (TLS, M->media.document, tgp_msg_on_loaded_document, C);
} else if (M->media.document->flags & TGLDF_VIDEO) {
tgl_do_load_video (TLS, M->media.document, tgp_msg_on_loaded_document, C);
} else {
tgl_do_load_document (TLS, M->media.document, tgp_msg_on_loaded_document, C);
}
}
#endif
}
break;
#ifndef __ADIUM_
case tgl_message_media_video:
if (M->media.document->size <= tls_get_media_threshold (TLS)) {
++ C->pending;
tgl_do_load_video (TLS, M->media.document, tgp_msg_on_loaded_document, C);
}
break;
case tgl_message_media_audio:
if (M->media.document->size <= tls_get_media_threshold (TLS)) {
++ C->pending;
tgl_do_load_audio (TLS, M->media.document, tgp_msg_on_loaded_document, C);
}
break;
#endif
case tgl_message_media_document_encr:
if (M->media.encr_document->flags & TGLDF_STICKER || M->media.encr_document->flags & TGLDF_IMAGE) {
++ C->pending;