The ProfileSync module manages cross-application profile synchronization for torrent client configurations, enabling seamless sharing of server profiles between ShareConnect applications.
ProfileSync provides centralized management of torrent client server profiles, allowing users to configure qBittorrent, Transmission, and uTorrent servers once and use them across all ShareConnect applications.
- Multi-Client Support: qBittorrent, Transmission, uTorrent profiles
- Secure Storage: Encrypted profile data with SQLCipher
- Profile Adapters: Client-specific profile format conversion
- Real-time Sync: Instant profile updates across applications
- Validation: Profile connectivity and configuration validation
ProfileSync/
├── ProfileSyncManager.kt # Main synchronization manager
├── models/
│ ├── ProfileData.kt # Unified profile data model
│ └── SyncableProfile.kt # Asinka synchronization wrapper
├── repository/
│ └── ProfileRepository.kt # Local database operations
├── database/
│ ├── ProfileDao.kt # Room DAO for profile operations
│ └── ProfileDatabase.kt # Room database configuration
└── adapters/
├── QBitConnectProfileAdapter.kt # qBittorrent profile conversion
├── ShareConnectProfileAdapter.kt # ShareConnect profile conversion
├── TransmissionConnectProfileAdapter.kt # Transmission profile conversion
└── UTorrentConnectProfileAdapter.kt # uTorrent profile conversion
The ProfileData model includes:
- Connection Details: Host, port, authentication credentials
- Client Type: TORRENT_CLIENT_QBITTORRENT, TORRENT_CLIENT_TRANSMISSION, TORRENT_CLIENT_UTORRENT
- Security: Encrypted password storage
- Metadata: Profile name, description, validation status
// Initialize ProfileSyncManager
val profileManager = ProfileSyncManager.getInstance(
context = applicationContext,
appIdentifier = "com.shareconnect",
appName = "ShareConnect",
appVersion = "1.0.0"
)
// Start synchronization
CoroutineScope(Dispatchers.IO).launch {
profileManager.start()
}val qbitProfile = ProfileData(
id = "qbit_main",
name = "Main qBittorrent Server",
clientType = ProfileData.TORRENT_CLIENT_QBITTORRENT,
host = "192.168.1.100",
port = 8080,
username = "admin",
password = "encrypted_password",
isActive = true
)
// Save and sync
profileManager.saveProfile(qbitProfile)// Validate profile connectivity
val isValid = profileManager.validateProfile(qbitProfile)
if (isValid) {
// Profile is ready for use
profileManager.setActiveProfile(qbitProfile.id)
}- Web UI: Standard web interface authentication
- API Version: Supports v2.8.0+
- Features: Torrent management, category support
- RPC API: JSON-RPC over HTTP
- Authentication: Session ID based auth
- Features: Torrent operations, bandwidth limits
- Web UI: Classic web interface
- Authentication: Basic HTTP auth
- Features: Label support, priority settings
CREATE TABLE synced_profiles (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
clientType TEXT NOT NULL,
host TEXT NOT NULL,
port INTEGER NOT NULL,
username TEXT,
password TEXT, -- Encrypted
isActive INTEGER NOT NULL DEFAULT 0,
description TEXT,
createdAt INTEGER NOT NULL,
updatedAt INTEGER NOT NULL,
validationStatus TEXT,
lastValidated INTEGER
);Profile adapters convert between the unified ProfileData format and client-specific configurations used by each ShareConnect application.
interface ProfileAdapter {
fun convertToClientFormat(profile: ProfileData): ClientSpecificProfile
fun convertFromClientFormat(clientProfile: ClientSpecificProfile): ProfileData
fun validateProfile(profile: ProfileData): Boolean
}Each adapter handles:
- Authentication format conversion
- Connection parameter mapping
- Client-specific validation
- Error handling and logging
class SCApplication : BaseApplication() {
lateinit var profileSyncManager: ProfileSyncManager
override fun onCreate() {
super.onCreate()
profileSyncManager = ProfileSyncManager.getInstance(
context = this,
appIdentifier = BuildConfig.APPLICATION_ID,
appName = getString(R.string.app_name),
appVersion = BuildConfig.VERSION_NAME
)
// Start in background
CoroutineScope(Dispatchers.IO).launch {
profileSyncManager.start()
}
}
}// In qBitConnect
val adapter = QBitConnectProfileAdapter()
val clientConfig = adapter.convertToClientFormat(profileData)
// Use clientConfig to initialize qBittorrent client./gradlew :ProfileSync:testDebugUnitTestTest Coverage:
- ProfileData model validation
- Adapter conversions
- Repository operations
- Manager lifecycle
./gradlew :ProfileSync:connectedDebugAndroidTestTest Scenarios:
- Cross-app profile synchronization
- Profile validation with real servers
- Adapter conversion accuracy
- Authentication flow testing
| Method | Description |
|---|---|
getInstance() |
Get singleton instance |
start() |
Start synchronization |
saveProfile() |
Save and sync profile |
getAllProfiles() |
Get all available profiles |
setActiveProfile() |
Set active profile |
validateProfile() |
Test profile connectivity |
| Property | Type | Description |
|---|---|---|
id |
String | Unique profile identifier |
name |
String | Display name |
clientType |
String | Client type constant |
host |
String | Server hostname/IP |
port |
Int | Server port |
username |
String? | Authentication username |
password |
String? | Encrypted password |
- Password Encryption: All passwords stored encrypted using SQLCipher
- Network Security: HTTPS recommended for remote connections
- Access Control: Profile data isolated per application
- Validation: Server connectivity verified before storage
-
Connection failures
- Verify server is running and accessible
- Check firewall settings
- Validate credentials
-
Sync not working
- Ensure apps are on same network
- Check Asinka service discovery
- Verify profile data integrity
-
Adapter conversion errors
- Check client version compatibility
- Validate profile data format
- Review adapter logs
Enable detailed logging:
ProfileSyncManager.enableDebugLogging(true)- Asinka: Synchronization framework
- Room: Local database persistence
- SQLCipher: Encrypted database storage
- Kotlin Coroutines: Asynchronous operations
When contributing to ProfileSync:
- Maintain compatibility with existing profile formats
- Add validation for new client versions
- Update adapters for new client features
- Test with real torrent client instances
| Metric | Value |
|---|---|
| Memory Usage | <50 KB |
| CPU Impact | <1% |
| Network Overhead | <2 KB/sync |
| Profile Validation Latency | <100ms |
| Max Supported Profiles | 50 |
- 2.0.3: Enhanced profile adapter logic
- 2.0.2: Improved encryption and security
- 2.0.1: Bug fixes and performance improvements
- 2.0.0: Major refactoring with multi-client support
Licensed under the MIT License. See project LICENSE file for details.