Skip to content

Commit

Permalink
V0.1.1
Browse files Browse the repository at this point in the history
Added a "Mass Change" button for easier changes. (The actual reason: Human stupidity, including mine [Mainly mine!].)

Reformated some code and fixed a bug on the Lunch Break return punch.
  • Loading branch information
tockawaffle committed Oct 3, 2024
1 parent 40855cf commit 41f59c1
Show file tree
Hide file tree
Showing 49 changed files with 2,966 additions and 1,882 deletions.
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pontuall",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -22,6 +22,7 @@
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.2",
"@tauri-apps/api": "^2.0.0-beta.15",
"@tauri-apps/plugin-fs": "^2.0.0-rc.2",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pontuall"
version = "0.1.0"
version = "0.1.1"
description = "PontuAll"
authors = ["TockaNest @ https://github.com/tockanest"]
edition = "2021"
Expand Down
32 changes: 16 additions & 16 deletions src-tauri/capabilities/main.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": [
"main"
],
"permissions": [
"core:path:default",
"core:event:default",
"core:window:default",
"core:app:default",
"core:image:default",
"core:resources:default",
"core:menu:default",
"core:tray:default"
]
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": [
"main"
],
"permissions": [
"core:path:default",
"core:event:default",
"core:window:default",
"core:app:default",
"core:image:default",
"core:resources:default",
"core:menu:default",
"core:tray:default"
]
}
54 changes: 27 additions & 27 deletions src-tauri/capabilities/splashscreen.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "splash-capability",
"description": "Capability for the splashscreen window",
"windows": [
"splashscreen"
],
"permissions": [
"core:window:default",
"core:event:default",
"core:app:default",
"core:image:default",
"core:resources:default",
"core:menu:default",
"core:tray:default",
"fs:default",
"fs:allow-create",
"fs:allow-appconfig-read-recursive",
"fs:allow-appconfig-write-recursive",
{
"identifier": "fs:allow-exists",
"allow": [
{
"path": "$APPDATA/**"
}
]
}
]
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "splash-capability",
"description": "Capability for the splashscreen window",
"windows": [
"splashscreen"
],
"permissions": [
"core:window:default",
"core:event:default",
"core:app:default",
"core:image:default",
"core:resources:default",
"core:menu:default",
"core:tray:default",
"fs:default",
"fs:allow-create",
"fs:allow-appconfig-read-recursive",
"fs:allow-appconfig-write-recursive",
{
"identifier": "fs:allow-exists",
"allow": [
{
"path": "$APPDATA/**"
}
]
}
]
}
10 changes: 6 additions & 4 deletions src-tauri/src/acr122u/card/read.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

use futures::TryFutureExt;
use pcsc::*;

use crate::acr122u::card::utils::authenticate::{authenticate_14443_3, KeyType};
Expand All @@ -24,7 +23,10 @@ use crate::acr122u::utils::errors::ReaderError;
/// block 9 – data block
/// block 10 – data block
/// block 11 – sector trailer
/// And so on. Be careful when accessing the blocks, as the sector trailer contains the access bits and the key A and key B. Overwriting the sector trailer can make the card unreadable.
/// And so on.
/// Be careful when accessing the blocks,
/// as the sector trailer contains the access bits,
/// and the key A and key B. Overwriting the sector trailer can make the card unreadable.
///
/// Reads data from a specified block on a card.
///
Expand All @@ -49,7 +51,7 @@ use crate::acr122u::utils::errors::ReaderError;
/// * The reader name is invalid.
/// * The read operation fails.
/// * The card type is unsupported.
/// * The operation is cancelled.
/// * The operation is canceled.
///
/// # Examples
///
Expand Down Expand Up @@ -236,7 +238,7 @@ mod tests {
.map(|b| format!("{:02X}", b))
.collect::<Vec<String>>()
.join(" ");
// Convert the hex to readable text
// Convert the hex to a readable text
let data_text = data_str
.split_whitespace()
.map(|s| {
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/acr122u/card/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::acr122u::utils::errors::ReaderError;
/// * The data length is not a multiple of the block size.
/// * The write operation fails.
/// * The card type is unsupported.
/// * The operation is cancelled.
/// * The operation is canceled.
///
/// # Examples
///
Expand All @@ -50,8 +50,7 @@ pub(crate) async fn write_block(
cancel_flag: &Arc<AtomicBool>,
) -> Result<bool, ReaderError> {
let reader = CString::new(reader)
.map_err(|_| ReaderError::UnsupportedReader("Invalid reader name".to_string()))
.unwrap();
.map_err(|_| ReaderError::UnsupportedReader("Invalid reader name".to_string()))?;
let block_size = block_size.unwrap_or(16);

if data.len() < block_size as usize || data.len() % block_size as usize != 0 {
Expand Down Expand Up @@ -211,17 +210,18 @@ mod tests {

use super::*;

#[tokio::test]
async fn test_write_single() {
let (ctx, reader) = reader().unwrap();
let cancel_flag = Arc::new(AtomicBool::new(false));

let mut buffer = vec![0; 16];
let data = "Hello, World!";
let data = "LvKY0TDcb34hbNeJ";
let data_len = data.len();
let copy_len = std::cmp::min(data_len, buffer.len());
buffer[..copy_len].copy_from_slice(&data.as_bytes()[..copy_len]);

let result = write_block(ctx, reader, 4, buffer, Option::from(16), &cancel_flag)
let result = write_block(ctx, reader, 5, buffer, Option::from(16), &cancel_flag)
.await
.unwrap_or_else(|e| panic!("{:?}", e));

Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/acr122u/tauri_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ fn connect() -> Result<FullReaderResult, ReaderError> {
/// * `true` if the context is valid.
/// * `false` if the context is invalid.
fn validate_context(context: &Context) -> bool {
return match context.is_valid() {
match context.is_valid() {
Ok(_valid) => true,
Err(_) => false,
};
}
}

/// Reads data from a specified block on the card.
Expand Down Expand Up @@ -103,7 +103,7 @@ async fn mcp_read(block_number: u16, state: Arc<ReadState>) -> Result<Vec<u8>, R
None,
None,
)
.await?;
.await?;
Ok(read)
} else {
Err(ReaderError::PcscError(pcsc::Error::InvalidHandle))
Expand Down Expand Up @@ -254,8 +254,8 @@ async fn mcp_write(
Option::from(16),
&state.cancel_flag,
)
.await
.unwrap_or_else(|e| panic!("{:?}", e));
.await
.unwrap_or_else(|e| panic!("{:?}", e));

if result {
Ok(())
Expand Down Expand Up @@ -308,8 +308,8 @@ pub(crate) async fn write_card(
/// * `Err(ReaderError)` - If an error occurs during the connection.
#[tauri::command]
pub(crate) fn get_connection() -> Result<String, ReaderError> {
return match connect() {
match connect() {
Ok(result) => Ok(result.reader),
Err(e) => Err(e),
};
}
}
Loading

0 comments on commit 41f59c1

Please sign in to comment.