Baseline: Ausgangszustand vor Modularisierung
Erster Commit des bestehenden monolithischen WinForms-Copytraders, inklusive der Alt-Backups (*.bak), damit diese dauerhaft in der Historie rekonstruierbar bleiben. Threema-Lib unter libs/ wurde vendored (nested .git entfernt). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IcgSoftware.Threema.CoreMsgApi.Results
|
||||
{
|
||||
/// <summary>
|
||||
/// Result of a capability lookup
|
||||
/// </summary>
|
||||
public class CapabilityResult
|
||||
{
|
||||
private readonly string key;
|
||||
private readonly string[] capabilities;
|
||||
|
||||
public CapabilityResult(string key, string[] capabilities)
|
||||
{
|
||||
this.key = key;
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
|
||||
public string Key
|
||||
{
|
||||
get { return key; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all capabilities as a string array.
|
||||
/// </summary>
|
||||
public string[] Capabilities
|
||||
{
|
||||
get { return capabilities; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the Threema ID can receive text
|
||||
/// </summary>
|
||||
public bool CanText
|
||||
{
|
||||
get { return this.Can("text"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the Threema ID can receive images
|
||||
/// </summary>
|
||||
public bool CanImage
|
||||
{
|
||||
get { return this.Can("image"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the Threema ID can receive videos
|
||||
/// </summary>
|
||||
public bool CanVideo
|
||||
{
|
||||
get { return this.Can("video"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the Threema ID can receive audio
|
||||
/// </summary>
|
||||
public bool CanAudio
|
||||
{
|
||||
get { return this.Can("audio"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the Threema ID can receive files
|
||||
/// </summary>
|
||||
public bool CanFile
|
||||
{
|
||||
get { return this.Can("file"); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.Append(this.key).Append(": ");
|
||||
for (int n = 0; n < this.capabilities.Length; n++) {
|
||||
if (n > 0)
|
||||
{
|
||||
b.Append(",");
|
||||
}
|
||||
b.Append(this.capabilities[n]);
|
||||
}
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
private bool Can(string key)
|
||||
{
|
||||
return this.capabilities.Any(k => k.Equals(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IcgSoftware.Threema.CoreMsgApi.Results
|
||||
{
|
||||
public class EncryptResult
|
||||
{
|
||||
private readonly byte[] result;
|
||||
private readonly byte[] secret;
|
||||
private readonly byte[] nonce;
|
||||
|
||||
public EncryptResult(byte[] result, byte[] secret, byte[] nonce)
|
||||
{
|
||||
this.result = result;
|
||||
this.secret = secret;
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the encrypted data
|
||||
/// </summary>
|
||||
public byte[] Result
|
||||
{
|
||||
get { return this.result; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the size (in bytes) of the encrypted data
|
||||
/// </summary>
|
||||
public int Size
|
||||
{
|
||||
get { return this.result.Length; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the nonce that was used for encryption
|
||||
/// </summary>
|
||||
public byte[] Nonce
|
||||
{
|
||||
get { return this.nonce; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the secret that was used for encryption (only for symmetric encryption, e.g. files)
|
||||
/// </summary>
|
||||
public byte[] Secret
|
||||
{
|
||||
get { return secret; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using IcgSoftware.Threema.CoreMsgApi.Messages;
|
||||
|
||||
namespace IcgSoftware.Threema.CoreMsgApi.Results
|
||||
{
|
||||
public class ReceiveMessageResult
|
||||
{
|
||||
private readonly string messageId;
|
||||
private readonly ThreemaMessage message;
|
||||
protected List<FileInfo> files = new List<FileInfo>();
|
||||
protected List<string> errors = new List<string>();
|
||||
|
||||
public ReceiveMessageResult(string messageId, ThreemaMessage message)
|
||||
{
|
||||
this.messageId = messageId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public List<FileInfo> Files
|
||||
{
|
||||
get { return this.files; }
|
||||
}
|
||||
|
||||
public List<string> Errors
|
||||
{
|
||||
get { return this.errors; }
|
||||
}
|
||||
|
||||
public ThreemaMessage Message
|
||||
{
|
||||
get { return this.message; }
|
||||
}
|
||||
|
||||
public string MessageId
|
||||
{
|
||||
get { return messageId; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IcgSoftware.Threema.CoreMsgApi.Results
|
||||
{
|
||||
public class UploadResult
|
||||
{
|
||||
private readonly int responseCode;
|
||||
private readonly byte[] blobId;
|
||||
|
||||
public UploadResult(int responseCode, byte[] blobId)
|
||||
{
|
||||
this.responseCode = responseCode;
|
||||
this.blobId = blobId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the blob ID that has been created
|
||||
/// </summary>
|
||||
public byte[] BlobId
|
||||
{
|
||||
get { return this.blobId; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// whether the upload succeeded
|
||||
/// </summary>
|
||||
public bool IsSuccess
|
||||
{
|
||||
get { return this.responseCode == 200; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the response code of the upload
|
||||
/// </summary>
|
||||
public int ResponseCode
|
||||
{
|
||||
get { return this.responseCode; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user