示例#1
0
        void Populate(VCard vcard)
        {
            string template = null;

            if (vcard == null)
            {
                template = "Unable to view profile.";
            }
            else
            {
                template = Util.ReadResource("profile.html");

                // FIXME: This is just a quick hack. Really need to do all the replacement at once.
                template = template.Replace("@@NAME@@", vcard.FullName);
                template = template.Replace("@@JID@@", vcard.JabberId);
                template = template.Replace("@@NICKNAME@@", vcard.Nickname);

                try {
                    template = template.Replace("@@BIRTHDAY@@", vcard.Birthday.ToString());
                } catch {
                    template = template.Replace("@@BIRTHDAY@@", String.Empty);
                }

                var email = vcard.GetEmail(EmailType.home);
                if (email != null)
                {
                    template = template.Replace("@@EMAIL@@", email.UserId);
                }
                else
                {
                    template = template.Replace("@@EMAIL@@", String.Empty);
                }

                if (vcard.Url != null)
                {
                    template = template.Replace("@@WEBSITE@@", vcard.Url.ToString());
                }
                else
                {
                    template = template.Replace("@@WEBSITE@@", String.Empty);
                }

                template = template.Replace("@@ADDRESS@@", FormatAddress(vcard.GetAddress(AddressLocation.home)));

                var phone = vcard.GetTelephone(TelephoneType.voice, TelephoneLocation.home);
                if (phone != null)
                {
                    template = template.Replace("@@PHONE@@", phone.Number);
                }
                else
                {
                    template = template.Replace("@@PHONE@@", String.Empty);
                }

                template = template.Replace("@@ABOUT@@", vcard.Description);

                var org = vcard.Organization;
                if (org != null)
                {
                    template = template.Replace("@@COMPANY@@", org.OrgName);
                    template = template.Replace("@@DEPARTMENT@@", vcard.Organization.Unit);
                }
                else
                {
                    template = template.Replace("@@COMPANY@@", String.Empty);
                    template = template.Replace("@@DEPARTMENT@@", String.Empty);
                }

                template = template.Replace("@@POSITION@@", vcard.Title);
                template = template.Replace("@@ROLE@@", vcard.Role);

                email = vcard.GetEmail(EmailType.work);
                if (email != null)
                {
                    template = template.Replace("@@WORK_EMAIL@@", email.UserId);
                }
                else
                {
                    template = template.Replace("@@WORK_EMAIL@@", String.Empty);
                }

                template = template.Replace("@@WORK_ADDRESS@@", FormatAddress(vcard.GetAddress(AddressLocation.work)));

                phone = vcard.GetTelephone(TelephoneType.voice, TelephoneLocation.work);
                if (phone != null)
                {
                    template = template.Replace("@@WORK_PHONE@@", phone.Number);
                }
                else
                {
                    template = template.Replace("@@WORK_PHONE@@", String.Empty);
                }
            }
            QApplication.Invoke(delegate {
                webView.SetHtml(template);
            });
        }
示例#2
0
        void Populate(VCard vcard)
        {
            string template = null;

            if (vcard == null) {
                template = "Unable to view profile.";
            } else {
                template = Util.ReadResource("profile.html");

                // FIXME: This is just a quick hack. Really need to do all the replacement at once.
                template = template.Replace("@@NAME@@", vcard.FullName);
                template = template.Replace("@@JID@@", vcard.JabberId);
                template = template.Replace("@@NICKNAME@@", vcard.Nickname);

                try {
                    template = template.Replace("@@BIRTHDAY@@", vcard.Birthday.ToString());
                } catch {
                    template = template.Replace("@@BIRTHDAY@@", String.Empty);
                }

                var email = vcard.GetEmail(EmailType.home);
                if (email != null)
                    template = template.Replace("@@EMAIL@@", email.UserId);
                else
                    template = template.Replace("@@EMAIL@@", String.Empty);

                if (vcard.Url != null)
                    template = template.Replace("@@WEBSITE@@", vcard.Url.ToString());
                else
                    template = template.Replace("@@WEBSITE@@", String.Empty);

                template = template.Replace("@@ADDRESS@@", FormatAddress(vcard.GetAddress(AddressLocation.home)));

                var phone = vcard.GetTelephone(TelephoneType.voice, TelephoneLocation.home);
                if (phone != null)
                    template = template.Replace("@@PHONE@@", phone.Number);
                else
                    template = template.Replace("@@PHONE@@", String.Empty);

                template = template.Replace("@@ABOUT@@", vcard.Description);

                var org = vcard.Organization;
                if (org != null) {
                    template = template.Replace("@@COMPANY@@", org.OrgName);
                    template = template.Replace("@@DEPARTMENT@@", vcard.Organization.Unit);
                } else {
                    template = template.Replace("@@COMPANY@@", String.Empty);
                    template = template.Replace("@@DEPARTMENT@@", String.Empty);
                }

                template = template.Replace("@@POSITION@@", vcard.Title);
                template = template.Replace("@@ROLE@@", vcard.Role);

                email = vcard.GetEmail(EmailType.work);
                if (email != null)
                    template = template.Replace("@@WORK_EMAIL@@", email.UserId);
                else
                    template = template.Replace("@@WORK_EMAIL@@", String.Empty);

                template = template.Replace("@@WORK_ADDRESS@@", FormatAddress(vcard.GetAddress(AddressLocation.work)));

                phone = vcard.GetTelephone(TelephoneType.voice, TelephoneLocation.work);
                if (phone != null)
                    template = template.Replace("@@WORK_PHONE@@", phone.Number);
                else
                    template = template.Replace("@@WORK_PHONE@@", String.Empty);
            }
            QApplication.Invoke(delegate {
                webView.SetHtml(template);
            });
        }