Repository navigation
Expand file tree
/
Copy pathAppConfig.cs
More file actions
441 lines (383 loc) · 15.2 KB
/
Copy pathAppConfig.cs
File metadata and controls
441 lines (383 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
using Microsoft.Office.Tools.Ribbon;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace SmartMailAssistant1
{
public class AppConfig
{
public ApiSettings ApiSettings { get; set; }
public UiSettings UiSettings { get; set; }
public WindowSettings WindowSettings { get; set; }
public EmailSettings EmailSettings { get; set; }
public LanguageSettings LanguageSettings { get; set; }
public ReplySettings ReplySettings { get; set; }
public Messages Messages { get; set; }
public Prompts Prompts { get; set; }
public RibbonSettings RibbonSettings { get; set; }
public OutlookSettings OutlookSettings { get; set; }
public ClassificationSettings ClassificationSettings { get; set; }
}
public class ApiSettings
{
public string ApiKey { get; set; }
public string ApiEndpoint { get; set; }
public string ModelName { get; set; }
public int TimeoutSeconds { get; set; }
public string MessageRole { get; set; }
public string StreamPrefix { get; set; }
public string StreamEndMarker { get; set; }
public string ResponseContentPath { get; set; }
public Dictionary<string, string> RequestHeaders { get; set; }
public Dictionary<string, object> RequestParameters { get; set; }
[JsonIgnore]
public string ApiUrl
{
get => ApiEndpoint;
set => ApiEndpoint = value;
}
}
public class UiSettings
{
public FontSettings Fonts { get; set; }
public ColorSettings Colors { get; set; }
public ButtonSettings ButtonSettings { get; set; }
public LoadingSettings LoadingSettings { get; set; }
public StreamingSettings StreamingSettings { get; set; }
}
public class FontSettings
{
public string Default { get; set; }
public string Arabic { get; set; }
public string Hebrew { get; set; }
public string Persian { get; set; }
public string Urdu { get; set; }
public string Pashto { get; set; }
public string DefaultRtl { get; set; }
}
public class ColorSettings
{
public string DarkBackground { get; set; }
public string TextColor { get; set; }
public string TextBoxBackground { get; set; }
public string RetryButtonColor { get; set; }
public string SendButtonColor { get; set; }
public string GenerateAnywayButtonColor { get; set; }
public string CloseButtonColor { get; set; }
}
public class ButtonSettings
{
public int PanelHeight { get; set; }
public int ButtonWidth { get; set; }
public int LargeButtonWidth { get; set; }
public int ButtonSpacing { get; set; }
public int CloseButtonSpacing { get; set; }
public int ForceReplySendButtonWidth { get; set; }
public Dictionary<string, string> CustomActions { get; set; }
}
public class LoadingSettings
{
public int AnimationInterval { get; set; }
public List<string> LoadingStates { get; set; }
}
public class OutlookSettings
{
public string MapiNamespace { get; set; }
public DefaultFoldersSettings DefaultFolders { get; set; }
public ItemRestrictions ItemRestrictions { get; set; }
public string DefaultFallbackFolder { get; set; } // Config-driven only
public ViewSettings ViewSettings { get; set; }
}
public class DefaultFoldersSettings
{
public string PrimaryFolder { get; set; }
public string FallbackFolder { get; set; }
public List<string> SupportedFolderTypes { get; set; }
}
public class ItemRestrictions
{
public string UnreadFilter { get; set; }
public string ReadFilter { get; set; }
public string TodayFilter { get; set; }
public string ThisWeekFilter { get; set; }
public List<string> CustomFilters { get; set; }
}
public class ViewSettings
{
public bool ResetViewAfterClassification { get; set; }
public bool RefreshViewAfterChanges { get; set; }
public int ViewUpdateDelayMs { get; set; }
}
public class StreamingSettings
{
public int CharacterDelay { get; set; }
}
public class WindowSettings
{
public WindowSize MainWindow { get; set; }
public ProgressWindowSettings ProgressWindow { get; set; }
}
public class WindowSize
{
public int Width { get; set; }
public int Height { get; set; }
}
public class ProgressWindowSettings
{
public int Width { get; set; }
public int Height { get; set; }
public int MinHeight { get; set; }
public int HeightDivisor { get; set; }
public string FormBorderStyle { get; set; }
public string StartPosition { get; set; }
public bool MaximizeBox { get; set; }
public bool MinimizeBox { get; set; }
}
public class EmailSettings
{
public List<string> MessageSeparators { get; set; }
public List<string> SignaturePrefixes { get; set; }
public DefaultFolders DefaultFolders { get; set; }
public ContentLimits ContentLimits { get; set; }
public EmptyContentDefaults EmptyContentDefaults { get; set; }
}
public class DefaultFolders
{
public string Primary { get; set; }
public string Fallback { get; set; }
}
public class ContentLimits
{
public int MaxOriginalBodyPreview { get; set; }
public int MaxProcessedBodyPreview { get; set; }
public int MinimalContentLength { get; set; }
public int FallbackBodyLength { get; set; }
}
public class EmptyContentDefaults
{
public string NoSubject { get; set; }
public string NoSender { get; set; }
public string NoBody { get; set; }
}
public class LanguageSettings
{
public string DefaultTranslationLanguage { get; set; }
public List<string> RightToLeftLanguages { get; set; }
public string FallbackLanguage { get; set; }
}
public class ReplySettings
{
public List<string> NoReplyTriggers { get; set; }
}
public class Messages
{
public string Loading { get; set; }
public string Retry { get; set; }
public string Close { get; set; }
public string SendReply { get; set; }
public string GenerateAnyway { get; set; }
public string Complete { get; set; }
public string Error { get; set; }
public string ClickRetry { get; set; }
public string NoReplyNeeded { get; set; }
public string DefaultReplyText { get; set; }
public string ApiError { get; set; }
public string GeneratingReply { get; set; }
public string ErrorCreatingReply { get; set; }
public string NoEmailSelected { get; set; }
public string NoEmailSelectedTitle { get; set; }
public string EmptyEmailBody { get; set; }
public string EmptyEmailTitle { get; set; }
public string GeneratingSummary { get; set; }
public string ErrorGeneratingSummary { get; set; }
public string Translating { get; set; }
public string ErrorTranslating { get; set; }
public string AnalyzingEmail { get; set; }
public string ErrorAnalyzing { get; set; }
public string InitializationError { get; set; }
public string CheckConfigFile { get; set; }
public string ConfigurationError { get; set; }
public string MissingApiKey { get; set; }
}
public class Prompts
{
public string Summarize { get; set; }
public string Translate { get; set; }
public string Reply { get; set; }
public string ForceReply { get; set; }
}
public class ClassificationSettings
{
public string Prompt { get; set; }
public Dictionary<string, ClassificationConfig> Classifications { get; set; }
public RateLimitSettings RateLimiting { get; set; }
public PreProcessingRules PreProcessingRules { get; set; } = new PreProcessingRules();
public AiClassificationSettings AiClassification { get; set; } = new AiClassificationSettings();
public EmailProcessingSettings EmailProcessing { get; set; }
public ClassificationMessages Messages { get; set; }
public DebugSettings Debug { get; set; }
public RetrySettings Retry { get; set; }
public ContentSettings Content { get; set; }
public ApiResponseSettings ApiResponse { get; set; }
public ProgressSettings Progress { get; set; }
public NormalizationSettings Normalization { get; set; }
public SecurityProtocolSettings SecurityProtocol { get; set; }
}
public class ClassificationConfig
{
public string CategoryPrefix { get; set; }
public string Importance { get; set; }
public string FlagIcon { get; set; }
public string FlagRequest { get; set; }
public string SubjectPrefix { get; set; }
public string CategoryColor { get; set; }
}
public class RateLimitSettings
{
public int DefaultRequestTimeoutSeconds { get; set; } // Config-driven only
public int DefaultMinDelayBetweenRequestsMs { get; set; } // Config-driven only
public int MaxConsecutiveFailures { get; set; }
public int RequestsPerMinute { get; set; }
public int BaseCooldownSeconds { get; set; }
public int MaxCooldownMinutes { get; set; }
public int MinDelayBetweenRequestsMs { get; set; }
public int RequestTimeoutSeconds { get; set; }
}
public class PreProcessingRules
{
public bool EnableRuleBasedClassification { get; set; } = false;
public List<ClassificationRule> Rules { get; set; } = new List<ClassificationRule>();
}
public class ClassificationRule
{
public string Name { get; set; }
public string Classification { get; set; }
public int Priority { get; set; } = 100;
public RuleConditions Conditions { get; set; } = new RuleConditions();
}
public class RuleConditions
{
public string MatchType { get; set; } = "ANY";
public List<string> SubjectKeywords { get; set; } = new List<string>();
public List<string> SenderDomains { get; set; } = new List<string>();
public List<string> SenderAddresses { get; set; } = new List<string>();
public List<string> BodyKeywords { get; set; } = new List<string>();
}
public class AiClassificationSettings
{
public bool EnableAiClassification { get; set; } = true;
public bool UseAiForUnmatched { get; set; } = true;
public DynamicPrompts DynamicPrompts { get; set; } = new DynamicPrompts();
}
public class DynamicPrompts
{
public bool IncludeAvailableCategories { get; set; } = false;
public string PromptTemplate { get; set; }
public Dictionary<string, string> CategoryDescriptions { get; set; } = new Dictionary<string, string>();
}
public class EmailProcessingSettings
{
public int DefaultMaxBodyLength { get; set; } // Config-driven only
public List<string> ContentSeparators { get; set; }
public int MaxBodyLength { get; set; }
}
public class ClassificationMessages
{
public string NoUnreadEmails { get; set; }
public string ConfirmClassification { get; set; }
public string CompletionSummary { get; set; }
public string HowToSeeClassifications { get; set; }
public string ProcessingStatus { get; set; }
public string CooldownStatus { get; set; }
public string RetryStatus { get; set; }
public string WaitStatus { get; set; }
}
public class DebugSettings
{
public int DefaultContentPreviewLength { get; set; } // Config-driven only
public bool EnableLogging { get; set; }
public int ContentPreviewLength { get; set; }
public string TruncationIndicator { get; set; }
public string DefaultTruncationIndicator { get; set; } // Config-driven only
}
public class RetrySettings
{
public int MaxAttempts { get; set; }
public List<string> DefaultFallbackOrder { get; set; }
public BackoffMultipliers BackoffMultipliers { get; set; }
}
// NEW: Backoff multipliers
public class BackoffMultipliers
{
public int TimeoutRetryBase { get; set; }
public int ErrorRetryBase { get; set; }
public int ExponentialBase { get; set; }
public int ExtendedCooldownFactor { get; set; }
}
public class ContentSettings
{
public List<string> AiTagPatterns { get; set; }
public string FallbackContentTemplate { get; set; }
public List<string> ClassificationKeywords { get; set; }
public List<string> DefaultSeparators { get; set; }
public int EmptyContentFallbackLength { get; set; }
public string MinimalContentFromSubjectTemplate { get; set; }
}
public class ApiResponseSettings
{
public List<string> FallbackContentPaths { get; set; }
public List<string> NoContentIndicators { get; set; }
}
public class ProgressSettings
{
public string TimeFormatString { get; set; }
public string StatusTemplate { get; set; }
public string CooldownTemplate { get; set; }
public string PercentageTemplate { get; set; }
public int UpdateIntervalMs { get; set; }
public string ProgressBarStyle { get; set; }
}
public class NormalizationSettings
{
public Dictionary<string, string> ImportanceSynonyms { get; set; }
public Dictionary<string, string> FlagIconSynonyms { get; set; }
public Dictionary<string, string> CategoryColorSynonyms { get; set; }
public string DefaultImportance { get; set; } // Config-driven only
public string DefaultCategoryColor { get; set; } // Config-driven only
public string DefaultFlagIcon { get; set; } // Config-driven only
}
public class RibbonSettings
{
public RibbonButtonSettings Ribbon1 { get; set; }
public RibbonButtonSettings Ribbon2 { get; set; }
}
public class RibbonButtonSettings
{
public string Button1Text { get; set; }
public string Button1Tooltip { get; set; }
public string Button2Text { get; set; }
public string Button2Tooltip { get; set; }
public string Button3Text { get; set; }
public string Button3Tooltip { get; set; }
public string Button5Text { get; set; }
public string Button5Tooltip { get; set; }
public string Button4Text { get; set; }
public string Button4Tooltip { get; set; }
}
// NEW: Security protocol settings
public class SecurityProtocolSettings
{
public string PrimaryProtocol { get; set; }
public string FallbackProtocol { get; set; }
public bool TryTls13 { get; set; }
}
}