Commit 7d7a40a8 authored by vvaltman's avatar vvaltman

Fixed configure. Added fwd_media command

parent 19e06898
srcdir=@srcdir@ srcdir=@srcdir@
CFLAGS=@CFLAGS@ CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@ LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@
CPPFLAGS=@CPPFLAGS@ CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@
DEFS=@DEFS@ DEFS=@DEFS@
COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ @OPENSSL_LIBS@
LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS} LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS}
LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
......
...@@ -21,16 +21,9 @@ ...@@ -21,16 +21,9 @@
/* Define to 1 if you have the <lauxlib.h> header file. */ /* Define to 1 if you have the <lauxlib.h> header file. */
#undef HAVE_LAUXLIB_H #undef HAVE_LAUXLIB_H
/* Define to 1 if you have the `AES_set_encrypt_key' library
(-lAES_set_encrypt_key). */
#undef HAVE_LIBAES_SET_ENCRYPT_KEY
/* Define to 1 if you have the `config' library (-lconfig). */ /* Define to 1 if you have the `config' library (-lconfig). */
#undef HAVE_LIBCONFIG #undef HAVE_LIBCONFIG
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define to 1 if you have the `edit' library (-ledit). */ /* Define to 1 if you have the `edit' library (-ledit). */
#undef HAVE_LIBEDIT #undef HAVE_LIBEDIT
...@@ -40,7 +33,7 @@ ...@@ -40,7 +33,7 @@
/* Define to 1 if you have the `m' library (-lm). */ /* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM #undef HAVE_LIBM
/* Define to 1 if you have the `z' library (-lz). */ /* Define to 1 if you have `z' library (-lz) */
#undef HAVE_LIBZ #undef HAVE_LIBZ
/* Define to 1 if you have the <luaconf.h> header file. */ /* Define to 1 if you have the <luaconf.h> header file. */
......
This diff is collapsed.
AC_PREREQ([2.68]) AC_PREREQ([2.68])
AC_INIT([telegram], [0.1]) AC_INIT([telegram-cli], [1.0])
AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
m4_include([ax_lua.m4]) m4_include([ax_lua.m4])
m4_include([m4_ax_check_openssl.m4])
m4_include([m4_ax_check_zlib.m4])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
...@@ -16,11 +18,16 @@ LDFLAGS="$LDFLAGS -L/usr/local/lib" ...@@ -16,11 +18,16 @@ LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_CHECK_LIB([m], [sqrt]) AC_CHECK_LIB([m], [sqrt])
AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([backtrace], [execinfo]) AC_SEARCH_LIBS([backtrace], [execinfo])
AC_CHECK_LIB([z], [inflate]) AC_CHECK_LIB([event], [event_base_new], [], [AC_MSG_ERROR([no libevent found])])
AC_CHECK_LIB([crypto], [AES_set_encrypt_key])
AC_CHECK_LIB([event], [event_base_new])
EXTRA_LIBS="" EXTRA_LIBS=""
# OPENSSL_INCLUDES to the include directives required
# OPENSSL_LIBS to the -l directives required
# OPENSSL_LDFLAGS to the -L or -R flags required
AX_CHECK_OPENSSL(,[AC_MSG_ERROR([No openssl found])])
AX_CHECK_ZLIB(, [AC_MSG_ERROR([No zlib found])])
AC_CHECK_LIB([readline], [rl_save_prompt], AC_CHECK_LIB([readline], [rl_save_prompt],
[ [
AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline]) AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline])
......
...@@ -354,6 +354,7 @@ struct command commands[] = { ...@@ -354,6 +354,7 @@ struct command commands[] = {
{"chat_info", {ca_chat, ca_none}}, {"chat_info", {ca_chat, ca_none}},
{"user_info", {ca_user, ca_none}}, {"user_info", {ca_user, ca_none}},
{"fwd", {ca_peer, ca_number, ca_none}}, {"fwd", {ca_peer, ca_number, ca_none}},
{"fwd_media", {ca_peer, ca_number, ca_none}},
{"msg", {ca_peer, ca_string_end}}, {"msg", {ca_peer, ca_string_end}},
{"rename_chat", {ca_peer, ca_string_end}}, {"rename_chat", {ca_peer, ca_string_end}},
{"load_photo", {ca_number, ca_none}}, {"load_photo", {ca_number, ca_none}},
...@@ -1180,6 +1181,14 @@ void interpreter (char *line UU) { ...@@ -1180,6 +1181,14 @@ void interpreter (char *line UU) {
RET; RET;
} }
tgl_do_forward_message (id, num, 0, 0); tgl_do_forward_message (id, num, 0, 0);
} else if (IS_WORD ("fwd_media")) {
GET_PEER;
int num = next_token_int ();
if (num == NOT_FOUND || num <= 0) {
printf ("Bad msg id\n");
RET;
}
tgl_do_forward_media (id, num, 0, 0);
} else if (IS_WORD ("load_photo")) { } else if (IS_WORD ("load_photo")) {
long long num = next_token_int (); long long num = next_token_int ();
if (num == NOT_FOUND) { if (num == NOT_FOUND) {
......
...@@ -455,6 +455,7 @@ enum lua_query_type { ...@@ -455,6 +455,7 @@ enum lua_query_type {
lq_send_video, lq_send_video,
lq_send_text, lq_send_text,
lq_fwd, lq_fwd,
lq_fwd_media,
lq_load_photo, lq_load_photo,
lq_load_video_thumb, lq_load_video_thumb,
lq_load_video, lq_load_video,
...@@ -922,6 +923,10 @@ void lua_do_all (void) { ...@@ -922,6 +923,10 @@ void lua_do_all (void) {
tgl_do_forward_message (((tgl_peer_t *)lua_ptr[p + 1])->id, ((struct tgl_message *)lua_ptr[p + 2])->id, lua_msg_cb, lua_ptr[p]); tgl_do_forward_message (((tgl_peer_t *)lua_ptr[p + 1])->id, ((struct tgl_message *)lua_ptr[p + 2])->id, lua_msg_cb, lua_ptr[p]);
p += 3; p += 3;
break; break;
case lq_fwd_media:
tgl_do_forward_media (((tgl_peer_t *)lua_ptr[p + 1])->id, ((struct tgl_message *)lua_ptr[p + 2])->id, lua_msg_cb, lua_ptr[p]);
p += 3;
break;
case lq_chat_info: case lq_chat_info:
tgl_do_get_chat_info (((tgl_peer_t *)lua_ptr[p + 1])->id, 0, lua_chat_cb, lua_ptr[p]); tgl_do_get_chat_info (((tgl_peer_t *)lua_ptr[p + 1])->id, 0, lua_chat_cb, lua_ptr[p]);
p += 2; p += 2;
...@@ -1077,6 +1082,7 @@ struct lua_function functions[] = { ...@@ -1077,6 +1082,7 @@ struct lua_function functions[] = {
{"load_document", lq_load_document, { lfp_msg, lfp_none }}, {"load_document", lq_load_document, { lfp_msg, lfp_none }},
{"load_document_thumb", lq_load_document_thumb, { lfp_msg, lfp_none }}, {"load_document_thumb", lq_load_document_thumb, { lfp_msg, lfp_none }},
{"fwd_msg", lq_fwd, { lfp_peer, lfp_msg, lfp_none }}, {"fwd_msg", lq_fwd, { lfp_peer, lfp_msg, lfp_none }},
{"fwd_media", lq_fwd_media, { lfp_peer, lfp_msg, lfp_none }},
{"chat_info", lq_chat_info, { lfp_chat, lfp_none }}, {"chat_info", lq_chat_info, { lfp_chat, lfp_none }},
{"user_info", lq_user_info, { lfp_user, lfp_none }}, {"user_info", lq_user_info, { lfp_user, lfp_none }},
{"get_history", lq_history, { lfp_peer, lfp_nonnegative_number, lfp_none }}, {"get_history", lq_history, { lfp_peer, lfp_nonnegative_number, lfp_none }},
......
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]])
#
# DESCRIPTION
#
# Look for OpenSSL in a number of default spots, or in a user-selected
# spot (via --with-openssl). Sets
#
# OPENSSL_INCLUDES to the include directives required
# OPENSSL_LIBS to the -l directives required
# OPENSSL_LDFLAGS to the -L or -R flags required
#
# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
#
# This macro sets OPENSSL_INCLUDES such that source files should use the
# openssl/ directory in include directives:
#
# #include <openssl/hmac.h>
#
# LICENSE
#
# Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
# Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 8
AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
AC_DEFUN([AX_CHECK_OPENSSL], [
found=false
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--with-openssl=DIR],
[root of the OpenSSL directory])],
[
case "$withval" in
"" | y | ye | yes | n | no)
AC_MSG_ERROR([Invalid --with-openssl value])
;;
*) ssldirs="$withval"
;;
esac
], [
# if pkg-config is installed and openssl has installed a .pc file,
# then use that information and don't search ssldirs
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
if test x"$PKG_CONFIG" != x""; then
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
if test $? = 0; then
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
found=true
fi
fi
# no such luck; use some default ssldirs
if ! $found; then
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
fi
]
)
# note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
# an 'openssl' subdirectory
if ! $found; then
OPENSSL_INCLUDES=
for ssldir in $ssldirs; do
AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
if test -f "$ssldir/include/openssl/ssl.h"; then
OPENSSL_INCLUDES="-I$ssldir/include"
OPENSSL_LDFLAGS="-L$ssldir/lib"
OPENSSL_LIBS="-lssl -lcrypto"
found=true
AC_MSG_RESULT([yes])
break
else
AC_MSG_RESULT([no])
fi
done
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
# it will just work!
fi
# try the preprocessor and linker with our new flags,
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
"OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
LIBS="$OPENSSL_LIBS $LIBS"
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
[
AC_MSG_RESULT([yes])
$1
], [
AC_MSG_RESULT([no])
$2
])
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
AC_SUBST([OPENSSL_INCLUDES])
AC_SUBST([OPENSSL_LIBS])
AC_SUBST([OPENSSL_LDFLAGS])
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
#
# DESCRIPTION
#
# This macro searches for an installed zlib library. If nothing was
# specified when calling configure, it searches first in /usr/local and
# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
# --without-zlib is specified, the library is not searched at all.
#
# If either the header file (zlib.h) or the library (libz) is not found,
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
# not specified, the configuration exits on error, asking for a valid zlib
# installation directory or --without-zlib.
#
# If both header file and library are found, shell commands
# 'action-if-found' is run. If 'action-if-found' is not specified, the
# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
# for this symbol in a config.h file. Sample usage in a C/C++ source is as
# follows:
#
# #ifdef HAVE_LIBZ
# #include <zlib.h>
# #endif /* HAVE_LIBZ */
#
# LICENSE
#
# Copyright (c) 2008 Loic Dachary <loic@senga.org>
# Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 14
AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
AC_DEFUN([AX_CHECK_ZLIB],
#
# Handle user hints
#
[AC_MSG_CHECKING(if zlib is wanted)
zlib_places="/usr/local /usr /opt/local /sw"
AC_ARG_WITH([zlib],
[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to
/usr/local or /usr if not found in /usr/local@:>@
--without-zlib to disable zlib usage completely],
[if test "$withval" != no ; then
AC_MSG_RESULT(yes)
if test -d "$withval"
then
zlib_places="$withval $zlib_places"
else
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
fi
else
zlib_places=
AC_MSG_RESULT(no)
fi],
[AC_MSG_RESULT(yes)])
#
# Locate zlib, if wanted
#
if test -n "${zlib_places}"
then
# check the user supplied or any other more or less 'standard' place:
# Most UNIX systems : /usr/local and /usr
# MacPorts / Fink on OSX : /opt/local respectively /sw
for ZLIB_HOME in ${zlib_places} ; do
if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
ZLIB_HOME=""
done
ZLIB_OLD_LDFLAGS=$LDFLAGS
ZLIB_OLD_CPPFLAGS=$CPPFLAGS
if test -n "${ZLIB_HOME}"; then
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
fi
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
AC_LANG_RESTORE
if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
then
#
# If both library and header were found, action-if-found
#
m4_ifblank([$1],[
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
LIBS="-lz $LIBS"
AC_DEFINE([HAVE_LIBZ], [1],
[Define to 1 if you have `z' library (-lz)])
],[
# Restore variables
LDFLAGS="$ZLIB_OLD_LDFLAGS"
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
$1
])
else
#
# If either header or library was not found, action-if-not-found
#
m4_default([$2],[
AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
])
fi
fi
])
...@@ -1858,6 +1858,66 @@ void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, co ...@@ -1858,6 +1858,66 @@ void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, co
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra); tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
} }
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra) {
if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) {
vlogprintf (E_WARNING, "Can not forward messages from secret chat\n");
callback (callback_extra, 0, 0);
return;
}
struct tgl_message *M = tgl_message_get (n);
if (!M) {
vlogprintf (E_WARNING, "No such message\n");
callback (callback_extra, 0, 0);
return;
}
if (M->flags & FLAG_ENCRYPTED) {
vlogprintf (E_WARNING, "Can not forward media from encrypted message\n");
callback (callback_extra, 0, 0);
return;
}
if (M->media.type != tgl_message_media_photo && M->media.type != tgl_message_media_video && M->media.type != tgl_message_media_audio && M->media.type != tgl_message_media_document) {
vlogprintf (E_WARNING, "Can only forward photo/audio/video/document\n");
callback (callback_extra, 0, 0);
return;
}
clear_packet ();
out_int (CODE_messages_send_media);
out_peer_id (id);
switch (M->media.type) {
case tgl_message_media_photo:
out_int (CODE_input_media_photo);
out_int (CODE_input_photo);
out_long (M->media.photo.id);
out_long (M->media.photo.access_hash);
break;
case tgl_message_media_video:
out_int (CODE_input_media_video);
out_int (CODE_input_video);
out_long (M->media.video.id);
out_long (M->media.video.access_hash);
break;
case tgl_message_media_audio:
out_int (CODE_input_media_audio);
out_int (CODE_input_audio);
out_long (M->media.audio.id);
out_long (M->media.audio.access_hash);
break;
case tgl_message_media_document:
out_int (CODE_input_media_document);
out_int (CODE_input_document);
out_long (M->media.document.id);
out_long (M->media.document.access_hash);
break;
default:
assert (0);
}
long long r;
tglt_secure_random (&r, 8);
out_long (r);
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
}
/* }}} */ /* }}} */
/* {{{ Rename chat */ /* {{{ Rename chat */
......
...@@ -280,6 +280,7 @@ void tgl_do_help_get_config_dc (struct tgl_dc *D, void (*callback)(void *, int), ...@@ -280,6 +280,7 @@ void tgl_do_help_get_config_dc (struct tgl_dc *D, void (*callback)(void *, int),
void tgl_do_export_card (void (*callback)(void *callback_extra, int success, int size, int *card), void *callback_extra); void tgl_do_export_card (void (*callback)(void *callback_extra, int success, int size, int *card), void *callback_extra);
void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra); void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra);
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]); void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment