diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/matrix-client.iml b/.idea/matrix-client.iml new file mode 100644 index 0000000..0351d43 --- /dev/null +++ b/.idea/matrix-client.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..870a71c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tauri-matrix/.gitignore b/tauri-matrix/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/tauri-matrix/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/tauri-matrix/.vscode/extensions.json b/tauri-matrix/.vscode/extensions.json new file mode 100644 index 0000000..24d7cc6 --- /dev/null +++ b/tauri-matrix/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/tauri-matrix/README.md b/tauri-matrix/README.md new file mode 100644 index 0000000..441faf7 --- /dev/null +++ b/tauri-matrix/README.md @@ -0,0 +1,7 @@ +# Tauri + Vanilla + +This template should help get you started developing with Tauri in vanilla HTML, CSS and Javascript. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/tauri-matrix/package-lock.json b/tauri-matrix/package-lock.json new file mode 100644 index 0000000..d44cd50 --- /dev/null +++ b/tauri-matrix/package-lock.json @@ -0,0 +1,227 @@ +{ + "name": "tauri-matrix", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tauri-matrix", + "version": "0.1.0", + "dependencies": { + "@tauri-apps/api": "^2.3.0" + }, + "devDependencies": { + "@tauri-apps/cli": "^2" + } + }, + "node_modules/@tauri-apps/api": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.3.0.tgz", + "integrity": "sha512-33Z+0lX2wgZbx1SPFfqvzI6su63hCBkbzv+5NexeYjIx7WA9htdOKoRR7Dh3dJyltqS5/J8vQFyybiRoaL0hlA==", + "license": "Apache-2.0 OR MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/tauri" + } + }, + "node_modules/@tauri-apps/cli": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.2.7.tgz", + "integrity": "sha512-ZnsS2B4BplwXP37celanNANiIy8TCYhvg5RT09n72uR/o+navFZtGpFSqljV8fy1Y4ixIPds8FrGSXJCN2BerA==", + "dev": true, + "license": "Apache-2.0 OR MIT", + "bin": { + "tauri": "tauri.js" + }, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/tauri" + }, + "optionalDependencies": { + "@tauri-apps/cli-darwin-arm64": "2.2.7", + "@tauri-apps/cli-darwin-x64": "2.2.7", + "@tauri-apps/cli-linux-arm-gnueabihf": "2.2.7", + "@tauri-apps/cli-linux-arm64-gnu": "2.2.7", + "@tauri-apps/cli-linux-arm64-musl": "2.2.7", + "@tauri-apps/cli-linux-x64-gnu": "2.2.7", + "@tauri-apps/cli-linux-x64-musl": "2.2.7", + "@tauri-apps/cli-win32-arm64-msvc": "2.2.7", + "@tauri-apps/cli-win32-ia32-msvc": "2.2.7", + "@tauri-apps/cli-win32-x64-msvc": "2.2.7" + } + }, + "node_modules/@tauri-apps/cli-darwin-arm64": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.2.7.tgz", + "integrity": "sha512-54kcpxZ3X1Rq+pPTzk3iIcjEVY4yv493uRx/80rLoAA95vAC0c//31Whz75UVddDjJfZvXlXZ3uSZ+bnCOnt0A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-darwin-x64": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.2.7.tgz", + "integrity": "sha512-Vgu2XtBWemLnarB+6LqQeLanDlRj7CeFN//H8bVVdjbNzxcSxsvbLYMBP8+3boa7eBnjDrqMImRySSgL6IrwTw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.2.7.tgz", + "integrity": "sha512-+Clha2iQAiK9zoY/KKW0KLHkR0k36O78YLx5Sl98tWkwI3OBZFg5H5WT1plH/4sbZIS2aLFN6dw58/JlY9Bu/g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm64-gnu": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.2.7.tgz", + "integrity": "sha512-Z/Lp4SQe6BUEOays9BQAEum2pvZF4w9igyXijP+WbkOejZx4cDvarFJ5qXrqSLmBh7vxrdZcLwoLk9U//+yQrg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm64-musl": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.7.tgz", + "integrity": "sha512-+8HZ+txff/Y3YjAh80XcLXcX8kpGXVdr1P8AfjLHxHdS6QD4Md+acSxGTTNbplmHuBaSHJvuTvZf9tU1eDCTDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-x64-gnu": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.2.7.tgz", + "integrity": "sha512-ahlSnuCnUntblp9dG7/w5ZWZOdzRFi3zl0oScgt7GF4KNAOEa7duADsxPA4/FT2hLRa0SvpqtD4IYFvCxoVv3Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-x64-musl": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.7.tgz", + "integrity": "sha512-+qKAWnJRSX+pjjRbKAQgTdFY8ecdcu8UdJ69i7wn3ZcRn2nMMzOO2LOMOTQV42B7/Q64D1pIpmZj9yblTMvadA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-arm64-msvc": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.2.7.tgz", + "integrity": "sha512-aa86nRnrwT04u9D9fhf5JVssuAZlUCCc8AjqQjqODQjMd4BMA2+d4K9qBMpEG/1kVh95vZaNsLogjEaqSTTw4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-ia32-msvc": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.2.7.tgz", + "integrity": "sha512-EiJ5/25tLSQOSGvv+t6o3ZBfOTKB5S3vb+hHQuKbfmKdRF0XQu2YPdIi1CQw1DU97ZAE0Dq4frvnyYEKWgMzVQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-x64-msvc": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.2.7.tgz", + "integrity": "sha512-ZB8Kw90j8Ld+9tCWyD2fWCYfIrzbQohJ4DJSidNwbnehlZzP7wAz6Z3xjsvUdKtQ3ibtfoeTqVInzCCEpI+pWg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + } + } +} diff --git a/tauri-matrix/package.json b/tauri-matrix/package.json new file mode 100644 index 0000000..de9c720 --- /dev/null +++ b/tauri-matrix/package.json @@ -0,0 +1,15 @@ +{ + "name": "tauri-matrix", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "tauri": "tauri" + }, + "devDependencies": { + "@tauri-apps/cli": "^2" + }, + "dependencies": { + "@tauri-apps/api": "^2.3.0" + } +} diff --git a/tauri-matrix/src-tauri/.gitignore b/tauri-matrix/src-tauri/.gitignore new file mode 100644 index 0000000..b21bd68 --- /dev/null +++ b/tauri-matrix/src-tauri/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/tauri-matrix/src-tauri/Cargo.toml b/tauri-matrix/src-tauri/Cargo.toml new file mode 100644 index 0000000..3486645 --- /dev/null +++ b/tauri-matrix/src-tauri/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "tauri-matrix" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "tauri_matrix_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-opener = "2" +matrix-sdk = "0.10.0" +ruma = "0.12.1" +log = "0.4.26" +env_logger = "0.11.6" +tokio = { version = "1", features = ["full"] } +sqlx = { version = "0.5", features = ["postgres", "runtime-tokio-native-tls"] } +dotenv = "0.15" +serde_json = "1.0" diff --git a/tauri-matrix/src-tauri/build.rs b/tauri-matrix/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/tauri-matrix/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/tauri-matrix/src-tauri/capabilities/default.json b/tauri-matrix/src-tauri/capabilities/default.json new file mode 100644 index 0000000..4cdbf49 --- /dev/null +++ b/tauri-matrix/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default" + ] +} diff --git a/tauri-matrix/src-tauri/icons/128x128.png b/tauri-matrix/src-tauri/icons/128x128.png new file mode 100644 index 0000000..6be5e50 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/128x128.png differ diff --git a/tauri-matrix/src-tauri/icons/128x128@2x.png b/tauri-matrix/src-tauri/icons/128x128@2x.png new file mode 100644 index 0000000..e81bece Binary files /dev/null and b/tauri-matrix/src-tauri/icons/128x128@2x.png differ diff --git a/tauri-matrix/src-tauri/icons/32x32.png b/tauri-matrix/src-tauri/icons/32x32.png new file mode 100644 index 0000000..a437dd5 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/32x32.png differ diff --git a/tauri-matrix/src-tauri/icons/Square107x107Logo.png b/tauri-matrix/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 0000000..0ca4f27 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square107x107Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square142x142Logo.png b/tauri-matrix/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 0000000..b81f820 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square142x142Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square150x150Logo.png b/tauri-matrix/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 0000000..624c7bf Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square150x150Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square284x284Logo.png b/tauri-matrix/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 0000000..c021d2b Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square284x284Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square30x30Logo.png b/tauri-matrix/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 0000000..6219700 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square30x30Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square310x310Logo.png b/tauri-matrix/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 0000000..f9bc048 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square310x310Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square44x44Logo.png b/tauri-matrix/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 0000000..d5fbfb2 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square44x44Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square71x71Logo.png b/tauri-matrix/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 0000000..63440d7 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square71x71Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/Square89x89Logo.png b/tauri-matrix/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 0000000..f3f705a Binary files /dev/null and b/tauri-matrix/src-tauri/icons/Square89x89Logo.png differ diff --git a/tauri-matrix/src-tauri/icons/StoreLogo.png b/tauri-matrix/src-tauri/icons/StoreLogo.png new file mode 100644 index 0000000..4556388 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/StoreLogo.png differ diff --git a/tauri-matrix/src-tauri/icons/icon.icns b/tauri-matrix/src-tauri/icons/icon.icns new file mode 100644 index 0000000..12a5bce Binary files /dev/null and b/tauri-matrix/src-tauri/icons/icon.icns differ diff --git a/tauri-matrix/src-tauri/icons/icon.ico b/tauri-matrix/src-tauri/icons/icon.ico new file mode 100644 index 0000000..b3636e4 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/icon.ico differ diff --git a/tauri-matrix/src-tauri/icons/icon.png b/tauri-matrix/src-tauri/icons/icon.png new file mode 100644 index 0000000..e1cd261 Binary files /dev/null and b/tauri-matrix/src-tauri/icons/icon.png differ diff --git a/tauri-matrix/src-tauri/src/auth.rs b/tauri-matrix/src-tauri/src/auth.rs new file mode 100644 index 0000000..0e5bcf5 --- /dev/null +++ b/tauri-matrix/src-tauri/src/auth.rs @@ -0,0 +1,48 @@ +use std::ptr::null; +use crate::{msdk}; +use crate::msdk::user_id::UserId; +use log::{info, warn, error}; +use matrix_sdk::ServerName; +use crate::msdk::user_id; + + + + +#[tauri::command] +pub async fn login(homeserver: &str, username: &str, password: &str) -> Result { + + let client_build_server = 1; + let matrix_auth = 2; + + let client = match msdk::Client::builder().server_name(<&ServerName>::try_from(homeserver).unwrap()).build().await { + Ok(client) => client, // If successful, use the client + Err(e) => { + error!("Error log: build client failure {:?}", e); + return Ok(client_build_server); + + } + }; + + // First we need to log in. + match client.matrix_auth().login_username(username, &*password).send().await { + Ok(response) => { + error!("Login Success! {:?}", response); + + let access_token = response.access_token; + let user_id = response.user_id; + let device_id = response.device_id; + + Ok(0) + } + Err(e) => { + + error!("Error log: login failed. {:?}", e); + Ok(matrix_auth) + } + } + + + +} + + diff --git a/tauri-matrix/src-tauri/src/db.rs b/tauri-matrix/src-tauri/src/db.rs new file mode 100644 index 0000000..dd82d92 --- /dev/null +++ b/tauri-matrix/src-tauri/src/db.rs @@ -0,0 +1,29 @@ +use sqlx::postgres::PgPoolOptions; +use std::env; +use dotenv::dotenv; +use log::error; + +#[tokio::main] +pub async fn db_init() -> Result { + dotenv().ok(); + + + let database_url = "postgres://test_user:testpasswd@localhost/data"; + + let pool = PgPoolOptions::new().max_connections(5).connect(&database_url).await; + + match pool { + Ok(pool) => Ok(pool), + Err(e) => { + error!("Failed to create database pool: {}", e); + Err(e) + } + } +} + + + + + + + diff --git a/tauri-matrix/src-tauri/src/eventhandler.rs b/tauri-matrix/src-tauri/src/eventhandler.rs new file mode 100644 index 0000000..e69de29 diff --git a/tauri-matrix/src-tauri/src/lib.rs b/tauri-matrix/src-tauri/src/lib.rs new file mode 100644 index 0000000..a5f3f14 --- /dev/null +++ b/tauri-matrix/src-tauri/src/lib.rs @@ -0,0 +1,20 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + + +use sqlx::Value; + +use serde_json; + +pub mod auth; +pub mod msdk; +pub mod db; +//pub mod main; + +#[cfg_attr(mobile, tauri::mobile_entry_point, )] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![auth::login]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/tauri-matrix/src-tauri/src/main.rs b/tauri-matrix/src-tauri/src/main.rs new file mode 100644 index 0000000..dc9df95 --- /dev/null +++ b/tauri-matrix/src-tauri/src/main.rs @@ -0,0 +1,19 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + + +pub mod auth; +pub mod msdk; + +pub mod db; + +fn main() { + + env_logger::init(); + db::db_init(); + tauri_matrix_lib::run(); + + +} + + diff --git a/tauri-matrix/src-tauri/src/msdk.rs b/tauri-matrix/src-tauri/src/msdk.rs new file mode 100644 index 0000000..6ce9675 --- /dev/null +++ b/tauri-matrix/src-tauri/src/msdk.rs @@ -0,0 +1,4 @@ +pub(crate) use matrix_sdk::{ + Client, config::SyncSettings, + ruma::{user_id, events::room::message::SyncRoomMessageEvent}, +}; diff --git a/tauri-matrix/src-tauri/tauri.conf.json b/tauri-matrix/src-tauri/tauri.conf.json new file mode 100644 index 0000000..17743ec --- /dev/null +++ b/tauri-matrix/src-tauri/tauri.conf.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "tauri-matrix", + "version": "0.1.0", + "identifier": "com.tauri-matrix.app", + "build": { + "frontendDist": "../src" + }, + "app": { + "withGlobalTauri": true, + "windows": [ + { + "title": "tauri-matrix", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/tauri-matrix/src/assets/javascript.svg b/tauri-matrix/src/assets/javascript.svg new file mode 100644 index 0000000..f9abb2b --- /dev/null +++ b/tauri-matrix/src/assets/javascript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tauri-matrix/src/assets/tauri.svg b/tauri-matrix/src/assets/tauri.svg new file mode 100644 index 0000000..31b62c9 --- /dev/null +++ b/tauri-matrix/src/assets/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/tauri-matrix/src/index.html b/tauri-matrix/src/index.html new file mode 100644 index 0000000..d8ade73 --- /dev/null +++ b/tauri-matrix/src/index.html @@ -0,0 +1,18 @@ + + + + + + + Tauri App + + + + +
+

Welcome

+ Login + Register +
+ + diff --git a/tauri-matrix/src/login.html b/tauri-matrix/src/login.html new file mode 100644 index 0000000..ae0bc2c --- /dev/null +++ b/tauri-matrix/src/login.html @@ -0,0 +1,26 @@ + + + + + Title + + + + + + + + + +

+ + + + + + diff --git a/tauri-matrix/src/main.js b/tauri-matrix/src/main.js new file mode 100644 index 0000000..23d6af8 --- /dev/null +++ b/tauri-matrix/src/main.js @@ -0,0 +1,35 @@ + +const invoke = window.__TAURI__.core.invoke; + +async function login() { + + let homeserver = document.getElementById("homeserver").value; + let username = document.getElementById("username").value; + let password = document.getElementById("password").value; + + let label = document.getElementById("error-label"); + + + const errors = ["Could not connect to homeserver", "Incorrect username or password"]; + + /** + * Error Codes + * @code {u8 / int}: 0 - Successful, no error + * @code {u8 / int}: 1 - Could not connect to homeserver (auth.rs - let client = match msdk::Client::builder().server_name) + * @code {u8 / int}: 2 - Incorrect username or password (auth.rs - match client.matrix_auth().login_username) + */ + + + let result = await invoke('login', {homeserver: homeserver, username: username, password: password}); + + if ( result !== 0 ) { + for (let i=0; i < errors.length + 1; i++) { + if (result === i) { + label.innerText = errors[i-1] + " [" + i + "]"; + break; + } + } + + } + +} diff --git a/tauri-matrix/src/styles.css b/tauri-matrix/src/styles.css new file mode 100644 index 0000000..e57b8ac --- /dev/null +++ b/tauri-matrix/src/styles.css @@ -0,0 +1,112 @@ +.logo.vanilla:hover { + filter: drop-shadow(0 0 2em #ffe21c); +} +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +}