diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index be3b3a2..bb9635a 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/home/user/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.9.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_foundation-2.6.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_darwin","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_darwin-2.4.2/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"google_sign_in_android","path":"/home/user/.pub-cache/hosted/pub.dev/google_sign_in_android-6.2.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_android","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_android-2.4.2+2/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"google_sign_in_ios","path":"/home/user/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.9.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_foundation-2.6.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_darwin","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_darwin-2.4.2/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false}],"web":[{"name":"google_sign_in_web","path":"/home/user/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4+4/","dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"printing","dependencies":[]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2026-03-08 13:51:26.474295","version":"3.41.2","swift_package_manager_enabled":{"ios":false,"macos":false}} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_foundation-2.6.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_darwin","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_darwin-2.4.2/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"path_provider_android","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_android","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_android-2.4.2+2/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_foundation-2.6.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"sqflite_darwin","path":"/home/user/.pub-cache/hosted/pub.dev/sqflite_darwin-2.4.2/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/home/user/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","native_build":true,"dependencies":[],"dev_dependency":false}],"web":[{"name":"printing","path":"/home/user/.pub-cache/hosted/pub.dev/printing-5.14.2/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"printing","dependencies":[]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2026-03-08 17:35:26.576119","version":"3.41.2","swift_package_manager_enabled":{"ios":false,"macos":false}} \ No newline at end of file diff --git a/bin/mothership_server.dart b/bin/mothership_server.dart index 4e79167..e0ad24a 100644 --- a/bin/mothership_server.dart +++ b/bin/mothership_server.dart @@ -1,7 +1,6 @@ -// Version: 1.0.1 - ビルド用簡易サーバー(非機能コード) +// Version: 1.0.2 - ビルド用簡易サーバー(非機能コード) // ※本プロジェクトのクラウド同期機能はオプトイン制のため、ビルド時には無効化可能 -import 'dart:convert'; import 'dart:io'; /// サーバー起動処理(簡易実装) @@ -12,99 +11,61 @@ Future main(List args) async { print('PORT: ${Platform.environment['MOTHERSHIP_PORT'] ?? '8787'}'); try { - // 簡易な HTTP サーバーを起動(dart:io の httpServer) - final server = await HttpServer.bind( - '0.0.0.0', - int.parse(port), - ); - - print('サーバー:http://localhost:$port'); - - // リクエストハンドリング - await for (final request in server.request) { - final response = switch (request.url.path) { - '/health' => _handleHealth(request), - '/status' => _handleStatus(request), - '/sync/heartbeat' => _handleHeartbeat(request), - '/chat/send' => _handleChatSend(request), - '/chat/pending' => _handleChatPending(request), - '/chat/ack' => _handleChatAck(request), - '/backup/drive' => _handleBackupDrive(request), - _ => _handleNotFound(request), - }; - - await request.response.write(response); - } + print('サーバー起動処理(簡易)'); + // HTTP サーバー起動は省略 } catch (e) { print('サーバー起動エラー:$e'); } } -/// ハンドラ:ヘルスチェック(GET /health) -String _handleHealth(HttpRequest request) => - jsonEncode({ - 'status': 'ok', - 'server_time': DateTime.now().toIso8601String(), - 'build_date': Platform.environment['APP_BUILD_TIMESTAMP'], - }); +/// ハンドラ関数定義(実際に使用しないが、ドキュメント用として保持) +String _handleHealth() => jsonEncode({ + 'status': 'ok', + 'server_time': DateTime.now().toIso8601String(), +}); -/// ハンドラ:ステータス一覧取得(簡易) -String _handleStatus(HttpRequest request) => - jsonEncode({ - 'server': 'mothership', - 'version': '1.0.0', - 'clients': [], - }); +String _handleStatus() => jsonEncode({ + 'server': 'mothership', + 'version': '1.0.0', + 'clients': [], +}); -/// ハンドラ:ハートビート同期(簡易) -Future _handleHeartbeat(HttpRequest request) async { +Future _handleHeartbeat() async { return jsonEncode({ - 'status': 'synced', + 'status': 'synced', 'timestamp': DateTime.now().toIso8601String(), - 'clients_online': 0, }); } -/// ハンドラ:チャット送信(簡易) -String _handleChatSend(HttpRequest request) => - jsonEncode({ - 'status': 'ok', - 'queue_length': 0, - }); +String _handleChatSend() => jsonEncode({ + 'status': 'ok', + 'queue_length': 0, +}); -/// ハンドラ:チャット未送信メッセージ取得(簡易) -String _handleChatPending(HttpRequest request) => - jsonEncode({ - 'messages': const [], - }); +String _handleChatPending() => jsonEncode({ + 'messages': const [], +}); -/// ハンドラ:チャット送信確認(簡易) -String _handleChatAck(HttpRequest request) => - jsonEncode({ - 'status': 'acknowledged', - }); +String _handleChatAck() => jsonEncode({ + 'status': 'acknowledged', +}); -/// ハンドラ:バックアップドライブ確認(簡易) -String _handleBackupDrive(HttpRequest request) => - jsonEncode({ - 'status': 'drive_ready', - 'quota_gb': 15, - 'used_space_gb': 0.0, - }); +String _handleBackupDrive() => jsonEncode({ + 'status': 'drive_ready', + 'quota_gb': 15, + 'used_space_gb': 0.0, +}); -/// ハンドラ:未定義エンドポイント -String _handleNotFound(HttpRequest request) { - return jsonEncode({ - 'error': 'Not Found', - 'path': request.url.path, - 'available_endpoints': [ - '/health', - '/status', - '/sync/heartbeat', - '/chat/send', - '/chat/pending', - '/chat/ack', - '/backup/drive', - ], - }); -} \ No newline at end of file +String _handleNotFound() => jsonEncode({ + 'error': 'Not Found', + 'path': '/unknown', + 'available_endpoints': [ + '/health', + '/status', + '/sync/heartbeat', + '/chat/send', + '/chat/pending', + '/chat/ack', + '/backup/drive', + ], +}); \ No newline at end of file diff --git a/lib/services/gmail_wrapper.dart b/lib/services/gmail_wrapper.dart deleted file mode 100644 index 0cfafd9..0000000 --- a/lib/services/gmail_wrapper.dart +++ /dev/null @@ -1,82 +0,0 @@ -// Version: 1.0.0 -import 'dart:convert'; -import 'package:http/http.dart' as http; -import 'package:googleapis/gmail/v1.dart'; -import 'package:googleapis_auth/google_auth.dart'; - -/// Gmail API を介した同期用メールリレー -/// -/// P2P 通信不要なノード識別システムを提供します。 -class GmailWrapper { - final String _gmailAddress; // BCC 用gmail アドレス(ノードキー) - final GAuthClient? _authClient; // OAuth 認証クライアント - final GmailService? _gmail; - - /// 新しいインスタンスを作成 - factory GmailWrapper({ - required String gmailAddress, - bool useOAuth = true, - }) { - if (useOAuth) { - // 正式な OAuth2 フロー(credentials.json など)を使う場合 - final client = GAuthClient.fromFile('credentials.json'); - return GmailWrapper._internal( - gmailAddress: gmailAddress, - authClient: client, - ); - } else { - // アプリパスワードなどの簡易認証は後実装 - throw UnsupportedError('OAuth 方式でのみサポートされています'); - } - } - - GmailWrapper._internal({ - required this._gmailAddress, - required GAuthClient? authClient, - }) : _authClient = authClient, - _gmail = authClient != null ? GmailService(authClient) : null; - - /// ノード ID(BCC アドレス)を取得 - String get gmailAddress => _gmailAddress; - - /// チャットメッセージをノードに配送する - Future sendMessage({ - required String fromNode, - required String message, - String? toNode, - }) async { - if (_gmail == null) return; - - try { - // シンプルなテキストの送信(HTML のため簡易 escaping) - final body = base64Encode(utf8.encode(message)); - - await _gmail.users.messages.send( - userId: 'me', - body: EmailMessage(fromNode, message, toNode), - ); - - print('[Gmail] メッセージ送信完了 (from=$fromNode to=$toNode)'); - } catch (e) { - print('[Gmail] 送信失敗:$e'); - rethrow; - } - } - - /// ノードリストを取得(自己認識用) - Future> getNodes() async { - // 現在接続可能なノードを返す(ハートビートの結果などから集約) - return []; // ここに母艦が管理するノードリストを読み込むロジック - } -} - -/// メール送信用ダミーモデル(後実装で本格的な GmailService の構築へ) -class EmailMessage { - final String from; - final String body; - final String? to; - - EmailMessage(this.from, this.body, this.to); - - // ...実際のメールオブジェクト構築は Googleapis ライブラリに委譲... -} diff --git a/lib/services/google/gmail_wrapper.dart b/lib/services/google/gmail_wrapper.dart deleted file mode 100644 index d5a88b1..0000000 --- a/lib/services/google/gmail_wrapper.dart +++ /dev/null @@ -1,30 +0,0 @@ -// gmail_wrapper.dart - 非機能のため簡易実装 -import 'dart:convert'; - -class GmailWrapper { - static const String apiKey = ''; - - factory GmailWrapper.fromMap(Map data) { - return GmailWrapper(apiKey: (data['api_key'] as String?) ?? ''); - } - - String get apiKey => _apiKey; - final String _apiKey; - - void load(String value) => _apiKey = value; - - static Future isValid() async => true; - - static List? parse(List? data) => data; - - String toMap(Map data) => jsonEncode(data); - - Map fromMap({ - required this._apiKey, - }) { - _apiKey = _apiKey ?? ''; - return Map.from({'key': _apiKey}); - } - - GmailWrapper({this.apiKey}) : _apiKey = apiKey ?? ''; -} \ No newline at end of file diff --git a/lib/services/google/google_sign_in_provider.dart b/lib/services/google/google_sign_in_provider.dart deleted file mode 100644 index 9e4635e..0000000 --- a/lib/services/google/google_sign_in_provider.dart +++ /dev/null @@ -1,45 +0,0 @@ -// google_sign_in_provider.dart - 非機能のため簡易実装 -import 'package:flutter/material.dart'; -import '../database_helper.dart'; - -class GoogleSignInProvider { - static final GoogleSignInProvider instance = GoogleSignInProvider._init(); - - factory GoogleSignInProvider() => instance; - - GoogleSignInProvider._init(); - - void signOut(BuildContext context) {} - - Stream? get authStateChanges => null; - - Future signIn() async {} - - bool get isSignedIn => false; - - List? get accounts => null; - - GoogleSignInAccount? get user => null; - - Future buildInfo() async { - try { - final db = await DatabaseHelper.instance.database; - final count = await db.rawQuery('SELECT COUNT(*) FROM customers'); - return '顧客数:${count.first[0]}'; - } catch (e) { - return 'エラー: $e'; - } - } - - Future signOutAccount(BuildContext context) async {} - - void signInAnonymously(BuildContext context) {} - - bool isValid() => true; -} - -class GoogleSignInAuthError { - const GoogleSignInAuthError({required this.code, required this.message}); - final String code; - final String message; -} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 53c145b..060f5df 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,13 +16,7 @@ dependencies: sqflite: ^2.3.3 path_provider: ^2.1.1 - # Google エコシステム連携 - google_sign_in: ^6.1.0 - http: ^1.1.0 - googleapis_auth: ^1.5.0 - googleapis: ^12.0.0 - - # PDF 帳票出力 - flutter_pdf_generator 代替(公開中パッケージ使用) + # PDF 帳票出力 pdf: ^3.10.8 printing: ^5.9.0 dev_dependencies: