Commit b870bdfa authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Merge remote-tracking branch 'origin/master' into dev_codec_downloader

parents 693aed8f 2ac6f410
......@@ -246,7 +246,7 @@ if(MSVC)
endif()
else()
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations")
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Werror=strict-prototypes")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
endif()
......
......@@ -47,7 +47,7 @@ libglew1.6-dev libv4l-dev libxml2-dev
libsqlite3-dev libupnp4-dev libsrtp-dev
+ Install zrtp (optional), for unbreakable call encryption
$ git clone git://git.linphone.org:bzrtp
$ git clone git://git.linphone.org/bzrtp.git
$ cd bzrtp && ./autogen.sh && ./configure && make
$ sudo make install
......
......@@ -37,7 +37,7 @@
#include <linphonecore.h>
#include "linphonec.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#ifdef _WIN32
#include <ws2tcpip.h>
......
......@@ -877,6 +877,14 @@ bool_t sal_dns_srv_enabled(const Sal *sal) {
return (bool_t)belle_sip_stack_dns_srv_enabled(sal->stack);
}
void sal_enable_dns_search(Sal *sal, bool_t enable) {
belle_sip_stack_enable_dns_search(sal->stack, (unsigned char)enable);
}
bool_t sal_dns_search_enabled(const Sal *sal) {
return (bool_t)belle_sip_stack_dns_search_enabled(sal->stack);
}
void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file) {
belle_sip_stack_set_dns_user_hosts_file(sal->stack, hosts_file);
}
......
......@@ -985,7 +985,7 @@ int sal_call_send_dtmf(SalOp *h, char dtmf){
if (h->dialog && (belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_EARLY)){
belle_sip_request_t *req=belle_sip_dialog_create_queued_request(h->dialog,"INFO");
if (req){
int bodylen;
size_t bodylen;
char dtmf_body[128]={0};
snprintf(dtmf_body, sizeof(dtmf_body)-1, "Signal=%c\r\nDuration=250\r\n", dtmf);
......
......@@ -115,7 +115,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
while (vCards) {
LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data;
if (vCard) {
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneFriend *lf = NULL;
bctbx_list_t *local_friend = NULL;
......
......@@ -466,7 +466,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
}
linphone_chat_room_delete_composing_idle_timer(cr);
linphone_chat_room_delete_composing_refresh_timer(cr);
if (call && call->op == op) {
/*In this case, chat delivery status is not notified, so unrefing chat message right now*/
/*Might be better fixed by delivering status, but too costly for now*/
......@@ -475,7 +475,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
linphone_chat_message_unref(msg);
return;
}
}
// if operation failed, we should not change message state
......@@ -590,7 +590,7 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag
b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength);
linphone_content_set_key(
msg->file_transfer_information, (char *)keyBuffer,
keyLength); /* duplicate key value into the linphone content private structure */
strlen((char *)keyBuffer)); /* duplicate key value into the linphone content private structure */
xmlFree(keyb64);
free(keyBuffer);
}
......
......@@ -49,27 +49,30 @@ static void _release_http_request(LinphoneChatMessage* msg) {
static void linphone_chat_message_process_io_error_upload(void *data, const belle_sip_io_error_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("I/O Error during file upload of msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered);
_release_http_request(msg);
linphone_chat_message_unref(msg);
}
static void linphone_chat_message_process_auth_requested_upload(void *data, belle_sip_auth_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("Error during file upload: auth requested for msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered);
_release_http_request(msg);
linphone_chat_message_unref(msg);
}
static void linphone_chat_message_process_io_error_download(void *data, const belle_sip_io_error_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("I/O Error during file download msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateFileTransferError);
_release_http_request(msg);
}
static void linphone_chat_message_process_auth_requested_download(void *data, belle_sip_auth_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("Error during file download : auth requested for msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateFileTransferError);
_release_http_request(msg);
}
......@@ -441,18 +444,38 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
int code = belle_http_response_get_status_code(event->response);
if (code == 200) {
LinphoneCore *lc = msg->chat_room->lc;
/* if the file was encrypted, finish the decryption and free context */
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0,
NULL, NULL);
}
/* file downloaded succesfully, call again the callback with size at zero */
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information,
lb);
linphone_buffer_unref(lb);
if (msg->file_transfer_filepath == NULL) {
/* if the file was encrypted, finish the decryption and free context */
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
}
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
} else {
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
bctbx_vfs_t *vfs = bctbx_vfs_get_default();
bctbx_vfs_file_t *decrypted_file;
bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r");
size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file);
char *encrypted_content = bctbx_malloc(encrypted_file_size);
char *decrypted_content = bctbx_malloc(encrypted_file_size);
bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0);
bctbx_file_close(encrypted_file);
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information),
(unsigned char *)linphone_content_get_key(msg->file_transfer_information),
encrypted_file_size, decrypted_content, encrypted_content);
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w");
bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0);
bctbx_file_close(decrypted_file);
bctbx_free(encrypted_content);
bctbx_free(decrypted_content);
}
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
......@@ -557,6 +580,10 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
, msg
, msg->chat_room);
belle_http_provider_cancel_request(msg->chat_room->lc->http_provider, msg->http_request);
if (msg->dir == LinphoneChatMessageOutgoing) {
// must release it
linphone_chat_message_unref(msg);
}
} else {
ms_message("Warning: http request still running for ORPHAN msg [%p]: this is a memory leak", msg);
}
......
......@@ -112,7 +112,7 @@ public:
bool microphoneIsMuted() const {return m_isMuted;}
float getInputVolume() const;
virtual int getSize() const {return m_participants.size() + (isIn()?1:0);}
virtual int getSize() const {return (int)m_participants.size() + (isIn()?1:0);}
const std::list<Participant *> &getParticipants() const {return m_participants;}
virtual int startRecording(const char *path) = 0;
......
......@@ -39,12 +39,15 @@ extern "C" {
/**
* LinphoneConference class
* The _LinphoneConference struct does not exists, it's the Conference C++ class that is used behind
*/
typedef struct _LinphoneConference LinphoneConference;
/**
* Parameters for initialization of conferences
* The _LinphoneConferenceParams struct does not exists, it's the ConferenceParams C++ class that is used behind
*/
typedef struct _LinphoneCorferenceParams LinphoneConferenceParams;
typedef struct _LinphoneConferenceParams LinphoneConferenceParams;
......
......@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static char *create_enum_domain(const char *number){
size_t len=strlen(number);
long len=(long)strlen(number);
char *domain=ms_malloc((len*2)+10);
long i,j;
......
......@@ -1256,7 +1256,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
LinphoneVcard *vcard = NULL;
unsigned int storage_id = (unsigned int)atoi(argv[0]);
vcard = linphone_vcard_new_from_vcard4_buffer(context, argv[6]);
vcard = linphone_vcard_context_get_vcard_from_buffer(context, argv[6]);
if (vcard) {
linphone_vcard_set_etag(vcard, argv[7]);
linphone_vcard_set_url(vcard, argv[8]);
......
......@@ -781,7 +781,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
return -1;
}
vcards = linphone_vcard_list_from_vcard4_file(list->lc->vcard_context, vcard_file);
vcards = linphone_vcard_context_get_vcard_list_from_file(list->lc->vcard_context, vcard_file);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the file %s", vcard_file);
......@@ -820,7 +820,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
return -1;
}
vcards = linphone_vcard_list_from_vcard4_buffer(list->lc->vcard_context, vcard_buffer);
vcards = linphone_vcard_context_get_vcard_list_from_buffer(list->lc->vcard_context, vcard_buffer);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the buffer");
......
......@@ -588,7 +588,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t
lime_strToUint8(selfZid, selfZidHex, 24);
/* encrypted message length is plaintext + 16 for tag */
encryptedMessageLength = strlen((char *)message) + 16;
encryptedMessageLength = (uint32_t)strlen((char *)message) + 16;
/* retrieve keys associated to the peer URI */
associatedKeys.peerURI = (uint8_t *)malloc(strlen((char *)peerURI)+1);
......@@ -626,7 +626,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t
limeKey_t *currentKey = associatedKeys.peerKeys[i];
/* encrypted message include a 16 bytes tag */
uint8_t *encryptedMessage = (uint8_t *)malloc(encryptedMessageLength);
lime_encryptMessage(currentKey, message, strlen((char *)message), selfZid, encryptedMessage);
lime_encryptMessage(currentKey, message, (uint32_t)strlen((char *)message), selfZid, encryptedMessage);
/* add a "msg" node the the output message, doc node is :
* <msg>
* <pzid>peerZID</pzid>
......@@ -795,7 +795,7 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_
/* decrypt the message */
*output = (uint8_t *)malloc(encryptedMessageLength - 16 +1); /* plain message is same length than encrypted one with 16 bytes less for the tag + 1 to add the null termination char */
retval = lime_decryptMessage(&associatedKey, encryptedMessage, encryptedMessageLength, selfZid, *output);
retval = lime_decryptMessage(&associatedKey, encryptedMessage, (uint32_t)encryptedMessageLength, selfZid, *output);
free(encryptedMessage);
......
......@@ -52,13 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifndef ANDROID /*on Android LIBLINPHONE version is passed from root Makefile*/
#include "liblinphone_gitversion.h"
#endif
#else
#ifndef LIBLINPHONE_GIT_VERSION
#define LIBLINPHONE_GIT_VERSION "unknown"
#endif
#include "liblinphone_gitversion.h"
#endif
#ifdef __APPLE__
......@@ -603,7 +597,7 @@ static int compress_file(FILE *input_file, COMPRESS_FILE_PTR output_file) {
total_bytes += fwrite(buffer, 1, bytes, output_file);
#endif
}
return total_bytes;
return (int)total_bytes;
}
static int prepare_log_collection_file_to_upload(const char *filename) {
......@@ -790,6 +784,8 @@ static void net_config_read (LinphoneCore *lc)
}
tmp = lp_config_get_int(lc->config, "net", "dns_srv_enabled", 1);
linphone_core_enable_dns_srv(lc, tmp);
tmp = lp_config_get_int(lc->config, "net", "dns_search_enabled", 1);
linphone_core_enable_dns_search(lc, tmp);
/* This is to filter out unsupported firewall policies */
if (nat_policy_ref == NULL)
......@@ -799,7 +795,7 @@ static void net_config_read (LinphoneCore *lc)
static void build_sound_devices_table(LinphoneCore *lc){
const char **devices;
const char **old;
int ndev;
size_t ndev;
int i;
const bctbx_list_t *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(lc->factory));
ndev=bctbx_list_size(elem);
......@@ -951,10 +947,7 @@ static void sip_config_read(LinphoneCore *lc)
const char *tmpstr;
LCSipTransports tr;
int i,tmp;
int ipv6_default = FALSE;
#if TARGET_OS_IPHONE
ipv6_default=TRUE;
#endif
int ipv6_default = TRUE;
if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){
sal_use_session_timers(lc->sal,200);
......@@ -963,13 +956,11 @@ static void sip_config_read(LinphoneCore *lc)
sal_use_no_initial_route(lc->sal,lp_config_get_int(lc->config,"sip","use_no_initial_route",0));
sal_use_rport(lc->sal,lp_config_get_int(lc->config,"sip","use_rport",1));
#if TARGET_OS_IPHONE
if (!lp_config_get_int(lc->config,"sip","ipv6_migration_done",FALSE) && lp_config_has_entry(lc->config,"sip","use_ipv6")) {
lp_config_clean_entry(lc->config,"sip","use_ipv6");
lp_config_set_int(lc->config, "sip", "ipv6_migration_done", TRUE);
ms_message("IPV6 settings migration done.");
}
#endif
lc->sip_conf.ipv6_enabled=lp_config_get_int(lc->config,"sip","use_ipv6",ipv6_default);
......@@ -1369,7 +1360,7 @@ static void codecs_config_read(LinphoneCore *lc){
static void build_video_devices_table(LinphoneCore *lc){
const bctbx_list_t *elem;
int i;
int ndev;
size_t ndev;
const char **devices;
if (lc->video_conf.cams)
ms_free((void *)lc->video_conf.cams);
......@@ -1523,6 +1514,16 @@ bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc) {
return sal_dns_srv_enabled(lc->sal);
}
void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable) {
sal_enable_dns_search(lc->sal, enable);
if (linphone_core_ready(lc))
lp_config_set_int(lc->config, "net", "dns_search_enabled", enable ? 1 : 0);
}
bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc) {
return sal_dns_search_enabled(lc->sal);
}
int linphone_core_get_download_bandwidth(const LinphoneCore *lc){
return lc->net_conf.download_bw;
}
......@@ -5390,7 +5391,7 @@ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) {
void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
bctbx_list_t *logs_to_migrate = NULL;
LpConfig *lpc = NULL;
int original_logs_count, migrated_logs_count;
size_t original_logs_count, migrated_logs_count;
int i;
#ifndef SQLITE_STORAGE_ENABLED
......@@ -5423,7 +5424,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
logs_to_migrate = lc->call_logs;
lc->call_logs = NULL;
// We can't use bctbx_list_for_each because logs_to_migrate are listed in the wrong order (latest first), and we want to store the logs latest last
for (i = bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) {
for (i = (int)bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) {
LinphoneCallLog *log = (LinphoneCallLog *) bctbx_list_nth_data(logs_to_migrate, i);
linphone_core_store_call_log(lc, log);
}
......@@ -5431,17 +5432,17 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
original_logs_count = bctbx_list_size(logs_to_migrate);
migrated_logs_count = bctbx_list_size(lc->call_logs);
if (original_logs_count == migrated_logs_count) {
int i = 0;
size_t i = 0;
ms_debug("call logs migration successful: %u logs migrated", (unsigned int)bctbx_list_size(lc->call_logs));
lp_config_set_int(lpc, "misc", "call_logs_migration_done", 1);
for (; i < original_logs_count; i++) {
char logsection[32];
snprintf(logsection, sizeof(logsection), "call_log_%i", i);
snprintf(logsection, sizeof(logsection), "call_log_%u", (unsigned int)i);
lp_config_clean_section(lpc, logsection);
}
} else {
ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", original_logs_count, migrated_logs_count);
ms_error("not as many logs saved in db has logs read from rc ("FORMAT_SIZE_T" in rc against "FORMAT_SIZE_T" in db)!", original_logs_count, migrated_logs_count);
}
bctbx_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref);
......@@ -6895,7 +6896,7 @@ void linphone_core_destroy(LinphoneCore *lc){
* @ingroup call_control
**/
int linphone_core_get_calls_nb(const LinphoneCore *lc){
return bctbx_list_size(lc->calls);;
return (int)bctbx_list_size(lc->calls);
}
/**
......
......@@ -2754,6 +2754,22 @@ LINPHONE_PUBLIC void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enabl
*/
LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc);
/**
* Enable or disable DNS search (use of local domain if the fully qualified name did return results).
* @param[in] lc #LinphoneCore object.
* @param[in] enable TRUE to enable DNS search, FALSE to disable it.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable);
/**
* Tells whether DNS search (use of local domain if the fully qualified name did return results) is enabled.
* @param[in] lc #LinphoneCore object.
* @return TRUE if DNS search is enabled, FALSE if disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc);
/**
* Forces liblinphone to use the supplied list of dns servers, instead of system's ones.
* @param[in] lc #LinphoneCore object.
......@@ -3464,6 +3480,12 @@ LINPHONE_PUBLIC void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc);
* @}
**/
/**
* Tells whether VCARD support is builtin.
* @return TRUE if VCARD is supported, FALSE otherwise.
* @ingroup misc
*/
LINPHONE_PUBLIC bool_t linphone_core_vcard_supported(void);
/* video support */
LINPHONE_PUBLIC bool_t linphone_core_video_supported(LinphoneCore *lc);
......
This diff is collapsed.
......@@ -25,7 +25,7 @@
#define MAX_LEN 16384
#include "linphonecore.h"
#include "bctoolbox/bc_vfs.h"
#include "bctoolbox/vfs.h"
#include <stdio.h>
#include <stdlib.h>
......@@ -397,10 +397,6 @@ LpConfig * lp_config_new_from_buffer(const char *buffer){
}
LpConfig *lp_config_new_with_factory(const char *config_filename, const char *factory_config_filename) {
int fd;
bctbx_vfs_file_t* pFile = NULL;
LpConfig *lpconfig=lp_new0(LpConfig,1);
lpconfig->g_bctbx_vfs = bctbx_vfs_get_default();
......@@ -430,23 +426,20 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa
}
}
#endif /*_WIN32*/
/*open with r+ to check if we can write on it later*/
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->filename, "r+");
fd = pFile->fd;
lpconfig->pFile = pFile;
/*open with r+ to check if we can write on it later*/
lpconfig->pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->filename, "r+");
#ifdef RENAME_REQUIRES_NONEXISTENT_NEW_PATH
if (fd == -1){
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+");
if (fd){
if (lpconfig->pFile == NULL){
lpconfig->pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+");
if (lpconfig->pFile == NULL){
ms_warning("Could not open %s but %s works, app may have crashed during last sync.",lpconfig->filename,lpconfig->tmpfilename);
}
}
#endif
if (fd != -1){
lp_config_parse(lpconfig, pFile);
bctbx_file_close(pFile);
if (lpconfig->pFile != NULL){
lp_config_parse(lpconfig, lpconfig->pFile);
bctbx_file_close(lpconfig->pFile);
lpconfig->pFile = NULL;
lpconfig->modified=0;
}
......@@ -463,10 +456,8 @@ fail:
int lp_config_read_file(LpConfig *lpconfig, const char *filename){
char* path = lp_realpath(filename, NULL);
int fd=-1;
bctbx_vfs_file_t* pFile = bctbx_file_open(lpconfig->g_bctbx_vfs, path, "r");
fd = pFile->fd;
if (fd != -1){
if (pFile != NULL){
ms_message("Reading config information from %s", path);
lp_config_parse(lpconfig, pFile);
bctbx_file_close(pFile);
......@@ -927,7 +918,7 @@ static const char *_lp_config_dirname(char *path) {
}
bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *filename) {
bctbx_vfs_file_t *pFile = lpconfig->pFile;
bctbx_vfs_file_t *pFile;
if (lpconfig->filename == NULL) {
return FALSE;
} else {
......@@ -943,10 +934,10 @@ bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *file
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "r");
ms_free(realfilepath);
if (pFile->fd != -1) {
if (pFile != NULL) {
bctbx_file_close(pFile);
}
return pFile->fd > 0;
return pFile != NULL;
}
}
......@@ -955,9 +946,8 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
const char *dir = NULL;
char *filepath = NULL;
char *realfilepath = NULL;
int fd = 0;
bctbx_vfs_file_t *pFile;
bctbx_vfs_file_t *pFile = lpconfig->pFile;
if (lpconfig->filename == NULL) return;
if(strlen(data) == 0) {
......@@ -974,10 +964,8 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
goto end;
}
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "w");
fd = pFile->fd;
if(fd == -1) {
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "w");
if(pFile == NULL) {
ms_error("Could not open %s for write", realfilepath);
goto end;
}
......@@ -994,7 +982,6 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename,
char *dup_config_file = NULL;
const char *dir = NULL;
char *filepath = NULL;
int fd = 0;
bctbx_vfs_file_t* pFile = NULL;
char* realfilepath = NULL;
......@@ -1011,16 +998,12 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename,
}
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath,"r");
if (pFile !=NULL)
fd = pFile->fd;
if(fd == -1 ) {
if (pFile == NULL) {
ms_error("Could not open %s for read.", realfilepath);
goto err;
}
if(bctbx_file_read(pFile, data, 1, max_length) < 0){
if(bctbx_file_read(pFile, data, 1, (off_t)max_length) < 0){
ms_error("%s could not be loaded.", realfilepath);