diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs index abb99a6d..bd8e5dc9 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs @@ -492,5 +492,1281 @@ namespace CampusAppWP8.Utility } } } + + public class Description : Comment // because the structure is the same + { + // 3.8.1.5 + public const string Name = ICSTag.DESCRIPTION; + + public Description() : base() + { + } + } + + public class Geo : Interface + { + // 3.8.1.6 + public const string Name = ICSTag.GEO; + + private Tuple value = null; + + public Geo() + { + } + + public void Set(string valueStr, string paramStr) + { + if ((paramStr == null) || (paramStr.Equals(string.Empty))) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.GEO + ")"); + } + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.GEO + ")"); + } + + string[] valSplit = valueStr.Split(';'); + + if (valSplit.Count() != 2) + { + throw new FormatException("there are not 2 float values, seperated by ';', in the value string"); + } + + this.value = new Tuple(float.Parse(valSplit[0]), float.Parse(valSplit[1])); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += ICSTag.GEO; + + if (this.value == null) + { + throw new NotSupportedException("there is no value set for (" + ICSTag.GEO + ")"); + } + + retValue += ":" + this.value.Item1.ToString() + ";" + this.value.Item2.ToString(); + + return retValue; + } + + public Tuple Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + } + + public class Location : Comment // because the structure is the same + { + // 3.8.1.7. + public const string Name = ICSTag.LOCATION; + + public Location() : base() + { + } + } + + public class PercentComplete : Interface + { + // 3.8.1.8 + public const string Name = ICSTag.PERCENT; + + private int value = -1; + + public PercentComplete() + { + } + + public void Set(string valueStr, string paramStr) + { + if ((paramStr == null) || (paramStr.Equals(string.Empty))) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.PERCENT + ")"); + } + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.PERCENT + ")"); + } + + this.value = int.Parse(valueStr); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += ICSTag.PERCENT; + + if (this.value < 0) + { + throw new NotSupportedException("there is no value set for (" + ICSTag.PERCENT + ")"); + } + + retValue += ":" + this.value.ToString(); + + return retValue; + } + + public int Value + { + get + { + return this.value; + } + set + { + if ((value >= 0) && (value <= 100)) + { + this.value = value; + } + else + { + throw new ArgumentOutOfRangeException("value must be in rang of [0..100] in (" + ICSTag.PERCENT + ")"); + } + } + } + } + + public class Priority : Interface + { + // 3.8.1.9. + public const string Name = ICSTag.PRIORITY; + + private int value = -1; + + public Priority() + { + } + + public void Set(string valueStr, string paramStr) + { + if ((paramStr == null) || (paramStr.Equals(string.Empty))) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.PRIORITY + ")"); + } + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.PRIORITY + ")"); + } + + this.value = int.Parse(valueStr); + + if ((this.value < 0) || (this.value > 9)) + { + throw new ArgumentOutOfRangeException("value must be in the range of [0..9] in (" + ICSTag.PRIORITY + ")"); + } + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += ICSTag.PERCENT; + + if (this.value < 0 || this.value > 9) + { + throw new NotSupportedException("there is no value set for (" + ICSTag.PRIORITY + ")"); + } + + retValue += ":" + this.value.ToString(); + + return retValue; + } + + public int Value + { + get + { + return this.value; + } + set + { + if (value >= 0 && value <= 9) + { + this.value = value; + } + else + { + throw new ArgumentOutOfRangeException("value must be in rage of [0..9] in (" + ICSTag.PRIORITY + ")"); + } + } + } + } + + public class Resources : Comment // because the structure is the same + { + // 3.8.1.10. + public const string Name = ICSTag.RESOURCES; + + public Resources() : base() + { + } + } + + public class Status : Interface + { + // 3.8.1.11. + public const string Name = ICSTag.STATUS; + + public readonly List ValueListEvent = null; + public readonly List ValueListToDo = null; + public readonly List ValueListJournal = null; + + private string value = string.Empty; + + public Status() + { + this.ValueListEvent = new List(); + this.ValueListEvent.AddRange(new string[] { + ICSValue.TENTATIVE, + ICSValue.CONFIRMED, + ICSValue.CANCELLED + }); + + this.ValueListToDo = new List(); + this.ValueListToDo.AddRange(new string[] { + ICSValue.NEEDS_ACTION, + ICSValue.COMPLETED, + ICSValue.IN_PROCESS, + ICSValue.CANCELLED + }); + + this.ValueListJournal = new List(); + this.ValueListJournal.AddRange(new string[] { + ICSValue.DRAFT, + ICSValue.FINAL, + ICSValue.CANCELLED + }); + } + + public void Set(string valueStr, string paramStr) + { + if ((paramStr == null) || (paramStr.Equals(string.Empty))) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.STATUS + ")"); + } + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + ICSTag.PRIORITY + ")"); + } + + if ((this.ValueListEvent.IndexOf(valueStr) < 0) + && (this.ValueListToDo.IndexOf(valueStr) < 0) + && (this.ValueListJournal.IndexOf(valueStr) < 0)) + { + throw new NotSupportedException("value (" + valueStr + ") is not supported in (" + ICSTag.STATUS + ")"); + } + + this.value = valueStr; + } + + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += ICSTag.STATUS + ":" + this.value; + + return retValue; + } + + public string Value + { + get + { + return this.value; + } + set + { + if ((this.ValueListEvent.IndexOf(value) >= 0) + || (this.ValueListToDo.IndexOf(value) >= 0) + || (this.ValueListJournal.IndexOf(value) >= 0)) + { + this.value = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported in (" + ICSTag.STATUS + ")"); + } + } + } + } + + public class Summary : Comment // because the structure is the same + { + // 3.8.1.12. + public const string Name = ICSTag.SUMMARY; + + public Summary() + : base() + { + } + } + + public class DTCompleted : Interface + { + // 3.8.2.1. + public readonly string Name = ICSTag.COMPLETED; + + private DateTime value = DateTime.MinValue; + + public DTCompleted() + { + } + + public void Set(string valueStr, string paramStr) + { + if ((paramStr == null) || (paramStr.Equals(string.Empty))) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + this.Name + ")"); + } + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + this.Name + ")"); + } + + this.value = UTCStringToDateTime(valueStr); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name + ":" + string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.value.ToUniversalTime()); + + return retValue; + } + + public DateTime Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + } + + public class DTEnd : Interface + { + // 3.8.2.2. + public readonly string Name = ICSTag.DT_END; + + public readonly List ParamList = null; + public readonly List ParamValueList = null; + + private DateTime value = DateTime.MinValue; + private string timeZone = string.Empty; + private bool isDate = false; + + public DTEnd() + { + this.ParamList = new List(); + this.ParamList.AddRange(new string[] { + ICSParam.NONE, + ICSParam.VALUE_TYPE, + ICSParam.TIME_ZONE_ID + }); + + this.ParamValueList = new List(); + this.ParamValueList.AddRange(new string[] { + ICSParamValue.DATE_TIME, + ICSParamValue.DATE + }); + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr, paramStr.Split(';')); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + if (paramStrList.Count() > 2) + { + throw new NotSupportedException("too many params in (" + this.Name + ")"); + } + + for(int i = 0; i < paramStrList.Count(); i++) + { + string[] p = paramStrList[i].Split('='); + + if (p.Count() != 2) + { + throw new NotSupportedException("incorrect param string (" + paramStrList[0] + ")"); + } + + if (p[0].Equals(ICSParam.VALUE_TYPE)) + { + if (p[1].Equals(ICSParamValue.DATE)) + { + this.isDate = true; + } + else if (p[1].Equals(ICSParamValue.DATE_TIME)) + { + this.isDate = false; + } + else + { + throw new NotSupportedException("param value (" + p[1] + ") is not supported in (" + this.Name + ")"); + } + } + else if(p[0].Equals(ICSParam.TIME_ZONE_ID)) + { + this.timeZone = p[1]; + } + else + { + throw new NotSupportedException("param (" + p[0] + ") is not supported in (" + this.Name + ")"); + } + } + } + + bool tempIsDate = IsDate(valueStr); + + if (this.isDate != tempIsDate) + { + throw new NotSupportedException("time value has not the same type as declared in param in(" + this.Name + ")"); + } + + this.value = UTCStringToDateTime(valueStr); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name; + + if(!this.timeZone.Equals(string.Empty)) + { + retValue += ";" + this.timeZone; + } + + if (this.isDate) + { + retValue += ";" + ICSParam.VALUE_TYPE + "=" + ICSParamValue.DATE; + } + + retValue += ":"; + + if (this.isDate) + { + retValue += string.Format("{0:yyyyMMdd}", this.value.ToUniversalTime()); + } + else + { + retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.value.ToUniversalTime()); + } + + return retValue; + } + + public DateTime Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + + public bool IsDate + { + get + { + return this.isDate; + } + set + { + this.isDate = value; + } + } + + public string TimeZone + { + get + { + return this.timeZone; + } + set + { + this.timeZone = value; + } + } + } + + public class DTDue : DTEnd // because the structure is the same + { + // 3.8.2.3. + public readonly string Name = ICSTag.DUE; + + public DTDue() + : base() + { + } + } + + public class DTStart : DTEnd // because the structure is the same + { + // 3.8.2.4. + public readonly string Name = ICSTag.DT_START; + + public DTStart() + : base() + { + } + } + + public class Duration : Interface + { + // 3.8.2.5. + public readonly string Name = ICSTag.DURATION; + + private TimeSpan value = TimeSpan.Zero; + private bool isNegative = false; + + public Duration() + { + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + this.Name + ")"); + } + + this.value = StringToTimeSpan(valueStr); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name + ":" + TimeSpanToString(this.value, this.isNegative); + + return retValue; + } + + public TimeSpan Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + + public bool IsNegative + { + get + { + return this.isNegative; + } + set + { + this.isNegative = value; + } + } + } + + public class FreeBusyTime : Interface + { + // 3.8.2.6. + public readonly string Name = ICSTag.FREEBUSY; + public readonly List ParamList = null; + public readonly List ParamValueList = null; + + private string freebusyType = string.Empty; + private List> valueList = null; + + public FreeBusyTime() + { + this.valueList = new List>(); + + this.ParamList = new List(); + this.ParamList.AddRange(new string[] { + ICSParam.NONE, + ICSParam.FREE_BUSY_TIME_TYPE + }); + + this.ParamValueList = new List(); + this.ParamValueList.AddRange(new string[] { + ICSParamValue.FREE, + ICSParamValue.BUSY, + ICSParamValue.BUSY_UNAVAILABLE, + ICSParamValue.BUSY_TENTATIVE + }); + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr, paramStr.Split(';')); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param in (" + this.Name + ") supported"); + } + + string[] pSplit = paramStrList[0].Split('='); + + if (pSplit.Count() != 2) + { + throw new FormatException("parameter string (" + paramStrList[0] + ") is wrong"); + } + + if (pSplit[0].Equals(ICSParam.FREE_BUSY_TIME_TYPE)) + { + if (this.ParamValueList.IndexOf(pSplit[1]) < 0) + { + throw new NotSupportedException("unsupported param value (" + pSplit[1] + ")"); + } + else + { + this.freebusyType = pSplit[1]; + } + } + else + { + throw new NotSupportedException("unsupported param (" + pSplit[0] + ")"); + } + } + + string[] valSplit = valueStr.Split(','); + + for (int i = 0; i < valueStr.Count(); i++) + { + string[] subSplit = valSplit[i].Split('/'); + + if (subSplit.Count() != 2) + { + throw new FormatException("value has a unsupported format (" + valSplit[i] + ")"); + } + + DateTime partDTStart = UTCStringToDateTime(subSplit[0]); + TimeSpan partTSDur = TimeSpan.Zero; + DateTime partDTEnd = DateTime.MinValue; + + if ((subSplit[1][subSplit[1].Length - 1].Equals('Z')) + || (subSplit[1][subSplit[1].Length - 1] >= '0' && subSplit[1][subSplit[1].Length - 1] <= '9')) + { + partDTEnd = UTCStringToDateTime(subSplit[1]); + } + else + { + partTSDur = StringToTimeSpan(subSplit[1]); + } + + this.valueList.Add(new Tuple(partDTStart, partTSDur, partDTEnd)); + } + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name; + + if (!this.freebusyType.Equals(string.Empty)) + { + retValue += ICSParam.FREE_BUSY_TIME_TYPE + "=" + this.freebusyType; + } + + retValue += ":"; + + for (int i = 0; i < this.valueList.Count(); i++) + { + if(i > 0) + { + retValue += ","; + } + + retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.valueList[i].Item1.ToUniversalTime()) + "/"; + + if (this.valueList[i].Item2.Equals(TimeSpan.Zero)) + { + retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.valueList[i].Item3.ToUniversalTime()); + } + else + { + retValue += TimeSpanToString(this.valueList[i].Item2); + } + } + + return retValue; + } + + public List> ValueList + { + get + { + return this.valueList; + } + set + { + this.valueList = value; + } + } + + public string FreeBusyType + { + get + { + return this.freebusyType; + } + set + { + if (this.ParamValueList.IndexOf(value) < 0) + { + throw new NotSupportedException("param value (" + value + ") is not supported"); + } + else + { + this.freebusyType = value; + } + } + } + + public void AddValue(DateTime dtStart, TimeSpan tsDur) + { + this.valueList.Add(new Tuple(dtStart, tsDur, DateTime.MinValue)); + } + + public void AddValue(DateTime dtStart, DateTime dtEnd) + { + this.ValueList.Add(new Tuple(dtStart, TimeSpan.Zero, dtEnd)); + } + } + + public class TimeTransparency : Interface + { + // 3.8.2.7. + public readonly string Name = ICSTag.TRANSP; + public readonly List ValueList = null; + + private string value = ICSValue.OPAQUE; + + public TimeTransparency() + { + this.ValueList = new List(); + this.ValueList.AddRange(new string[] { + ICSValue.OPAQUE, + ICSValue.TRANSPARENT + }); + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + this.Name + ")"); + } + + if (this.ValueList.IndexOf(valueStr) < 0) + { + throw new NotSupportedException("value (" + valueStr + ") is not supported"); + } + + this.value = valueStr; + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name + ":" + this.value; + + return retValue; + } + + public string Value + { + get + { + return this.value; + } + set + { + if (this.ValueList.IndexOf(value) < 0) + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + else + { + this.value = value; + } + } + } + } + + public class TimeZoneIdentifier : Interface + { + // 3.8.3.1. + public readonly string Name = ICSTag.TIME_ZONE_ID; + + private string value = string.Empty; + + public TimeZoneIdentifier() + { + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + this.Name + ")"); + } + + this.value = valueStr; + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name + ":" + this.value; + + return retValue; + } + + public string Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + } + + public class TimeZoneName : Interface + { + // 3.8.3.2. + public readonly string Name = ICSTag.TIME_ZONE_NAME; + public readonly List ParamList = null; + + private string language = string.Empty; + private string value = string.Empty; + + public TimeZoneName() + { + this.ParamList = new List(); + this.ParamList.AddRange(new string[] { + ICSParam.NONE, + ICSParam.LANGUAGE + }); + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr, paramStr.Split(';')); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("ther is only 1 param supported in (" + this.Name + ")"); + } + + if (paramStrList.Count() == 1) + { + string[] pSplit = paramStrList[0].Split('='); + + if (pSplit.Count() != 2) + { + throw new FormatException("unsupported format in param (" + paramStrList[0] + ")"); + } + + if (pSplit[0].Equals(ICSParam.LANGUAGE)) + { + this.language = pSplit[1]; + } + else + { + throw new NotSupportedException("unsupported param (" + pSplit[0] + ")"); + } + } + } + + this.value = valueStr; + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name; + + if (!this.language.Equals(string.Empty)) + { + retValue += ";" + ICSParam.LANGUAGE + "=" + this.language; + } + + retValue += ":" + this.value; + + return retValue; + } + + public string Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + + public string Language + { + get + { + return this.language; + } + set + { + this.language = value; + } + } + } + + public class TimeZoneOffsetFrom : Interface + { + // 3.8.3.3. + public readonly string Name = ICSTag.TIME_ZONE_OFFSET_FROM; + + private bool isNegative = false; + private TimeSpan value = TimeSpan.Zero; + + public TimeZoneOffsetFrom() + { + } + + public void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + public void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("no param supported in (" + this.Name + ")"); + } + + if(valueStr[0].Equals('+')) + { + this.isNegative = false; + } + else if(valueStr[0].Equals('-')) + { + this.isNegative = true; + } + else + { + throw new NotImplementedException("unhandled starting char (" + valueStr + ")"); + } + + this.value = new TimeSpan(int.Parse(valueStr.Substring(1, 2)), int.Parse(valueStr.Substring(3, 2)), ((valueStr.Length > 5) ? int.Parse(valueStr.Substring(5, 2)) : 0)); + } + + public byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + public string GetString() + { + string retValue = string.Empty; + + retValue += this.Name + ":" + ((this.isNegative) ? "-" : "+") + string.Format("{0:HHmm}", this.value); + + return retValue; + } + + public TimeSpan Value + { + get + { + return this.value; + } + set + { + this.value = value; + } + } + + public bool IsNegative + { + get + { + return this.isNegative; + } + set + { + this.isNegative = value; + } + } + } + + // functions + private static DateTime UTCStringToDateTime(string timeStr) + { + // see http://tools.ietf.org/html/rfc5545 3.3.5. + + timeStr = timeStr.Insert(4, "-"); + timeStr = timeStr.Insert(7, "-"); + + if (!IsDate(timeStr)) + { + timeStr = timeStr.Insert(13, ":"); + timeStr = timeStr.Insert(16, ":"); + } + + return DateTime.Parse(timeStr); + } + + private static bool IsDate(string timeStr) + { + if (timeStr[timeStr.Length - 1].Equals('Z')) + return false; + else + return true; + } + + private static TimeSpan StringToTimeSpan(string timeStr) + { + TimeSpan retValue = TimeSpan.Zero; + + Tuple[] valList = DurSplit(timeStr); + + int days = 0; + int hours = 0; + int mins = 0; + int secs = 0; + + for (int i = 0; i < valList.Count(); i++) + { + switch (valList[i].Item2) + { + case 'D': + days = valList[i].Item1; + break; + case 'W': + days = valList[i].Item1 * 7; + break; + case 'H': + hours = valList[i].Item1; + break; + case 'M': + mins = valList[i].Item1; + break; + case 'S': + secs = valList[i].Item1; + break; + + default: + throw new NotSupportedException("duration tag (" + valList[i].Item2 + ") not supported"); + } + } + + retValue = new TimeSpan(days, hours, mins, secs); + + return retValue; + } + + private static Tuple[] DurSplit(string durStr) + { + List> retValue = new List>(); + + string str = durStr.Replace("P", "").Replace("T", "").Replace("+", "").Replace("-", ""); + + int val = 0; + char typeChar; + + for (int i = 0; i < durStr.Length; i++) + { + if (durStr[i] >= '0' && durStr[i] <= '9') + { + val *= 10; + val += (durStr[0] - '0'); + } + else + { + typeChar = durStr[i]; + retValue.Add(new Tuple(val, typeChar)); + val = 0; + } + } + + return retValue.ToArray(); + } + + private static string TimeSpanToString(TimeSpan timeSpan, bool isNegative = false) + { + string retValue = string.Empty; + + if (isNegative) + { + retValue += "-"; + } + + retValue += "P"; + + if (timeSpan.Days > 0) + { + retValue += timeSpan.Days.ToString() + "D"; + } + + if ((timeSpan.Hours > 0) || (timeSpan.Minutes > 0) || (timeSpan.Seconds > 0)) + { + retValue += "T" + timeSpan.Hours.ToString() + "H" + timeSpan.Minutes.ToString() + "M" + timeSpan.Seconds.ToString() + "S"; + } + + return retValue; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs index 55c98d63..d4e56490 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs @@ -242,7 +242,7 @@ namespace CampusAppWP8.Utility new ICSElemDesc(ICSTag.PRIORITY, null, null), new ICSElemDesc(ICSTag.SEQ, null, null), new ICSElemDesc(ICSTag.STATUS, null, null), - new ICSElemDesc(ICSTag.TITLE, null, null), + new ICSElemDesc(ICSTag.SUMMARY, null, null), new ICSElemDesc(ICSTag.TRANSP, null, null), new ICSElemDesc(ICSTag.URL, null, null), new ICSElemDesc(ICSTag.RECURRENCE_ID, null, null), @@ -271,7 +271,7 @@ namespace CampusAppWP8.Utility new ICSElemDesc(ICSTag.REPEAT, null, null), // audio, display, email new ICSElemDesc(ICSTag.ATTACHMENT, null, null), // audio, email new ICSElemDesc(ICSTag.DESCRIPTION, null, null),// display, eamil - new ICSElemDesc(ICSTag.TITLE, null, null), // email + new ICSElemDesc(ICSTag.SUMMARY, null, null), // email new ICSElemDesc(ICSTag.ATTENDEE, null, null), // email new ICSElemDesc(ICSTag.END, null, new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSTag.VALARM, null) @@ -299,7 +299,7 @@ namespace CampusAppWP8.Utility new ICSElemDesc(ICSTag.RECURRENCE_ID, null, null), new ICSElemDesc(ICSTag.SEQ, null, null), new ICSElemDesc(ICSTag.STATUS, null, null), - new ICSElemDesc(ICSTag.TITLE, null, null), + new ICSElemDesc(ICSTag.SUMMARY, null, null), new ICSElemDesc(ICSTag.URL, null, null), new ICSElemDesc(ICSTag.RRULE, null, null), new ICSElemDesc(ICSTag.DUE, null, null), @@ -326,7 +326,7 @@ namespace CampusAppWP8.Utility new ICSElemDesc(ICSTag.REPEAT, null, null), // audio, display, email new ICSElemDesc(ICSTag.ATTACHMENT, null, null), // audio, email new ICSElemDesc(ICSTag.DESCRIPTION, null, null),// display, eamil - new ICSElemDesc(ICSTag.TITLE, null, null), // email + new ICSElemDesc(ICSTag.SUMMARY, null, null), // email new ICSElemDesc(ICSTag.ATTENDEE, null, null), // email new ICSElemDesc(ICSTag.END, null, new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSTag.VALARM, null) @@ -348,7 +348,7 @@ namespace CampusAppWP8.Utility new ICSElemDesc(ICSTag.RECURRENCE_ID, null, null), new ICSElemDesc(ICSTag.SEQ, null, null), new ICSElemDesc(ICSTag.STATUS, null, null), - new ICSElemDesc(ICSTag.TITLE, null, null), + new ICSElemDesc(ICSTag.SUMMARY, null, null), new ICSElemDesc(ICSTag.URL, null, null), new ICSElemDesc(ICSTag.RRULE, null, null), new ICSElemDesc(ICSTag.ATTACHMENT, null, null), @@ -457,7 +457,7 @@ namespace CampusAppWP8.Utility public const string PRIORITY = "PRIORITY"; public const string SEQ = "SEQ"; public const string STATUS = "STATUS"; - public const string TITLE = "SUMMARY"; + public const string SUMMARY = "SUMMARY"; public const string TRANSP = "TRANSP"; public const string URL = "URL"; public const string RECURRENCE_ID = "RECURID"; // "RECURRENCE-ID"; ??? @@ -480,7 +480,7 @@ namespace CampusAppWP8.Utility // To-Do Component public const string VTODO = "VTODO"; public const string COMPLETED = "COMPLETED"; - public const string PERCENT = "PERCENT"; + public const string PERCENT = "PERCENT-COMPLETE"; public const string DUE = "DUE"; // Journal Component public const string VJOURNAL = "VJOURNAL"; @@ -596,6 +596,23 @@ namespace CampusAppWP8.Utility public const string PUBLIC = "PUBLIC"; public const string PRIVATE = "PRIVATE"; public const string CONFIDENTIAL = "CONFIDENTIAL"; + // STATUS + // (in vevent) + public const string TENTATIVE = "TENTATIVE"; + public const string CONFIRMED = "CONFIRMED"; + public const string CANCELLED = "CANCELLED"; + // (in vtodo) + public const string NEEDS_ACTION = "NEEDS-ACTION"; + public const string COMPLETED = "COMPLETED"; + public const string IN_PROCESS = "IN-PROCESS"; + // public const string CANCELLED = "CANCELLED"; + // (in vjournal) + public const string DRAFT = "DRAFT"; + public const string FINAL = "FINAL"; + // public const string CANCELLED = "CANCELLED"; + // TRANSP + public const string OPAQUE = "OPAQUE"; + public const string TRANSPARENT = "TRANSPARENT"; } public class ICSParamValue