@@ -182,8 +182,12 @@ static switch_status_t process_originate_message(mosquitto_mosq_userdata_t *user
182
182
aleg = argv [1 ];
183
183
bleg = argv [2 ];
184
184
185
- //status = switch_ivr_originate(session, NULL, &cause, NULL, timeout, NULL, cid_name, cid_number, NULL, originate_vars, SOF_NONE, NULL);
186
- status = switch_ivr_originate (NULL , & session , & cause , aleg , timeout , NULL , NULL , NULL , NULL , originate_vars , SOF_NONE , NULL , NULL );
185
+ #if SWITCH_API_VERSION < 5
186
+ status = switch_ivr_originate (session , NULL , & cause , NULL , timeout , NULL , cid_name , cid_number , NULL , originate_vars , SOF_NONE , NULL );
187
+ #else
188
+ status = switch_ivr_originate (NULL , & session , & cause , aleg , timeout , NULL , NULL , NULL , NULL , originate_vars , SOF_NONE , NULL , NULL );
189
+ #endif
190
+
187
191
if (status != SWITCH_STATUS_SUCCESS || !session ) {
188
192
log (SWITCH_LOG_WARNING , "Originate to [%s] failed, cause: %s\n" , aleg , switch_channel_cause2str (cause ));
189
193
return status ;
@@ -586,20 +590,23 @@ switch_status_t mosq_int_option(mosquitto_connection_t *connection)
586
590
{
587
591
switch_status_t status = SWITCH_STATUS_SUCCESS ;
588
592
int rc ;
593
+ int protocol_version = MQTT_PROTOCOL_V31 ;
589
594
590
- /*
591
595
if (!strncasecmp (connection -> protocol_version , "V311" , 4 )) {
592
596
protocol_version = MQTT_PROTOCOL_V311 ;
593
597
}
594
- */
595
598
596
599
/*
597
600
* mosq A valid mosquitto instance.
598
601
* option The option to set.
599
602
* value The option specific value.
600
603
*/
601
- rc = mosquitto_int_option (connection -> mosq , MOSQ_OPT_PROTOCOL_VERSION , MQTT_PROTOCOL_V311 );
602
- log (SWITCH_LOG_DEBUG , "mosquitto_init_option() for Profile %s connection %s protocol version %s rc %d\n" , connection -> profile_name , connection -> name , connection -> protocol_version , rc );
604
+ #if LIBMOSQUITTO_VERSION_NUMBER < 1006008
605
+ rc = mosquitto_opts_set (connection -> mosq , MOSQ_OPT_PROTOCOL_VERSION , & protocol_version );
606
+ #else
607
+ rc = mosquitto_int_option (connection -> mosq , MOSQ_OPT_PROTOCOL_VERSION , protocol_version );
608
+ #endif
609
+ log (SWITCH_LOG_DEBUG , "Options set for Profile %s connection %s protocol version %s rc %d\n" , connection -> profile_name , connection -> name , connection -> protocol_version , rc );
603
610
604
611
/*
605
612
rc = mosquitto_init_option(connection->mosq, MOSQ_OPT_RECEIVE_MAXIMUM, connection->receive_maximum);
@@ -1239,18 +1246,12 @@ switch_status_t mosq_new(mosquitto_profile_t *profile, mosquitto_connection_t *c
1239
1246
return SWITCH_STATUS_SUCCESS ;
1240
1247
}
1241
1248
1242
- /*
1243
1249
if (!(userdata = (mosquitto_mosq_userdata_t * )switch_core_alloc (profile -> pool , sizeof (mosquitto_mosq_userdata_t )))) {
1244
1250
log (SWITCH_LOG_CRIT , "mosq_new() Failed to allocate memory for mosquitto_new() userdata structure profile %s connection %s\n" , profile -> name , connection -> name );
1245
1251
return SWITCH_STATUS_GENERR ;
1246
- } else {
1247
- connection->userdata = userdata;
1248
- userdata->profile = profile;
1249
- userdata->connection = connection;
1250
1252
}
1251
- */
1253
+ //switch_malloc(userdata, sizeof(mosquitto_mosq_userdata_t));
1252
1254
1253
- switch_malloc (userdata , sizeof (mosquitto_mosq_userdata_t ));
1254
1255
connection -> userdata = userdata ;
1255
1256
userdata -> profile = profile ;
1256
1257
userdata -> connection = connection ;
@@ -1320,17 +1321,17 @@ switch_status_t mosq_destroy(mosquitto_connection_t *connection)
1320
1321
return SWITCH_STATUS_GENERR ;
1321
1322
}
1322
1323
1323
- userdata = mosquitto_userdata (connection -> mosq );
1324
- if (!userdata ) {
1325
- log (SWITCH_LOG_ERROR , "mosq_destroy() called with NULL userdata pointer\n" );
1326
- return SWITCH_STATUS_GENERR ;
1327
- }
1328
-
1329
- profile = (mosquitto_profile_t * )userdata -> profile ;
1330
-
1331
- log (SWITCH_LOG_DEBUG , "mosq_destroy(): profile %s connection %s\n" , profile -> name , connection -> name );
1324
+ #if LIBMOSQUITTO_VERSION_NUMBER >= 1006008
1325
+ userdata = mosquitto_userdata (connection -> mosq );
1326
+ if (!userdata ) {
1327
+ log (SWITCH_LOG_ERROR , "mosq_destroy() called with NULL userdata pointer\n" );
1328
+ return SWITCH_STATUS_GENERR ;
1329
+ }
1330
+ profile = (mosquitto_profile_t * )userdata -> profile ;
1331
+ log (SWITCH_LOG_DEBUG , "mosq_destroy(): profile %s connection %s\n" , profile -> name , connection -> name );
1332
+ // switch_safe_free(connection->userdata);
1333
+ #endif
1332
1334
1333
- switch_safe_free (connection -> userdata );
1334
1335
mosquitto_destroy (connection -> mosq );
1335
1336
connection -> mosq = NULL ;
1336
1337
connection -> connected = SWITCH_FALSE ;
@@ -1427,11 +1428,13 @@ switch_status_t mosq_subscribe(mosquitto_profile_t *profile, mosquitto_subscribe
1427
1428
topic -> subscribed = SWITCH_FALSE ;
1428
1429
return SWITCH_STATUS_GENERR ;
1429
1430
break ;
1431
+ #if LIBMOSQUITTO_VERSION_NUMBER >= 1006008
1430
1432
case MOSQ_ERR_OVERSIZE_PACKET :
1431
1433
log (SWITCH_LOG_ERROR , "Profile %s subscriber %s connection %s topic %s pattern %s the pattern larger than the MQTT broker can support\n" , profile -> name , subscriber -> name , connection -> name , topic -> name , topic -> pattern );
1432
1434
topic -> subscribed = SWITCH_FALSE ;
1433
1435
return SWITCH_STATUS_GENERR ;
1434
1436
break ;
1437
+ #endif
1435
1438
}
1436
1439
1437
1440
return status ;
0 commit comments