File: modules.cpp

package info (click to toggle)
sipwitch 1.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,768 kB
  • sloc: cpp: 16,534; sh: 11,336; makefile: 206; xml: 24; ansic: 20
file content (121 lines) | stat: -rw-r--r-- 3,029 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// 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 3 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/>.

#include <config.h>
#include <ucommon/ucommon.h>
#include <ucommon/export.h>
#include <sipwitch/modules.h>
#include <sipwitch/control.h>
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

using namespace SIPWITCH_NAMESPACE;
using namespace UCOMMON_NAMESPACE;

modules::protocols *modules::protocols::instance = NULL;

modules::protocols::protocols()
{
    assert(instance == NULL);

    instance = this;
}

modules::sipwitch::sipwitch() :
service::callback(MODULE_RUNLEVEL)
{
}

modules::generic::generic() :
service::callback(GENERIC_RUNLEVEL)
{
}

void modules::sipwitch::activating(MappedRegistry *rr)
{
}

void modules::sipwitch::expiring(MappedRegistry *rr)
{
}

void modules::sipwitch::period(long slice)
{
}

bool modules::sipwitch::announce(MappedRegistry *rr, const char *msgtype, const char *event, const char *expires, const char *msgbody)
{
    return false;
}

void modules::sipwitch::registration(int id, regmode_t mode)
{
}

bool modules::sipwitch::authenticate(int id, const char *realm)
{
    return false;
}

char *modules::sipwitch::referLocal(MappedRegistry *rr, const char *target, char *buffer, size_t size)
{
    return NULL;
}

char *modules::sipwitch::referRemote(MappedRegistry *rr, const char *target, char *buffer, size_t size)
{
    return NULL;
}

void modules::errlog(shell::loglevel_t level, const char *text)
{
    linked_pointer<service::callback> cb = service::getModules();

    while(is(cb)) {
        cb->errlog(level, text);
        cb.next();
    }
}

void modules::cdrlog(FILE *fp, cdr *call)
{
    DateTimeString dt(call->starting);
    const char *buf = dt.c_str();

    if(call->type == cdr::STOP) {
        shell::debug(1, "call %08x:%u %s %s %s %ld %s %s %s %s",
            call->sequence, call->cid, call->network, call->reason, buf,
            call->duration, call->ident, call->dialed, call->joined, call->display);
    }

    linked_pointer<service::callback> cb = service::getModules();

    while(is(cb)) {
        cb->cdrlog(call);
        cb.next();
    }

    if(!fp || call->type != cdr::STOP)
        return;

    fprintf(fp, "%08x:%u %s %s %s %ld %s %s %s %s\n",
        call->sequence, call->cid, call->network, call->reason, buf,
        call->duration, call->ident, call->dialed, call->joined, call->display);
}