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/
enable_consoleui = false
if get_option('consoleui')
libgnt_dep = dependency('gnt3',
version : '>= 3.0.0',
fallback : ['libgnt', 'libgnt_dep'])
#######################################################################
# Check for ncurses and other things used by it
# FIXME: This should be temporary until libgnt wraps the functionality.
#######################################################################
ncurses_available = true
ncurses_header = 'ncurses.h'
# Some distros put the headers in ncursesw/, some don't. These are ordered to
# pick the last available as most-specific version.
ncursesw_header_paths = ['', 'ncursesw/']
ncurses = dependency('ncursesw', required : false)
if ncurses.found()
foreach location : ncursesw_header_paths
f = location / 'ncurses.h'
if compiler.has_header_symbol(f, 'get_wch',
prefix : '#define _XOPEN_SOURCE_EXTENDED')
ncurses_header = f
endif
endforeach
else
ncurses_available = false
ncurses_inc = []
ncurses_libs = compiler.find_library('ncursesw', required : false)
if ncurses_libs.found()
foreach location : ncursesw_header_paths
f = location / 'ncurses.h'
if compiler.has_header_symbol(f, 'get_wch',
prefix : '#define _XOPEN_SOURCE_EXTENDED')
ncurses_available = true
ncurses_header = f
endif
endforeach
if ncurses_available
ncurses = declare_dependency(
include_directories : ncurses_inc,
dependencies : ncurses_libs
)
endif
endif
endif
if not ncurses_available
# ncursesw was not found. Look for plain old ncurses
ncurses = dependency('ncurses', required : false)
if ncurses.found()
ncurses_available = true
else
ncurses_libs = compiler.find_library('ncurses', required : false)
ncurses_available = ncurses_libs.found()
ncurses = declare_dependency(dependencies : ncurses_libs)
endif
endif
if not ncurses_available and host_machine.system() == 'windows'
# Try pdcurses too.
ncurses_header = 'curses.h'
ncurses_libs = compiler.find_library('pdcurses', required : false)
ncurses_available = compiler.has_header(ncurses_header) and ncurses_libs.found()
ncurses = declare_dependency(dependencies : ncurses_libs)
endif
if not ncurses_available
error('ncurses could not be found!')
endif
if libgnt_dep.found() and ncurses_available
ncurses_header = '-DNCURSES_HEADER="@0@"'.format(ncurses_header)
enable_consoleui = true
else
error('''
Finch will not be built. You need to install libgnt (or its requirements) and its development headers.
''')
endif
endif
libfinch_SOURCES = [
'gntaccount.c',
'gntblist.c',
'gntconn.c',
'gntconv.c',
'gntdebug.c',
'gntidle.c',
'gntlog.c',
'gntmedia.c',
'gntmenuutil.c',
'gntnotify.c',
'gntplugin.c',
'gntprefs.c',
'gntrequest.c',
'gntroomlist.c',
'gntstatus.c',
'gntui.c',
'gntxfer.c',
package_revision,
'libfinch.c'
]
libfinch_headers = [
'gntaccount.h',
'gntblist.h',
'gntconn.h',
'gntconv.h',
'gntdebug.h',
'gntidle.h',
'gntlog.h',
'gntmedia.h',
'gntmenuutil.h',
'gntnotify.h',
'gntplugin.h',
'gntprefs.h',
'gntrequest.h',
'gntroomlist.h',
'gntstatus.h',
'gntui.h',
'gntxfer.h',
'libfinch.h'
]
libfinch_enum_headers = [
'gntconv.h',
]
# the built lists are append to below
libfinch_built_sources = []
libfinch_built_headers = []
libfinch_generated_sources = []
finch_SOURCES = [
'finch.c'
]
if IS_WIN32
winmm = compiler.find_library('winmm')
finch_winres = configure_file(
input : 'finch_winres.rc.in',
output : 'finch_winres.rc',
configuration : version_conf)
finch_SOURCES += windows.compile_resources(finch_winres)
libfinch_winres = configure_file(
input : 'libfinch_winres.rc.in',
output : 'libfinch_winres.rc',
configuration : version_conf)
libfinch_SOURCES += windows.compile_resources(libfinch_winres)
else
winmm = []
endif
if enable_consoleui
libfinch_enums = gnome.mkenums_simple('finchenums',
sources: libfinch_enum_headers)
libfinch_built_sources += libfinch_enums[0]
libfinch_built_headers += libfinch_enums[1]
FINCH_H_INCLUDES = []
foreach header : libfinch_headers + ['finchenums.h']
FINCH_H_INCLUDES += '#include <finch/@0@>'.format(header)
endforeach
finch_h_conf = configuration_data()
finch_h_conf.set('FINCH_H_INCLUDES', '\n'.join(FINCH_H_INCLUDES))
finch_h = configure_file(input : 'finch.h.in',
output : 'finch.h',
configuration : finch_h_conf,
install : true,
install_dir : get_option('includedir') / 'finch-3')
libfinch_built_headers += finch_h
install_headers(libfinch_headers, subdir : 'finch-3')
libfinch_inc = include_directories('.')
libfinch = shared_library('finch3',
libfinch_SOURCES + libfinch_built_headers + libfinch_built_sources,
c_args : ['-DSTANDALONE', '-DGNTSEAL_ENABLE', '-DFINCH_COMPILATION', ncurses_header],
include_directories : [toplevel_inc],
version : PURPLE_LIB_VERSION,
dependencies : [libpurple_dep, libgnt_dep, ncurses, glib, winmm],
install : true)
if enable_introspection
introspection_sources = libfinch_headers
Finch_gir_includes = [
'Gnt-3.0',
'GPlugin-1.0',
# subproject needs to be before libpurple in the repo so that
# meson will use our variables and not try to discover them from
# libpurple.
libpurple_gir[0],
]
libfinch_gir = gnome.generate_gir(libfinch,
sources : introspection_sources,
includes : Finch_gir_includes,
namespace : 'Finch',
symbol_prefix : 'finch',
identifier_prefix : 'Finch',
export_packages : 'finch',
nsversion : '@0@.@1@'.format(purple_major_version,
purple_minor_version),
install : true,
dependencies: [libgnt_dep, gplugin_dep],
extra_args : ['-DFINCH_COMPILATION', '--quiet'])
libfinch_generated_sources += libfinch_gir
endif
libfinch_dep = declare_dependency(
include_directories : [toplevel_inc, libfinch_inc],
link_with : libfinch,
sources: libfinch_built_headers + libfinch_generated_sources,
dependencies : [libpurple_dep, libgnt_dep, glib])
finch = executable('finch3',
finch_SOURCES,
c_args : ['-DSTANDALONE', '-DGNTSEAL_ENABLE'],
dependencies : [libpurple_dep, libgnt_dep, libfinch_dep],
install : true)
if meson.version().version_compare('>=0.54.0')
meson.override_dependency('finch-3', libfinch_dep)
endif
pkgconfig.generate(
name : 'Finch',
description : 'Finch is an instant messenger application that uses libpurple for protocol support and ncurses (libgnt) for the UI.',
version : meson.project_version(),
filebase : 'finch-3',
subdirs : 'finch-3',
libraries : [libfinch],
requires : ['gnt', 'purple-3'],
variables : ['plugindir=${libdir}/finch-@0@'.format(purple_major_version)])
subdir('plugins')
endif # enable_consoleui