~davewalker/ubuntu/maverick/asterisk/lp_705014

« back to all changes in this revision

Viewing changes to apps/app_sendtext.c

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2005-03-09 22:09:05 UTC
  • mto: (1.2.1 upstream) (8.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050309220905-9afy6hcpw96xbr6j
Tags: upstream-1.0.6
ImportĀ upstreamĀ versionĀ 1.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Asterisk -- A telephony toolkit for Linux.
 
3
 *
 
4
 * App to transmit a text message
 
5
 * 
 
6
 * Copyright (C) 1999, Mark Spencer
 
7
 *
 
8
 * Mark Spencer <markster@linux-support.net>
 
9
 *
 
10
 * This program is free software, distributed under the terms of
 
11
 * the GNU General Public License
 
12
 */
 
13
 
 
14
#include <asterisk/lock.h>
 
15
#include <asterisk/file.h>
 
16
#include <asterisk/logger.h>
 
17
#include <asterisk/channel.h>
 
18
#include <asterisk/channel_pvt.h>
 
19
#include <asterisk/pbx.h>
 
20
#include <asterisk/module.h>
 
21
#include <asterisk/translate.h>
 
22
#include <asterisk/image.h>
 
23
#include <string.h>
 
24
#include <stdlib.h>
 
25
 
 
26
static char *tdesc = "Send Text Applications";
 
27
 
 
28
static char *app = "SendText";
 
29
 
 
30
static char *synopsis = "Send a Text Message";
 
31
 
 
32
static char *descrip = 
 
33
"  SendText(text): Sends text to client.  If the client\n"
 
34
"does not support text transport, and  there  exists  a  step  with\n"
 
35
"priority  n + 101,  then  execution  will  continue  at that step.\n"
 
36
"Otherwise, execution will continue at  the  next  priority  level.\n"
 
37
"SendText only returns 0  if  the  text  was  sent  correctly  or  if\n"
 
38
"the channel  does  not  support text transport,  and -1 otherwise.\n";
 
39
 
 
40
STANDARD_LOCAL_USER;
 
41
 
 
42
LOCAL_USER_DECL;
 
43
 
 
44
static int sendtext_exec(struct ast_channel *chan, void *data)
 
45
{
 
46
        int res = 0;
 
47
        struct localuser *u;
 
48
        if (!data || !strlen((char *)data)) {
 
49
                ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
 
50
                return -1;
 
51
        }
 
52
        LOCAL_USER_ADD(u);
 
53
        ast_mutex_lock(&chan->lock);
 
54
        if (!chan->pvt->send_text) {
 
55
                ast_mutex_unlock(&chan->lock);
 
56
                /* Does not support transport */
 
57
                if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
 
58
                        chan->priority += 100;
 
59
                LOCAL_USER_REMOVE(u);
 
60
                return 0;
 
61
        }
 
62
        ast_mutex_unlock(&chan->lock);
 
63
        res = ast_sendtext(chan, (char *)data);
 
64
        LOCAL_USER_REMOVE(u);
 
65
        return res;
 
66
}
 
67
 
 
68
int unload_module(void)
 
69
{
 
70
        STANDARD_HANGUP_LOCALUSERS;
 
71
        return ast_unregister_application(app);
 
72
}
 
73
 
 
74
int load_module(void)
 
75
{
 
76
        return ast_register_application(app, sendtext_exec, synopsis, descrip);
 
77
}
 
78
 
 
79
char *description(void)
 
80
{
 
81
        return tdesc;
 
82
}
 
83
 
 
84
int usecount(void)
 
85
{
 
86
        int res;
 
87
        STANDARD_USECOUNT(res);
 
88
        return res;
 
89
}
 
90
 
 
91
char *key()
 
92
{
 
93
        return ASTERISK_GPL_KEY;
 
94
}