-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Virkus
committed
Jun 16, 2020
1 parent
0573cff
commit 390b24e
Showing
19 changed files
with
858 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:enough_mail/discover/client_config.dart'; | ||
import 'package:enough_mail/enough_mail.dart'; | ||
|
||
import 'mail_authentication.dart'; | ||
|
||
class MailServerConfig { | ||
ServerConfig serverConfig; | ||
MailAuthentication authentication; | ||
List<Capability> serverCapabilities; | ||
|
||
String pathSeparator; | ||
|
||
bool supports(String capabilityName) { | ||
return (serverCapabilities.firstWhere((c) => c.name == capabilityName, | ||
orElse: () => null) != | ||
null); | ||
} | ||
} | ||
|
||
class MailAccount { | ||
String name; | ||
String email; | ||
MailServerConfig incoming; | ||
MailServerConfig outgoing; | ||
String outgoingClientDomain = 'enough.de'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:enough_mail/discover/client_config.dart'; | ||
import 'package:enough_mail/imap/imap_client.dart'; | ||
import 'package:enough_mail/pop/pop_client.dart'; | ||
import 'package:enough_mail/smtp/smtp_client.dart'; | ||
|
||
import 'mail_response.dart'; | ||
|
||
abstract class MailAuthentication { | ||
Future<MailResponse> authenticate(ServerConfig serverConfig, | ||
{ImapClient imap, PopClient pop, SmtpClient smtp}); | ||
} | ||
|
||
class PlainAuthentication extends MailAuthentication { | ||
String userName; | ||
String password; | ||
PlainAuthentication(this.userName, this.password); | ||
|
||
@override | ||
Future<MailResponse> authenticate(ServerConfig serverConfig, | ||
{ImapClient imap, PopClient pop, SmtpClient smtp}) async { | ||
switch (serverConfig.type) { | ||
case ServerType.imap: | ||
var imapResponse = await imap.login(userName, password); | ||
return MailResponseHelper.createFromImap(imapResponse); | ||
break; | ||
case ServerType.pop: | ||
var popResponse = await pop.login(userName, password); | ||
return MailResponseHelper.createFromPop(popResponse); | ||
break; | ||
case ServerType.smtp: | ||
break; | ||
default: | ||
throw StateError('Unknown server type ${serverConfig.typeName}'); | ||
} | ||
} | ||
} |
Oops, something went wrong.