#include <stdint.h>
#include "caadapterutils.h"
-#include "camutex.h"
+#include "octhread.h"
#include "uarraylist.h"
#include "logger.h"
#include "oic_malloc.h"
CAJidBoundCallback jidBoundCallback;
} CARAXmppData_t;
-static ca_mutex g_raadapterMutex = NULL;
+static oc_mutex g_raadapterMutex = NULL;
static CARAXmppData_t g_xmppData = {.xmpp = NULL, .port = 5222, .hostName = {0},
.password = {0}, .jid = {0}, .connectionStatus = CA_INTERFACE_DOWN,
return CA_STATUS_FAILED;
}
- g_raadapterMutex = ca_mutex_new ();
+ g_raadapterMutex = oc_mutex_new ();
if (!g_raadapterMutex)
{
OIC_LOG (ERROR, RA_ADAPTER_TAG, PCF("Memory allocation for mutex failed."));
return CA_MEMORY_ALLOC_FAILED;
}
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
xmpphelper_connect(g_xmppData.xmpp, g_xmppData.hostName, g_xmppData.port,
g_xmppData.jid, g_xmppData.password);
xmpphelper_run(g_xmppData.xmpp);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "RA adapter started succesfully");
return CA_STATUS_OK;
xmpp_ibb_unregister(xmpphelper_get_conn(g_xmppData.xmpp));
if (!g_raadapterMutex)
{
- ca_mutex_free (g_raadapterMutex);
+ oc_mutex_free (g_raadapterMutex);
g_raadapterMutex = NULL;
}
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Stopped RA adapter successfully"));
int obsopt = CARAGetReqObsOption(pdu, remoteEndpoint);
coap_delete_pdu(pdu);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connectionStatus)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, RA not connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
if (sess == NULL)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "IBB session establish failed!");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
}
}
xmppdata_t xdata = {.data = (char *) data, .size = dataLength};
int rc = xmpp_ibb_send_data(sess, &xdata);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
if (rc < 0)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "IBB send data failed!");
char jabberID[CA_RAJABBERID_SIZE];
} CARAXmppData_t;
-static ca_mutex g_raadapterMutex = NULL;
+static oc_mutex g_raadapterMutex = NULL;
static CARAXmppData_t g_xmppData = {};
{
printf("\n\n\t\t===>your jid: %s\n\n", bound_jid);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
OICStrcpy (g_xmppData.jabberID, CA_RAJABBERID_SIZE, bound_jid);
g_xmppData.connection_status = CA_INTERFACE_UP;
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "XMPP connected callback status: %d", result);
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
// Notify network change to CA
CARANotifyNetworkChange(bound_jid, connection_status);
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARAXmppDisonnectedCB IN");
char jabberID[CA_RAJABBERID_SIZE];
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
g_xmppData.connection_status = CA_INTERFACE_DOWN;
xmpp_message_context_destroy(g_xmppData.message_context);
OICStrcpy (jabberID, CA_RAJABBERID_SIZE, g_xmppData.jabberID);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
// Notify network change to CA
CARANotifyNetworkChange(jabberID, CA_INTERFACE_DOWN);
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Starting RA adapter"));
- g_raadapterMutex = ca_mutex_new ();
+ g_raadapterMutex = oc_mutex_new ();
if (!g_raadapterMutex)
{
OIC_LOG (ERROR, RA_ADAPTER_TAG, PCF("Memory allocation for mutex failed."));
return CA_MEMORY_ALLOC_FAILED;
}
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
xmpp_context_init(&g_xmppData.context);
g_xmppData.handle = xmpp_startup(&g_xmppData.context);
xmpp_identity_destroy(&g_xmppData.g_identity);
xmpp_host_destroy(&g_xmppData.g_host);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
if (XMPP_ERR_OK != ret)
{
xmpp_shutdown_xmpp(g_xmppData.handle);
xmpp_context_destroy(&g_xmppData.context);
- ca_mutex_free (g_raadapterMutex);
+ oc_mutex_free (g_raadapterMutex);
g_raadapterMutex = NULL;
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Stopped RA adapter successfully"));
}
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "Sending unicast data to %s", remoteEndpoint->addr);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connection_status)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, RA not connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
if (XMPP_ERR_OK != res)
{
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, status: %d", res);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
OIC_LOG_V(INFO, RA_ADAPTER_TAG, "Successfully dispatched bytes[%d] to addr[%s]",
dataLength, remoteEndpoint->addr);
VERIFY_NON_NULL(info, RA_ADAPTER_TAG, "info is NULL");
VERIFY_NON_NULL(size, RA_ADAPTER_TAG, "size is NULL");
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connection_status)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Failed to get interface info, RA not Connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return CA_ADAPTER_NOT_ENABLED;
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
CA_ADAPTER_REMOTE_ACCESS,