Rename sub->parent to sub->line.
authorDamien Wedhorn <voip@facts.com.au>
Fri, 6 May 2011 22:32:45 +0000 (22:32 +0000)
committerDamien Wedhorn <voip@facts.com.au>
Fri, 6 May 2011 22:32:45 +0000 (22:32 +0000)
Improve readability of code, eg, (sub->parent == d->activeline) becomes
(sub->line == d->activeline).

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318018 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_skinny.c

index d1da426..9e1436f 100644 (file)
@@ -1217,7 +1217,7 @@ struct skinny_subchannel {
 
        AST_LIST_ENTRY(skinny_subchannel) list;
        struct skinny_subchannel *related;
-       struct skinny_line *parent;
+       struct skinny_line *line;
 };
 
 #define SKINNY_LINE_OPTIONS                            \
@@ -2270,7 +2270,7 @@ static void transmit_callinfo(struct skinny_subchannel *sub)
        char *toname;
        char *tonum;
 
-       if (!sub || !(l=sub->parent) || !(d=sub->parent->device) || !(ast=sub->owner)) {
+       if (!sub || !(l=sub->line) || !(d=l->device) || !(ast=sub->owner)) {
                return;
        }
 
@@ -2309,7 +2309,7 @@ static void transmit_callinfo(struct skinny_subchannel *sub)
 static void transmit_connect(struct skinny_device *d, struct skinny_subchannel *sub)
 {
        struct skinny_req *req;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct ast_format_list fmt;
        struct ast_format tmpfmt;
 
@@ -2839,7 +2839,7 @@ static int skinny_extensionstate_cb(char *context, char *exten, int state, void
 static void update_connectedline(struct skinny_subchannel *sub, const void *data, size_t datalen)
 {
        struct ast_channel *c = sub->owner;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (!c->caller.id.number.valid
@@ -2947,7 +2947,7 @@ static enum ast_rtp_glue_result skinny_get_rtp_peer(struct ast_channel *c, struc
        ao2_ref(sub->rtp, +1);
        *instance = sub->rtp;
 
-       l = sub->parent;
+       l = sub->line;
 
        if (!l->directmedia || l->nat){
                res = AST_RTP_GLUE_RESULT_LOCAL;
@@ -2981,7 +2981,7 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r
                return -1;
        }
 
-       l = sub->parent;
+       l = sub->line;
        d = l->device;
 
        if (rtp){
@@ -3863,7 +3863,7 @@ static struct ast_cli_entry cli_skinny[] = {
 
 static void start_rtp(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int hasvideo = 0;
        struct ast_sockaddr bindaddr_tmp;
@@ -3911,7 +3911,7 @@ static void *skinny_newcall(void *data)
 {
        struct ast_channel *c = data;
        struct skinny_subchannel *sub = c->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int res = 0;
 
@@ -3944,7 +3944,7 @@ static void *skinny_ss(void *data)
 {
        struct ast_channel *c = data;
        struct skinny_subchannel *sub = c->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int len = 0;
        int timeout = firstdigittimeout;
@@ -4048,7 +4048,7 @@ static int skinny_call(struct ast_channel *ast, char *dest, int timeout)
 {
        int res = 0;
        struct skinny_subchannel *sub = ast->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (!d->registered) {
@@ -4089,7 +4089,7 @@ static int skinny_hangup(struct ast_channel *ast)
                return 0;
        }
 
-       l = sub->parent;
+       l = sub->line;
        d = l->device;
 
        if (skinnydebug)
@@ -4147,7 +4147,7 @@ static int skinny_hangup(struct ast_channel *ast)
                        transmit_activatecallplane(d, l);
                        l->activesub = NULL;
                        transmit_lamp_indication(d, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
-                       if (sub->parent == d->activeline) {
+                       if (sub->line == d->activeline) {
                                transmit_activatecallplane(d, l);
                                transmit_closereceivechannel(d, sub);
                                transmit_stopmediatransmission(d, sub);
@@ -4177,7 +4177,7 @@ static int skinny_answer(struct ast_channel *ast)
 {
        int res = 0;
        struct skinny_subchannel *sub = ast->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (sub->blindxfer) {
@@ -4310,7 +4310,7 @@ static int skinny_senddigit_end(struct ast_channel *ast, char digit, unsigned in
 {
 #if 0
        struct skinny_subchannel *sub = ast->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int tmp;
        /* not right */
@@ -4482,7 +4482,7 @@ static int skinny_transfer(struct skinny_subchannel *sub)
 static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
 {
        struct skinny_subchannel *sub = ast->tech_pvt;
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct skinnysession *s = d->session;
 
@@ -4570,7 +4570,7 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state, const ch
                        d->lastcallreference = sub->callid;
                        sub->cxmode = SKINNY_CX_INACTIVE;
                        sub->nat = l->nat;
-                       sub->parent = l;
+                       sub->line = l;
                        sub->blindxfer = 0;
                        sub->xferor = 0;
                        sub->related = NULL;
@@ -4690,7 +4690,7 @@ static char *substate2str(int ind) {
 
 static void setsubstate_offhook(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        pthread_t t;
 
@@ -4715,7 +4715,7 @@ static void setsubstate_offhook(struct skinny_subchannel *sub)
 
 static void setsubstate_dialing(struct skinny_subchannel *sub, char exten[AST_MAX_EXTENSION])
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct ast_channel *c = sub->owner;
        pthread_t t;
@@ -4749,7 +4749,7 @@ static void setsubstate_dialing(struct skinny_subchannel *sub, char exten[AST_MA
 
 static void setsubstate_ringout(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS)) {
@@ -4760,7 +4760,7 @@ static void setsubstate_ringout(struct skinny_subchannel *sub)
        if (!d->earlyrtp) {
                transmit_start_tone(d, SKINNY_ALERT, l->instance, sub->callid);
        }
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_RINGOUT);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_RINGOUT);
        transmit_dialednumber(d, l->lastnumberdialed, l->instance, sub->callid);
        transmit_displaypromptstatus(d, "Ring Out", 0, l->instance, sub->callid);
        transmit_callinfo(sub);
@@ -4769,11 +4769,11 @@ static void setsubstate_ringout(struct skinny_subchannel *sub)
 
 static void setsubstate_ringin(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct ast_channel *c = sub->owner;
 
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_RINGIN);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_RINGIN);
        transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGIN);
        transmit_displaypromptstatus(d, "Ring-In", 0, l->instance, sub->callid);
        transmit_callinfo(sub);
@@ -4791,7 +4791,7 @@ static void setsubstate_ringin(struct skinny_subchannel *sub)
 
 static void setsubstate_connected(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        
        if (sub->substate == SUBSTATE_HOLD) {
@@ -4801,7 +4801,7 @@ static void setsubstate_connected(struct skinny_subchannel *sub)
        transmit_activatecallplane(d, l);
        transmit_stop_tone(d, l->instance, sub->callid);
        transmit_callinfo(sub);
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_CONNECTED);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_CONNECTED);
        transmit_displaypromptstatus(d, "Connected", 0, l->instance, sub->callid);
        transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_CONNECTED);
        if (!sub->rtp) {
@@ -4822,7 +4822,7 @@ static void setsubstate_connected(struct skinny_subchannel *sub)
 
 static void setsubstate_busy(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS || sub->substate == SUBSTATE_RINGOUT)) {
@@ -4834,14 +4834,14 @@ static void setsubstate_busy(struct skinny_subchannel *sub)
                transmit_start_tone(d, SKINNY_BUSYTONE, l->instance, sub->callid);
        }
        transmit_callinfo(sub);
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_BUSY);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_BUSY);
        transmit_displaypromptstatus(d, "Busy", 0, l->instance, sub->callid);
        sub->substate = SUBSTATE_BUSY;
 }
 
 static void setsubstate_congestion(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS || sub->substate == SUBSTATE_RINGOUT)) {
@@ -4853,14 +4853,14 @@ static void setsubstate_congestion(struct skinny_subchannel *sub)
                transmit_start_tone(d, SKINNY_REORDER, l->instance, sub->callid);
        }
        transmit_callinfo(sub);
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_CONGESTION);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_CONGESTION);
        transmit_displaypromptstatus(d, "Congestion", 0, l->instance, sub->callid);
        sub->substate = SUBSTATE_CONGESTION;
 }
 
 static void setsubstate_progress(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (sub->substate != SUBSTATE_DIALING) {
@@ -4872,14 +4872,14 @@ static void setsubstate_progress(struct skinny_subchannel *sub)
                transmit_start_tone(d, SKINNY_ALERT, l->instance, sub->callid);
        }
        transmit_callinfo(sub);
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_PROGRESS);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_PROGRESS);
        transmit_displaypromptstatus(d, "Call Progress", 0, l->instance, sub->callid);
        sub->substate = SUBSTATE_PROGRESS;
 }
 
 static void setsubstate_hold(struct skinny_subchannel *sub)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
        if (sub->substate != SUBSTATE_CONNECTED) {
@@ -4895,9 +4895,9 @@ static void setsubstate_hold(struct skinny_subchannel *sub)
        transmit_closereceivechannel(d, sub);
        transmit_stopmediatransmission(d, sub);
 
-       transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_HOLD);
+       transmit_callstate(d, l->instance, sub->callid, SKINNY_HOLD);
        transmit_lamp_indication(d, STIMULUS_LINE, l->instance, SKINNY_LAMP_WINK);
-       transmit_selectsoftkeys(sub->parent->device, sub->parent->instance, sub->callid, KEYDEF_ONHOLD);
+       transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_ONHOLD);
        sub->substate = SUBSTATE_HOLD;
 }
 
@@ -4930,7 +4930,7 @@ static int handle_transfer_button(struct skinny_subchannel *sub)
                return -1;
        }
 
-       l = sub->parent;
+       l = sub->line;
        d = l->device;
 
        if (!sub->related) {
@@ -4973,7 +4973,7 @@ static int handle_transfer_button(struct skinny_subchannel *sub)
 
 static int handle_callforward_button(struct skinny_subchannel *sub, int cfwdtype)
 {
-       struct skinny_line *l = sub->parent;
+       struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct ast_channel *c = sub->owner;
 
@@ -5060,7 +5060,7 @@ static int handle_keypad_button_message(struct skinny_req *req, struct skinnyses
        if (!sub)
                return 0;
 
-       l = sub->parent;
+       l = sub->line;
        if (sub->owner) {
                if (sub->owner->_state == 0) {
                        f.frametype = AST_FRAME_DTMF_BEGIN;
@@ -5113,7 +5113,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                }
                sub = l->activesub;
        } else {
-               l = sub->parent;
+               l = sub->line;
        }
 
        switch(event) {
@@ -5131,7 +5131,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
                        sub = c->tech_pvt;
-                       l = sub->parent;
+                       l = sub->line;
                        l->activesub = sub;
                        setsubstate_dialing(sub, l->lastnumberdialed);
                }
@@ -5155,7 +5155,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
                        sub = c->tech_pvt;
-                       l = sub->parent;
+                       l = sub->line;
                        l->activesub = sub;
                        
                        setsubstate_dialing(sub, sd->exten);
@@ -5193,7 +5193,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
                        sub = c->tech_pvt;
-                       l = sub->parent;
+                       l = sub->line;
                        l->activesub = sub;
                        
                        setsubstate_dialing(sub,l->vmexten);
@@ -5373,7 +5373,7 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
                                return 0;
                        }
                } else {
-                       l = sub->parent;
+                       l = sub->line;
                }
        } else {
                l = d->activeline;
@@ -5428,7 +5428,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s
                if (!sub) {
                        return 0;
                }
-               l = sub->parent;
+               l = sub->line;
        } else {
                l = d->activeline;
                sub = l->activesub;
@@ -5726,7 +5726,7 @@ static int handle_open_receive_channel_ack_message(struct skinny_req *req, struc
        if (!sub)
                return 0;
 
-       l = sub->parent;
+       l = sub->line;
 
        if (sub->rtp) {
                ast_sockaddr_from_sin(&sin_tmp, &sin);
@@ -5772,7 +5772,7 @@ static int handle_enbloc_call_message(struct skinny_req *req, struct skinnysessi
                        return 0;
                }
        } else {
-               l = sub->parent;
+               l = sub->line;
        }
 
        c = skinny_new(l, AST_STATE_DOWN, NULL, SKINNY_OUTGOING);
@@ -7153,7 +7153,7 @@ static struct ast_channel *skinny_request(const char *type, struct ast_format_ca
                                                ast_mutex_lock(&l->lock);
                                                l->sub = ltemp->sub;
                                                AST_LIST_TRAVERSE(&l->sub, sub, list) {
-                                                       sub->parent = l;
+                                                       sub->line = l;
                                                }
                                                ast_mutex_unlock(&l->lock);
                                        }