pidgin/pidgin

741992355ead
GSoC History API including sqlite history adapter

The History API has been created to drive all message handling in purple3. It will be used to update existing messages for edits, reactions, pinning, read/deliver receipts, etc. The API uses an adapter pattern, to abstract out backends, but provides a SQLite3 backend by default.

It also provides search capabilities using a custom query language that can easily be expanded over time. It will be use by both the end user to search messages and the frontends to implement features like a pinned messages button. A command line utility is also provided for searching outside of the program itself.

## Remaining Items

**These all will most likely be done by the Pidgin core team after GSoC when we figure out exactly how to solve them.**

Need to store database in purple config directory
* Gary has spent some time looking at this and it looks like the purple-history cli will need to become a purple-ui to make this work write as in the future other adapters will be plugins.

Other things to consider:
- For simplicity, the SqliteHistoryAdapter is parsing the query itself, but for consistency having `PurpleHistoryAdapter` parse the query and pass tokens to the subclass might be something we want to do.

Testing Done:
## Unit Tests
History Manager
History Adapter

## Integration Tests
purplehistorycore created for integration tests.
PurpleSqliteHistoryAdapter functionality tested:
- Creates proper db schema
- Writes logs
- Reads logs
- Queries using query language
- Deletes using query language

Bugs closed: PIDGIN-17526, PIDGIN-17532, PIDGIN-17533, PIDGIN-17534

Reviewed at https://reviews.imfreedom.org/r/877/
/*
* Purple - Internet Messaging Library
* Copyright (C) Pidgin Developers <devel@pidgin.im>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#include <glib/gi18n-lib.h>
#include "purplenoopcredentialprovider.h"
#include "purplecredentialmanager.h"
struct _PurpleNoopCredentialProvider {
PurpleCredentialProvider parent;
};
G_DEFINE_TYPE(PurpleNoopCredentialProvider, purple_noop_credential_provider,
PURPLE_TYPE_CREDENTIAL_PROVIDER)
/******************************************************************************
* PurpleCredentialProvider Implementation
*****************************************************************************/
static void
purple_noop_credential_provider_read_password_async(PurpleCredentialProvider *provider,
PurpleAccount *account,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer data)
{
GTask *task = g_task_new(G_OBJECT(provider), cancellable, callback, data);
g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
_("provider does not store passwords"));
g_object_unref(G_OBJECT(task));
}
static gchar *
purple_noop_credential_provider_read_password_finish(PurpleCredentialProvider *provider,
GAsyncResult *result,
GError **error)
{
return g_task_propagate_pointer(G_TASK(result), error);
}
static void
purple_noop_credential_provider_write_password_async(PurpleCredentialProvider *provider,
PurpleAccount *account,
const gchar *password,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer data)
{
GTask *task = g_task_new(G_OBJECT(provider), cancellable, callback, data);
g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
_("provider does not store passwords"));
g_object_unref(G_OBJECT(task));
}
static gboolean
purple_noop_credential_provider_write_password_finish(PurpleCredentialProvider *provider,
GAsyncResult *result,
GError **error)
{
return g_task_propagate_boolean(G_TASK(result), error);
}
/******************************************************************************
* GObject Implementation
*****************************************************************************/
static void
purple_noop_credential_provider_init(PurpleNoopCredentialProvider *provider) {
}
static void
purple_noop_credential_provider_class_init(PurpleNoopCredentialProviderClass *klass)
{
PurpleCredentialProviderClass *provider_class = NULL;
provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass);
provider_class->read_password_async =
purple_noop_credential_provider_read_password_async;
provider_class->read_password_finish =
purple_noop_credential_provider_read_password_finish;
provider_class->write_password_async =
purple_noop_credential_provider_write_password_async;
provider_class->write_password_finish =
purple_noop_credential_provider_write_password_finish;
}
/******************************************************************************
* Public API
*****************************************************************************/
PurpleCredentialProvider *
purple_noop_credential_provider_new(void) {
return PURPLE_CREDENTIAL_PROVIDER(g_object_new(
PURPLE_TYPE_NOOP_CREDENTIAL_PROVIDER,
"id", "noop-provider",
"name", _("None"),
"description", _("Passwords will not be saved."),
NULL
));
}