1 /*!
2  * \file        sccp_line.h
3  * \brief       SCCP Line Header
4  * \author      Sergio Chersovani <mlists [at] c-net.it>
5  * \note        Reworked, but based on chan_sccp code.
6  *              The original chan_sccp driver that was made by Zozo which itself was derived from the chan_skinny driver.
7  *              Modified by Jan Czmok and Julien Goodwin
8  * \note        This program is free software and may be modified and distributed under the terms of the GNU Public License.
9  *              See the LICENSE file at the top of the source tree.
10  *
11  */
12 #pragma once
13 
14 #define sccp_line_retain(_x)			sccp_refcount_retain_type(sccp_line_t, _x)
15 #define sccp_line_release(_x)			sccp_refcount_release_type(sccp_line_t, _x)
16 #define sccp_line_refreplace(_x, _y)		sccp_refcount_refreplace_type(sccp_line_t, _x, _y)
17 __BEGIN_C_EXTERN__
18 /*!
19  * \brief SCCP Line Structure
20  * \note A line is the equivalent of a 'phone line' going to the phone.
21  */
22 struct sccp_line {
23 	//sccp_mutex_t lock;											/*!< Asterisk: Lock Me Up and Tie me Down */
24 	char id[SCCP_MAX_LINE_ID];										/*!< This line's ID, used for login (for mobility) */
25 	char name[StationMaxNameSize];										/*!< The name of the line, so use in asterisk (i.e SCCP/[name]) */
26 	uint32_t configurationStatus;										/*!< what is the current configuration status - @see sccp_config_status_t */
27 #ifdef CS_SCCP_REALTIME
28 	boolean_t realtime;											/*!< is it a realtimeconfiguration */
29 	uint8_t _padding1[3];
30 #endif
31 	SCCP_RWLIST_ENTRY (sccp_line_t) list;									/*!< global list entry */
32 	struct {
33 		uint8_t numberOfActiveDevices;									/*!< Number of Active Devices */
34 		uint8_t numberOfActiveChannels;									/*!< Number of Active Channels */
35 		uint8_t numberOfHeldChannels;									/*!< Number of Hold Channels */
36 		uint8_t numberOfDNDDevices;									/*!< Number of DND Devices */
37 	} statistic;												/*!< Statistics for Line Structure */
38 
39 	uint8_t incominglimit;											/*!< max incoming calls limit */
40 	skinny_tone_t initial_dialtone_tone;                                                                    /*!< initial dialtone tone */
41 	skinny_tone_t secondary_dialtone_tone;									/*!< secondary dialtone tone */
42 	char secondary_dialtone_digits[SCCP_MAX_SECONDARY_DIALTONE_DIGITS];					/*!< secondary dialtone digits */
43 
44 	char *trnsfvm;												/*!< transfer to voicemail softkey. Basically a call forward */
45 	sccp_group_t callgroup;											/*!< callgroups assigned (seperated by commas) to this lines */
46 #ifdef CS_SCCP_PICKUP
47 	sccp_group_t pickupgroup;										/*!< pickupgroup assigned to this line */
48 
49 	boolean_t directed_pickup;										/*!< Directed Pickup Extension Support (Boolean, default=on) */
50 	char directed_pickup_context[SCCP_MAX_CONTEXT];								/*!< Directed Pickup Context to Use in DialPlan */
51 	boolean_t pickup_modeanswer;										/*!< Directed PickUp Mode Answer (boolean, default" on) */
52 #ifdef CS_AST_HAS_NAMEDGROUP
53 	char *namedcallgroup;											/*!< Named Call Group */
54 	char *namedpickupgroup;											/*!< Named Pickup Group */
55 #endif
56 #endif
57 	skinny_capabilities_t capabilities;									/*!< (shared)line level preferences (overrules device level) */
58 	skinny_capabilities_t preferences;									/*!< (shared)line level preferences (overrules device level) */
59 	boolean_t preferences_set_on_line_level;								/*!< (Temp) if above was set manually or automatically copied */
60 
61 	char cid_num[SCCP_MAX_EXTENSION];									/* smaller would be better (i.e. 32) */ /*!< Caller(ID) to use on outgoing calls  */
62 	char cid_name[SCCP_MAX_EXTENSION];									/* smaller would be better (i.e. 32) */ /*!< Caller(Name) to use on outgoing calls */
63 
64 	pbx_ama_flags_type amaflags;
65 	sccp_dndmode_t dndmode;											/*!< dnd mode: see SCCP_DNDMODE_* */
66 
67 	SCCP_LIST_HEAD (, sccp_mailbox_t) mailboxes;								/*!< Mailbox Linked List Entry. To check for messages */
68 	SCCP_LIST_HEAD (, sccp_channel_t) channels;								/*!< Linked list of current channels for this line */
69 	SCCP_LIST_HEAD(, sccp_linedevice_t) devices;                                                            /*!< The device this line is currently registered to. */
70 
71 	PBX_VARIABLE_TYPE *variables;										/*!< Channel variables to set */
72 	char pin[SCCP_MAX_LINE_PIN];										/*!< PIN number for mobility/roaming. */
73 	char *adhocNumber;											/*!< number that should be dialed when device offhocks this line */
74 	char *regexten;												/*!< Extension for auto-extension (DUNDI) */
75 	char *regcontext;											/*!< Context for auto-extension (DUNDI) */
76 	char *description;											/*!< A description for the line, displayed on in header (on7960/40) or on main  screen on 7910 */
77 	char *label;												/*!< A name for the line, displayed next to the button (7960/40). */
78 	char *vmnum;												/*!< Voicemail number to Dial */
79 	char *meetmenum;											/*!< Meetme Extension to be Dialed (\todo TO BE REMOVED) */
80 	char *meetmeopts;											/*!< Meetme Options to be Used */
81 	char *context;												/*!< The context we use for Outgoing Calls. */
82 	char *language;												/*!< language we use for calls */
83 	char *accountcode;											/*!< accountcode used in cdr */
84 	char *musicclass;											/*!< musicclass assigned when getting moh */
85 	char *parkinglot;											/*!< parkinglot to use */
86 
87 	sccp_subscription_id_t defaultSubscriptionId;								/*!< default subscription id for shared lines */
88 	boolean_t echocancel;											/*!< echocancel phone support */
89 	boolean_t silencesuppression;										/*!< Silence Suppression Phone Support */
90 	boolean_t meetme;											/*!< Meetme on/off */
91 	boolean_t isShared;
92 	/*!
93 	 * \brief VoiceMail Statistics Structure
94 	 */
95 	struct {
96 		int newmsgs;											/*!< New Messages */
97 		int oldmsgs;											/*!< Old Messages */
98 	} voicemailStatistic;											/*!< VoiceMail Statistics Structure */
99 	boolean_t transfer;											/*!< Transfer Phone Support */
100 
101 	sccp_video_mode_t videomode;
102 	/* this is for reload routines */
103 	boolean_t pendingDelete;										/*!< this bit will tell the scheduler to delete this line when unused */
104 	boolean_t pendingUpdate;										/*!< this bit will tell the scheduler to update this line when unused */
105 };														/*!< SCCP Line Structure */
106 
107 /*!
108  * \brief SCCP Hotline Structure
109  * \note This contains the new HotLine Feature
110  */
111 struct sccp_hotline {
112 	linePtr line;                                                                                           /*!< Line */
113 	char exten[SCCP_MAX_EXTENSION];										/*!< Extension */
114 };														/*!< SCCP Hotline Structure */
115 
116 SCCP_API void SCCP_CALL sccp_line_pre_reload(void);
117 SCCP_API void SCCP_CALL sccp_line_post_reload(void);
118 /* live cycle */
119 SCCP_API void * SCCP_CALL sccp_create_hotline(void);
120 SCCP_API linePtr SCCP_CALL sccp_line_create(const char * name);
121 SCCP_API void SCCP_CALL sccp_line_addToGlobals(constLinePtr line);
122 SCCP_API void SCCP_CALL sccp_line_removeFromGlobals(sccp_line_t * line);
123 SCCP_API void SCCP_CALL sccp_line_addChannel(constLinePtr line, constChannelPtr channel);
124 SCCP_API void SCCP_CALL sccp_line_removeChannel(constLinePtr line, sccp_channel_t * channel);
125 SCCP_API void SCCP_CALL sccp_line_clean(linePtr l, boolean_t remove_from_global);
126 SCCP_API void SCCP_CALL sccp_line_kill_channels(linePtr l);
127 SCCP_API void SCCP_CALL sccp_line_copyCodecSetsFromLineToChannel(constLinePtr l, constDevicePtr maybe_d, channelPtr c);
128 SCCP_API void SCCP_CALL sccp_line_updatePreferencesFromDevicesToLine(linePtr l);
129 SCCP_API void SCCP_CALL sccp_line_updateCapabilitiesFromDevicesToLine(linePtr l);
130 SCCP_API void SCCP_CALL sccp_line_updateLineCapabilitiesByDevice(constDevicePtr d);
131 SCCP_API void SCCP_CALL sccp_line_cfwd(constLinePtr line, constDevicePtr device, sccp_cfwd_t type, char * number);
132 SCCP_API void SCCP_CALL sccp_line_setMWI(constLinePtr l, int newlinemsgs, int oldlinemsgs);
133 
134 // find line
135 SCCP_API linePtr SCCP_CALL sccp_line_find_byname(const char * name, uint8_t useRealtime);
136 #if DEBUG
137 #	define sccp_line_find_byid(_x, _y) __sccp_line_find_byid(_x, _y, __FILE__, __LINE__, __PRETTY_FUNCTION__)
138 SCCP_API linePtr SCCP_CALL __sccp_line_find_byid(constDevicePtr d, uint16_t instance, const char * filename, int lineno, const char * func);
139 
140 #	define sccp_line_find_byButtonIndex(_x, _y) __sccp_line_find_byButtonIndex(_x, _y, __FILE__, __LINE__, __PRETTY_FUNCTION__)
141 SCCP_API linePtr SCCP_CALL __sccp_line_find_byButtonIndex(constDevicePtr d, uint16_t buttonIndex, const char * filename, int lineno, const char * func);
142 #	ifdef CS_SCCP_REALTIME
143 #		define sccp_line_find_realtime_byname(_x) __sccp_line_find_realtime_byname(_x, __FILE__, __LINE__, __PRETTY_FUNCTION__)
144 SCCP_API linePtr SCCP_CALL __sccp_line_find_realtime_byname(const char * name, const char * filename, int lineno, const char * func);
145 #	endif                                                                                                  // CS_SCCP_REALTIME
146 #else														// DEBUG
147 SCCP_API linePtr SCCP_CALL sccp_line_find_byid(constDevicePtr d, uint16_t instance);
148 SCCP_API linePtr SCCP_CALL sccp_line_find_byButtonIndex(constDevicePtr d, uint16_t buttonIndex);
149 
150 #	ifdef CS_SCCP_REALTIME
151 SCCP_API linePtr SCCP_CALL sccp_line_find_realtime_byname(const char * name);
152 #	endif                                                                                                  // CS_SCCP_REALTIME
153 #endif														// DEBUG
154 
155 __END_C_EXTERN__
156 // kate: indent-width 8; replace-tabs off; indent-mode cstyle; auto-insert-doxygen on; line-numbers on; tab-indents on; keep-extra-spaces off; auto-brackets off;
157