mirror of https://github.com/status-im/nimqml.git
Merge pull request #30 from status-im/feature/issue-2675
feat(@desktop/general): Keychain manager added
This commit is contained in:
commit
b5ed94dfb4
|
@ -31,11 +31,12 @@ include "nimqml/private/qabstractlistmodel.nim"
|
|||
include "nimqml/private/qabstracttablemodel.nim"
|
||||
include "nimqml/private/qresource.nim"
|
||||
include "nimqml/private/qdeclarative.nim"
|
||||
include "nimqml/private/qsettings.nim"
|
||||
include "nimqml/private/nimqmlmacros.nim"
|
||||
include "nimqml/private/singleinstance.nim"
|
||||
include "nimqml/private/status/statusevent.nim"
|
||||
include "nimqml/private/status/statusosnotification.nim"
|
||||
|
||||
include "nimqml/private/status/statuskeychainmanager.nim"
|
||||
|
||||
proc signal_handler*(receiver: pointer, signal: cstring, slot: cstring) =
|
||||
var dosqobj = cast[DosQObject](receiver)
|
||||
|
|
|
@ -32,9 +32,11 @@ type
|
|||
DosQAbstractItemModel = distinct pointer
|
||||
DosQAbstractTableModel = distinct pointer
|
||||
DosQAbstractListModel = distinct pointer
|
||||
DosStatusEventObject = distinct pointer
|
||||
DosStatusOSNotificationObject = DosQObject
|
||||
|
||||
DosStatusEvent = distinct pointer
|
||||
DosStatusOSNotification = DosQObject
|
||||
DosQSettings = DosQObject
|
||||
DosStatusKeychainManager = DosQObject
|
||||
|
||||
DosParameterDefinition = object
|
||||
name: cstring
|
||||
metaType: cint
|
||||
|
@ -137,7 +139,7 @@ proc dos_qapplication_quit() {.cdecl, dynlib: dynLibName, importc.}
|
|||
proc dos_qapplication_icon(filename: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_delete() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_clipboard_setText(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_installEventFilter(engine: DosStatusEventObject) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_installEventFilter(engine: DosStatusEvent) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_clipboard_setImage(content: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qapplication_download_image(imageSource: cstring, filePath: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
|
@ -147,7 +149,7 @@ proc dos_qguiapplication_exec() {.cdecl, dynlib: dynLibName, importc.}
|
|||
proc dos_qguiapplication_quit() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_icon(filename: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_delete() {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_installEventFilter(engine: DosStatusEventObject) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qguiapplication_installEventFilter(engine: DosStatusEvent) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# QQmlContext
|
||||
proc dos_qqmlcontext_setcontextproperty(context: DosQQmlContext, propertyName: cstring, propertyValue: DosQVariant) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
@ -342,22 +344,51 @@ proc dos_singleinstance_create(uniqueName: cstring, eventStr: cstring): DosQObje
|
|||
proc dos_singleinstance_isfirst(vptr: DosQObject): bool {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_singleinstance_delete(vptr: DosQObject) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# DosStatusEventObject
|
||||
proc dos_statusevent_create_showAppEvent(engine: DosQQmlApplicationEngine): DosStatusEventObject {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_statusevent_create_osThemeEvent(engine: DosQQmlApplicationEngine): DosStatusEventObject {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_statusevent_delete(vptr: DosStatusEventObject) {.cdecl, dynlib: dynLibName, importc.}
|
||||
# DosStatusEvent
|
||||
proc dos_event_create_showAppEvent(engine: DosQQmlApplicationEngine): DosStatusEvent {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_event_create_osThemeEvent(engine: DosQQmlApplicationEngine): DosStatusEvent {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_event_delete(vptr: DosStatusEvent) {.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# DosStatusOSNotificationObject
|
||||
proc dos_statusosnotification_create(): DosStatusOSNotificationObject
|
||||
# DosStatusOSNotification
|
||||
proc dos_osnotification_create(): DosStatusOSNotification
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_statusosnotification_show_notification(vptr: DosStatusOSNotificationObject,
|
||||
title: cstring, messsage: cstring, identifier: cstring)
|
||||
proc dos_osnotification_show_notification(vptr: DosStatusOSNotification,
|
||||
title: cstring, messsage: cstring, identifier: cstring)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_statusosnotification_delete(vptr: DosStatusOSNotificationObject)
|
||||
proc dos_osnotification_delete(vptr: DosStatusOSNotification)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# QSettings
|
||||
proc dos_qsettings_create(fileName: cstring, format: int): DosQSettings
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qsettings_value(vptr: DosQSettings, key: cstring,
|
||||
defaultValue: DosQVariant): DosQVariant
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qsettings_set_value(vptr: DosQSettings, key: cstring,
|
||||
value: DosQVariant)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qsettings_remove(vptr: DosQSettings, key: cstring)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_qsettings_delete(vptr: DosQSettings)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
# DosStatusKeychainManager
|
||||
proc dos_keychainmanager_create(service: cstring, authenticationReason: cstring):
|
||||
DosStatusKeychainManager
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_keychainmanager_read_data_sync(vptr: DosStatusKeychainManager,
|
||||
key: cstring): string {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_keychainmanager_read_data_async(vptr: DosStatusKeychainManager,
|
||||
key: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_keychainmanager_store_data_async(vptr: DosStatusKeychainManager,
|
||||
key: cstring, data: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_keychainmanager_delete_data_async(vptr: DosStatusKeychainManager,
|
||||
key: cstring) {.cdecl, dynlib: dynLibName, importc.}
|
||||
proc dos_keychainmanager_delete(vptr: DosStatusKeychainManager)
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
proc dos_to_local_file(fileUrl: cstring): cstring
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
|
||||
proc dos_from_local_file(filePath: cstring): cstring
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
||||
{.cdecl, dynlib: dynLibName, importc.}
|
|
@ -44,6 +44,8 @@ type
|
|||
QResource* = ref object of RootObj ## \
|
||||
# A QResource
|
||||
|
||||
QSettings* = ref object of QObject ## \
|
||||
|
||||
QtItemFlag*{.pure, size: sizeof(cint).} = enum ## \
|
||||
## Item flags
|
||||
##
|
||||
|
@ -132,11 +134,13 @@ type
|
|||
|
||||
SingleInstance* = ref object of QObject
|
||||
|
||||
StatusEventObject* = ref object of RootObj ## \
|
||||
## A StatusEventObject
|
||||
vptr: DosStatusEventObject
|
||||
StatusEvent* = ref object of RootObj ## \
|
||||
## A StatusEvent
|
||||
vptr: DosStatusEvent
|
||||
|
||||
StatusOSNotificationObject* = ref object of QObject
|
||||
StatusOSNotification* = ref object of QObject
|
||||
|
||||
StatusKeychainManager* = ref object of QObject
|
||||
|
||||
const
|
||||
UserRole* = 0x100
|
||||
|
|
|
@ -17,7 +17,7 @@ proc icon*(application: QApplication, filename: string) =
|
|||
proc setClipboardText*(text: string = "") =
|
||||
dos_qapplication_clipboard_setText(text.cstring)
|
||||
|
||||
proc installEventFilter*(application: QApplication, event: StatusEventObject) =
|
||||
proc installEventFilter*(application: QApplication, event: StatusEvent) =
|
||||
dos_qapplication_installEventFilter(event.vptr)
|
||||
|
||||
proc setClipboardImage*(text: string = "") =
|
||||
|
|
|
@ -16,7 +16,7 @@ proc delete*(self: QGuiApplication) =
|
|||
proc icon*(application: QGuiApplication, filename: string) =
|
||||
dos_qguiapplication_icon(filename.cstring)
|
||||
|
||||
proc installEventFilter*(application: QGuiApplication, event: StatusEventObject) =
|
||||
proc installEventFilter*(application: QGuiApplication, event: StatusEvent) =
|
||||
dos_qguiapplication_installEventFilter(event.vptr)
|
||||
|
||||
proc newQGuiApplication*(): QGuiApplication =
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
type
|
||||
QSettingsFormat* {.pure.} = enum
|
||||
NativeFormat = 0
|
||||
IniFormat
|
||||
|
||||
proc setup(self: QSettings, fileName: string, format: int) =
|
||||
self.vptr = dos_qsettings_create(fileName, format)
|
||||
|
||||
proc delete*(self: QSettings) =
|
||||
dos_qsettings_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newQSettings*(fileName: string,
|
||||
format: QSettingsFormat = QSettingsFormat.NativeFormat): QSettings =
|
||||
## Available values for format are:
|
||||
## 0 - QSettings::NativeFormat
|
||||
## 1 - QSettings::IniFormat
|
||||
## any other value will be converted to 0 (QSettings::NativeFormat)
|
||||
new(result, delete)
|
||||
result.setup(fileName, format.int)
|
||||
|
||||
proc value*(self: QSettings, key: string, defaultValue: QVariant = newQVariant()):
|
||||
QVariant =
|
||||
newQVariant(dos_qsettings_value(self.vptr, key, defaultValue.vptr), Ownership.Take)
|
||||
|
||||
proc setValue*(self: QSettings, key: string, value: QVariant) =
|
||||
dos_qsettings_set_value(self.vptr, key, value.vptr)
|
||||
|
||||
proc remove*(self: QSettings, key: string) =
|
||||
dos_qsettings_remove(self.vptr, key)
|
|
@ -1,18 +1,17 @@
|
|||
proc setupDockShowAppEventObject*(self: StatusEvent, engine: QQmlApplicationEngine) =
|
||||
self.vptr = dos_event_create_showAppEvent(engine.vptr)
|
||||
|
||||
proc setupDockShowAppEventObject(self: StatusEventObject, engine: QQmlApplicationEngine) =
|
||||
self.vptr = dos_statusevent_create_showAppEvent(engine.vptr)
|
||||
proc setupOSThemeEventObject*(self: StatusEvent, engine: QQmlApplicationEngine) =
|
||||
self.vptr = dos_event_create_osThemeEvent(engine.vptr)
|
||||
|
||||
proc setupOSThemeEventObject(self: StatusEventObject, engine: QQmlApplicationEngine) =
|
||||
self.vptr = dos_statusevent_create_osThemeEvent(engine.vptr)
|
||||
|
||||
proc delete*(self: StatusEventObject) =
|
||||
dos_statusevent_delete(self.vptr)
|
||||
proc delete*(self: StatusEvent) =
|
||||
dos_event_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newStatusDockShowAppEventObject*(engine: QQmlApplicationEngine): StatusEventObject =
|
||||
proc newStatusDockShowAppEventObject*(engine: QQmlApplicationEngine): StatusEvent =
|
||||
new(result, delete)
|
||||
result.setupDockShowAppEventObject(engine)
|
||||
|
||||
proc newStatusOSThemeEventObject*(engine: QQmlApplicationEngine): StatusEventObject =
|
||||
proc newStatusOSThemeEventObject*(engine: QQmlApplicationEngine): StatusEvent =
|
||||
new(result, delete)
|
||||
result.setupOSThemeEventObject(engine)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
proc setup(self: StatusKeychainManager, service: string,
|
||||
authenticationReason: string) =
|
||||
self.vptr = dos_keychainmanager_create(service, authenticationReason)
|
||||
|
||||
proc delete*(self: StatusKeychainManager) =
|
||||
dos_keychainmanager_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newStatusKeychainManager*(service: string,
|
||||
authenticationReason: string): StatusKeychainManager =
|
||||
new(result, delete)
|
||||
result.setup(service, authenticationReason)
|
||||
|
||||
proc readDataSync*(self: StatusKeychainManager, key: string): string =
|
||||
return dos_keychainmanager_read_data_sync(self.vptr, key)
|
||||
|
||||
proc readDataAsync*(self: StatusKeychainManager, key: string) =
|
||||
dos_keychainmanager_read_data_async(self.vptr, key)
|
||||
|
||||
proc storeDataAsync*(self: StatusKeychainManager, key: string, data: string) =
|
||||
dos_keychainmanager_store_data_async(self.vptr, key, data)
|
||||
|
||||
proc deleteDataAsync*(self: StatusKeychainManager, key: string) =
|
||||
dos_keychainmanager_delete_data_async(self.vptr, key)
|
|
@ -1,14 +1,14 @@
|
|||
proc setup(self: StatusOSNotificationObject) =
|
||||
self.vptr = dos_statusosnotification_create()
|
||||
proc setup(self: StatusOSNotification) =
|
||||
self.vptr = dos_osnotification_create()
|
||||
|
||||
proc delete*(self: StatusOSNotificationObject) =
|
||||
dos_statusosnotification_delete(self.vptr)
|
||||
proc delete*(self: StatusOSNotification) =
|
||||
dos_osnotification_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newStatusOSNotificationObject*(): StatusOSNotificationObject =
|
||||
proc newStatusOSNotification*(): StatusOSNotification =
|
||||
new(result, delete)
|
||||
result.setup()
|
||||
|
||||
proc showNotification*(self: StatusOSNotificationObject, title: string,
|
||||
proc showNotification*(self: StatusOSNotification, title: string,
|
||||
message: string, identifier: string) =
|
||||
dos_statusosnotification_show_notification(self.vptr, title, message, identifier)
|
||||
dos_osnotification_show_notification(self.vptr, title, message, identifier)
|
||||
|
|
Loading…
Reference in New Issue