Initial project's source code check-in.
This commit is contained in:
commit
b03b0b373f
4573 changed files with 981205 additions and 0 deletions
|
@ -0,0 +1,21 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebsitePanel.Providers.Mail.SmarterMail3")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("WebsitePanel.Providers.Mail.SmarterMail3")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e201f24b-df21-46d7-bd80-ca8a8bd21656")]
|
|
@ -0,0 +1,675 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WebsitePanel.Providers.Mail.SM3;
|
||||
using Microsoft.Win32;
|
||||
using SM3 = WebsitePanel.Providers.Mail.SM3;
|
||||
|
||||
namespace WebsitePanel.Providers.Mail
|
||||
{
|
||||
public class SmarterMail3 : SmarterMail2
|
||||
{
|
||||
static string[] sm3Settings = new string[] {
|
||||
"description",
|
||||
"disabled",
|
||||
"moderator",
|
||||
"password",
|
||||
"requirepassword",
|
||||
"whocanpost",
|
||||
"prependsubject",
|
||||
"maxmessagesize",
|
||||
"maxrecipients",
|
||||
"replytolist"
|
||||
};
|
||||
|
||||
public SmarterMail3()
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreateAccount(MailAccount mailbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
svcUserAdmin users = new svcUserAdmin();
|
||||
PrepareProxy(users);
|
||||
|
||||
GenericResult1 result = users.AddUser(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
mailbox.Password,
|
||||
GetDomainName(mailbox.Name),
|
||||
mailbox.FirstName,
|
||||
mailbox.LastName,
|
||||
false //domain admin is false
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set forwarding settings
|
||||
result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
|
||||
mailbox.Name, mailbox.DeleteOnForward,
|
||||
(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set additional settings
|
||||
result = users.SetRequestedUserSettings(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
new string[]
|
||||
{
|
||||
"isenabled=" + mailbox.Enabled.ToString(),
|
||||
"maxsize=" + mailbox.MaxMailboxSize.ToString(),
|
||||
"passwordlocked=" + mailbox.PasswordLocked.ToString(),
|
||||
"replytoaddress=" + (mailbox.ReplyTo != null ? mailbox.ReplyTo : ""),
|
||||
"signature=" + (mailbox.Signature != null ? mailbox.Signature : ""),
|
||||
"spamforwardoption=none"
|
||||
});
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set autoresponder settings
|
||||
result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
mailbox.ResponderEnabled,
|
||||
(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
|
||||
(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Could not create mailbox", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateAccount(MailAccount mailbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
//get original account
|
||||
MailAccount account = GetAccount(mailbox.Name);
|
||||
|
||||
svcUserAdmin users = new svcUserAdmin();
|
||||
PrepareProxy(users);
|
||||
|
||||
|
||||
|
||||
string strPassword = mailbox.Password;
|
||||
|
||||
//Don't change password. Get it from mail server.
|
||||
if (!mailbox.ChangePassword)
|
||||
{
|
||||
strPassword = account.Password;
|
||||
}
|
||||
|
||||
GenericResult1 result = users.UpdateUser(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
strPassword,
|
||||
mailbox.FirstName,
|
||||
mailbox.LastName,
|
||||
account.IsDomainAdmin
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set forwarding settings
|
||||
result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
|
||||
mailbox.Name, mailbox.DeleteOnForward,
|
||||
(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set additional settings
|
||||
result = users.SetRequestedUserSettings(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
new string[]
|
||||
{
|
||||
"isenabled=" + mailbox.Enabled.ToString(),
|
||||
"maxsize=" + mailbox.MaxMailboxSize.ToString(),
|
||||
"passwordlocked=" + mailbox.PasswordLocked.ToString(),
|
||||
"replytoaddress=" + (mailbox.ReplyTo != null ? mailbox.ReplyTo : ""),
|
||||
"signature=" + (mailbox.Signature != null ? mailbox.Signature : ""),
|
||||
"spamforwardoption=none"
|
||||
});
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
// set autoresponder settings
|
||||
result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
|
||||
mailbox.Name,
|
||||
mailbox.ResponderEnabled,
|
||||
(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
|
||||
(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Could not update mailbox", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddDomainAlias(string domainName, string aliasName)
|
||||
{
|
||||
try
|
||||
{
|
||||
SM3.svcDomainAliasAdmin service = new SM3.svcDomainAliasAdmin();
|
||||
PrepareProxy(service);
|
||||
|
||||
SM3.GenericResult result = service.AddDomainAliasWithoutMxCheck(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domainName,
|
||||
aliasName
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't create domain alias.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DeleteDomainAlias(string domainName, string aliasName)
|
||||
{
|
||||
try
|
||||
{
|
||||
SM3.svcDomainAliasAdmin service = new SM3.svcDomainAliasAdmin();
|
||||
PrepareProxy(service);
|
||||
|
||||
SM3.GenericResult result = service.DeleteDomainAlias(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domainName,
|
||||
aliasName
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't delete domain alias.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ListExists(string listName)
|
||||
{
|
||||
bool exists = false;
|
||||
|
||||
try
|
||||
{
|
||||
string domain = GetDomainName(listName);
|
||||
string account = GetAccountName(listName);
|
||||
|
||||
SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(lists);
|
||||
|
||||
SM3.MailingListResult result = lists.GetMailingListsByDomain(AdminUsername, AdminPassword, domain);
|
||||
|
||||
if (result.Result)
|
||||
{
|
||||
foreach (string member in result.listNames)
|
||||
{
|
||||
if (string.Compare(member, listName, true) == 0)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't obtain mail list.", ex);
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
public override void CreateList(MailList list)
|
||||
{
|
||||
try
|
||||
{
|
||||
string domain = GetDomainName(list.Name);
|
||||
string account = GetAccountName(list.Name);
|
||||
|
||||
SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(lists);
|
||||
|
||||
SM3.GenericResult result = lists.AddList(AdminUsername, AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
list.ModeratorAddress,
|
||||
list.Description
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
List<string> settings = new List<string>();
|
||||
settings.Add(string.Concat("description=", list.Description));
|
||||
settings.Add(string.Concat("disabled=", !list.Enabled));
|
||||
settings.Add(string.Concat("moderator=", list.ModeratorAddress));
|
||||
settings.Add(string.Concat("password=", list.Password));
|
||||
settings.Add(string.Concat("requirepassword=", list.RequirePassword));
|
||||
|
||||
switch (list.PostingMode)
|
||||
{
|
||||
case PostingMode.AnyoneCanPost:
|
||||
settings.Add("whocanpost=anyone");
|
||||
break;
|
||||
case PostingMode.MembersCanPost:
|
||||
settings.Add("whocanpost=subscribersonly");
|
||||
break;
|
||||
case PostingMode.ModeratorCanPost:
|
||||
settings.Add("whocanpost=moderator");
|
||||
break;
|
||||
}
|
||||
|
||||
settings.Add(string.Concat("prependsubject=", list.EnableSubjectPrefix));
|
||||
settings.Add(string.Concat("maxmessagesize=", list.MaxMessageSize));
|
||||
settings.Add(string.Concat("maxrecipients=", list.MaxRecipientsPerMessage));
|
||||
|
||||
switch (list.ReplyToMode)
|
||||
{
|
||||
case ReplyTo.RepliesToList:
|
||||
settings.Add("replytolist=true");
|
||||
break;
|
||||
}
|
||||
|
||||
result = lists.SetRequestedListSettings(AdminUsername, AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
settings.ToArray()
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
if (list.Members.Length > 0)
|
||||
{
|
||||
result = lists.SetSubscriberList(AdminUsername, AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
list.Members
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't create mail list.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override MailList GetList(string listName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string domain = GetDomainName(listName);
|
||||
string account = GetAccountName(listName);
|
||||
|
||||
SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(svcLists);
|
||||
|
||||
SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
sm3Settings
|
||||
);
|
||||
|
||||
if (!sResult.Result)
|
||||
throw new Exception(sResult.Message);
|
||||
|
||||
SM3.SubscriberListResult mResult = svcLists.GetSubscriberList(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domain,
|
||||
account
|
||||
);
|
||||
|
||||
if (!mResult.Result)
|
||||
throw new Exception(mResult.Message);
|
||||
|
||||
MailList list = new MailList();
|
||||
list.Name = listName;
|
||||
|
||||
SetMailListSettings(list, sResult.settingValues);
|
||||
SetMailListMembers(list, mResult.Subscribers);
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't obtain mail list.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override MailList[] GetLists(string domainName)
|
||||
{
|
||||
try
|
||||
{
|
||||
SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(svcLists);
|
||||
|
||||
SM3.MailingListResult mResult = svcLists.GetMailingListsByDomain(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domainName
|
||||
);
|
||||
|
||||
if (!mResult.Result)
|
||||
throw new Exception(mResult.Message);
|
||||
|
||||
List<MailList> mailLists = new List<MailList>();
|
||||
foreach (string listName in mResult.listNames)
|
||||
{
|
||||
SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domainName,
|
||||
listName,
|
||||
sm3Settings
|
||||
);
|
||||
|
||||
if (!sResult.Result)
|
||||
throw new Exception(sResult.Message);
|
||||
|
||||
SM3.SubscriberListResult rResult = svcLists.GetSubscriberList(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domainName,
|
||||
listName
|
||||
);
|
||||
|
||||
if (!rResult.Result)
|
||||
throw new Exception(rResult.Message);
|
||||
|
||||
MailList list = new MailList();
|
||||
list.Name = string.Concat(listName, "@", domainName);
|
||||
SetMailListSettings(list, sResult.settingValues);
|
||||
SetMailListMembers(list, rResult.Subscribers);
|
||||
mailLists.Add(list);
|
||||
}
|
||||
|
||||
return mailLists.ToArray();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't obtain domain mail lists.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DeleteList(string listName)
|
||||
{
|
||||
try
|
||||
{
|
||||
SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(svcLists);
|
||||
|
||||
string account = GetAccountName(listName);
|
||||
string domain = GetDomainName(listName);
|
||||
|
||||
SM3.GenericResult gResult = svcLists.DeleteList(
|
||||
AdminUsername,
|
||||
AdminPassword,
|
||||
domain,
|
||||
listName
|
||||
);
|
||||
|
||||
if (!gResult.Result)
|
||||
throw new Exception(gResult.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't delete a mail list.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateList(MailList list)
|
||||
{
|
||||
try
|
||||
{
|
||||
string domain = GetDomainName(list.Name);
|
||||
string account = GetAccountName(list.Name);
|
||||
|
||||
SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
|
||||
PrepareProxy(lists);
|
||||
|
||||
List<string> settings = new List<string>();
|
||||
settings.Add(string.Concat("description=", list.Description));
|
||||
settings.Add(string.Concat("disabled=", !list.Enabled));
|
||||
settings.Add(string.Concat("moderator=", list.ModeratorAddress));
|
||||
settings.Add(string.Concat("password=", list.Password));
|
||||
settings.Add(string.Concat("requirepassword=", list.RequirePassword));
|
||||
|
||||
switch (list.PostingMode)
|
||||
{
|
||||
case PostingMode.AnyoneCanPost:
|
||||
settings.Add("whocanpost=anyone");
|
||||
break;
|
||||
case PostingMode.MembersCanPost:
|
||||
settings.Add("whocanpost=subscribersonly");
|
||||
break;
|
||||
case PostingMode.ModeratorCanPost:
|
||||
settings.Add("whocanpost=moderator");
|
||||
break;
|
||||
}
|
||||
|
||||
settings.Add(string.Concat("prependsubject=", list.EnableSubjectPrefix));
|
||||
settings.Add(string.Concat("maxmessagesize=", list.MaxMessageSize));
|
||||
settings.Add(string.Concat("maxrecipients=", list.MaxRecipientsPerMessage));
|
||||
|
||||
switch (list.ReplyToMode)
|
||||
{
|
||||
case ReplyTo.RepliesToList:
|
||||
settings.Add("replytolist=true");
|
||||
break;
|
||||
case ReplyTo.RepliesToSender:
|
||||
settings.Add("replytolist=false");
|
||||
break;
|
||||
}
|
||||
|
||||
SM3.GenericResult result = lists.SetRequestedListSettings(AdminUsername, AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
settings.ToArray()
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
|
||||
if (list.Members.Length > 0)
|
||||
{
|
||||
result = lists.SetSubscriberList(AdminUsername, AdminPassword,
|
||||
domain,
|
||||
account,
|
||||
list.Members
|
||||
);
|
||||
|
||||
if (!result.Result)
|
||||
throw new Exception(result.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Couldn't update mail list.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetMailListSettings(MailList list, string[] smSettings)
|
||||
{
|
||||
foreach (string setting in smSettings)
|
||||
{
|
||||
string[] bunch = setting.Split(new char[] { '=' });
|
||||
|
||||
switch (bunch[0])
|
||||
{
|
||||
case "description":
|
||||
list.Description = bunch[1];
|
||||
break;
|
||||
case "disabled":
|
||||
list.Enabled = !Convert.ToBoolean(bunch[1]);
|
||||
break;
|
||||
case "moderator":
|
||||
list.ModeratorAddress = bunch[1];
|
||||
list.Moderated = !string.IsNullOrEmpty(bunch[1]);
|
||||
break;
|
||||
case "password":
|
||||
list.Password = bunch[1];
|
||||
break;
|
||||
case "requirepassword":
|
||||
list.RequirePassword = Convert.ToBoolean(bunch[1]);
|
||||
break;
|
||||
case "whocanpost":
|
||||
if (string.Compare(bunch[1], "anyone", true) == 0)
|
||||
list.PostingMode = PostingMode.AnyoneCanPost;
|
||||
else if (string.Compare(bunch[1], "moderatoronly", true) == 0)
|
||||
list.PostingMode = PostingMode.ModeratorCanPost;
|
||||
else
|
||||
list.PostingMode = PostingMode.MembersCanPost;
|
||||
break;
|
||||
case "prependsubject":
|
||||
list.EnableSubjectPrefix = Convert.ToBoolean(bunch[1]);
|
||||
break;
|
||||
case "maxmessagesize":
|
||||
list.MaxMessageSize = Convert.ToInt32(bunch[1]);
|
||||
break;
|
||||
case "maxrecipients":
|
||||
list.MaxRecipientsPerMessage = Convert.ToInt32(bunch[1]);
|
||||
break;
|
||||
case "replytolist":
|
||||
if (string.Compare(bunch[1], "true", true) == 0)
|
||||
list.ReplyToMode = string.Compare(bunch[1], "true", true) == 0 ? ReplyTo.RepliesToList : ReplyTo.RepliesToSender;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetMailListMembers(MailList list, string[] subscribers)
|
||||
{
|
||||
List<string> members = new List<string>();
|
||||
|
||||
foreach (string subscriber in subscribers)
|
||||
members.Add(subscriber);
|
||||
|
||||
list.Members = members.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public override bool IsInstalled()
|
||||
{
|
||||
string productName = null;
|
||||
string productVersion = null;
|
||||
|
||||
RegistryKey HKLM = Registry.LocalMachine;
|
||||
|
||||
RegistryKey key = HKLM.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
|
||||
String[] names = null;
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
names = key.GetSubKeyNames();
|
||||
|
||||
foreach (string s in names)
|
||||
{
|
||||
RegistryKey subkey = HKLM.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + s);
|
||||
if (subkey != null)
|
||||
if (!String.IsNullOrEmpty((string)subkey.GetValue("DisplayName")))
|
||||
{
|
||||
productName = (string)subkey.GetValue("DisplayName");
|
||||
}
|
||||
if (productName != null)
|
||||
if (productName.Equals("SmarterMail"))
|
||||
{
|
||||
if (subkey != null) productVersion = (string)subkey.GetValue("DisplayVersion");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(productVersion))
|
||||
{
|
||||
string[] split = productVersion.Split(new char[] { '.' });
|
||||
return split[0].Equals("3") | split[0].Equals("4");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key = HKLM.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
|
||||
|
||||
if (key == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
names = key.GetSubKeyNames();
|
||||
|
||||
foreach (string s in names)
|
||||
{
|
||||
RegistryKey subkey = HKLM.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" + s);
|
||||
if (subkey != null)
|
||||
if (!String.IsNullOrEmpty((string)subkey.GetValue("DisplayName")))
|
||||
{
|
||||
productName = (string)subkey.GetValue("DisplayName");
|
||||
}
|
||||
if (productName != null)
|
||||
if (productName.Equals("SmarterMail"))
|
||||
{
|
||||
if (subkey != null) productVersion = (string)subkey.GetValue("DisplayVersion");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(productVersion))
|
||||
{
|
||||
string[] split = productVersion.Split(new[] { '.' });
|
||||
return split[0].Equals("3") | split[0].Equals("4");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B8965821-B64E-4A1B-9B72-E089B3D58861}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WebsitePanel.Providers.Mail</RootNamespace>
|
||||
<AssemblyName>WebsitePanel.Providers.Mail.SmarterMail3</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\VersionInfo.cs">
|
||||
<Link>VersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SmarterMail3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.Base\WebsitePanel.Providers.Base.csproj">
|
||||
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
|
||||
<Name>WebsitePanel.Providers.Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.Mail.SmarterMail2\WebsitePanel.Providers.Mail.SmarterMail2.csproj">
|
||||
<Project>{3B31793D-7CA6-40C1-BC3B-EE85F414C626}</Project>
|
||||
<Name>WebsitePanel.Providers.Mail.SmarterMail2</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue