Пример #1
0
static void message_storage_migration() {
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	char src_db[256];
	char tmp_db[256];
	MSList* chatrooms;
	snprintf(src_db,sizeof(src_db), "%s/messages.db", liblinphone_tester_file_prefix);
	snprintf(tmp_db,sizeof(tmp_db), "%s/tmp.db", liblinphone_tester_writable_dir_prefix);

	CU_ASSERT_EQUAL_FATAL(message_tester_copy_file(src_db, tmp_db), 0);

	// enable to test the performances of the migration step
	//linphone_core_message_storage_set_debug(marie->lc, TRUE);

	// the messages.db has 10000 dummy messages with the very first DB scheme.
	// This will test the migration procedure
	linphone_core_set_chat_database_path(marie->lc, tmp_db);

	chatrooms = linphone_core_get_chat_rooms(marie->lc);
	CU_ASSERT(ms_list_size(chatrooms) > 0);

	// check that all messages have been migrated to the UTC time storage
	CU_ASSERT(sqlite3_exec(marie->lc->db, "SELECT COUNT(*) FROM history WHERE time != '-1';", check_no_strange_time, NULL, NULL) == SQLITE_OK );

	linphone_core_manager_destroy(marie);
	remove(tmp_db);
}
Пример #2
0
QLinphoneCore::QLinphoneCore(QObject *parent) : QObject(parent)
{
    QDir confDir = QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
    confDir.mkdir("Linphone");

    QString config_file = confDir.absolutePath() + "/Linphone/.linphonerc";
    QString chatDb_file = confDir.absolutePath() + "/Linphone/chatdb.db";
	qDebug() << "Config file:" << config_file;

    static LinphoneCoreVTable vtable = {0};

    vtable.global_state_changed = qlinphone_global_state_changed;
	vtable.message_received = qlinphone_message_received;
	vtable.auth_info_requested = qlinphone_auth_info_requested;
	vtable.registration_state_changed = qlinphone_registration_state_changed;

	lc = linphone_core_new(&vtable, config_file.toStdString().c_str() , NULL, this);

    linphone_core_set_chat_database_path(lc,chatDb_file.toStdString().c_str());

	// build proxies list
	const MSList* proxyList = linphone_core_get_proxy_config_list(lc);
	const MSList* proxy = proxyList;
	while( proxy ){
		proxies.append((LinphoneProxyConfig*)proxy->data);
		proxy = proxy->next;
	}

	// build chatrooms list
	const MSList* roomsList = linphone_core_get_chat_rooms(lc);
	const MSList* iter = roomsList;
	while(iter){
		rooms.append(new QLChatRoom((LinphoneChatRoom*)iter->data));
		iter=iter->next;
	}


	// iterate
	QTimer *timer = new QTimer();
	connect(timer, &QTimer::timeout, this, &QLinphoneCore::iterate);
	timer->start(20);
}