1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 #include <sipwitch-config.h>
19
20 namespace sipwitch {
21
22 static const char *dirpath = NULL;
23 static char prior[65] = "down";
24
26 {
27 public:
29
30 private:
35 };
36
38
41 {
42 shell::log(shell::INFO, "scripting plugin loaded");
43 }
44
46 {
47 assert(cfg != NULL);
48
49 if(dirpath == NULL)
51
52 if(!dirpath)
53 return;
54
55 const char *state = cfg->
getRoot()->getPointer();
56 if(!state)
57 state = "up";
58
59 if(String::equal(state, prior))
60 return;
61
63
64 String::set(prior, sizeof(prior), state);
65 }
66
68 {
69 assert(cfg != NULL);
70
71 static char buf[256];
73
74 if(fsys::is_dir(DEFAULT_CFGPATH "/sysconfig/sipwitch-scripts"))
75 dirpath = DEFAULT_CFGPATH "/sysconfig/sipwitch-scripts";
76 else if(fsys::is_dir(DEFAULT_LIBEXEC "/sipwitch"))
77 dirpath = DEFAULT_LIBEXEC "/sipwitch";
78 else if(home) {
79 snprintf(buf, sizeof(buf), "%s/.sipwitch-scripts", home);
80 if(fsys::is_dir(buf))
81 dirpath = buf;
82 }
83
84 if(dirpath)
85 shell::log(shell::INFO, "scripting plugin path %s", dirpath);
86 else
87 shell::log(shell::ERR, "scripting plugin disabled; no script directory");
88 }
89
91 {
92 char addr[128];
93 if(!dirpath)
94 return;
95
96 Socket::query((
struct sockaddr *)&rr->
contact, addr,
sizeof(addr));
98 addr, Socket::port((
struct sockaddr *)&rr->
contact),
100 }
101
103 {
104 if(!dirpath)
105 return;
106
108 }
109
110 } // end namespace
Representation of a mapped active user record.
sockaddr_internet contact
Top level include directory for GNU Telephony SIP Witch Server.
void reload(service *cfg)
static bool libexec(const char *fmt,...) __PRINTF(1
Execute an external shell command on behalf of the server.
void expiring(MappedRegistry *rr)
Notify plugins a user registration has been expired or released.
void activating(MappedRegistry *rr)
Notify plugins a user registration is being activated.
System configuration instance and service functions.
Common interfaces and clases for plugins.
Common base class for sipwitch plugin services.
static const char * env(const char *id)
Return the value of a server environment variable.
enum sipwitch::MappedRegistry::@5 type