Esempio n. 1
0
        private void GetAllAttachments()
        {
            int count;

            int ret = Interop.Messages.GetAttachmentCount(_messageHandle, out count);

            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to get attachment count, Error - " + (MessagesError)ret);
                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
            }

            string path;
            int    type;
            var    attachmentList = new List <MessagesAttachment>();

            for (int i = 0; i < count; i++)
            {
                ret = Interop.Messages.GetAttachment(_messageHandle, i, out type, out path);
                if (ret != (int)MessagesError.None)
                {
                    Log.Error(Globals.LogTag, "Failed to get attachment, Error - " + (MessagesError)ret);
                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
                }

                var attachmentItem = new MessagesAttachment((MediaType)type, path);
                attachmentList.Add(attachmentItem);
            }

            _attachment = attachmentList;
        }
Esempio n. 2
0
        private void AddAttachment(MessagesAttachment attach)
        {
            int ret = Interop.Messages.AddAttachment(_messageHandle, (int)attach.Type, attach.FilePath);

            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to add attachment, Error - " + (MessagesError)ret);
                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
            }
        }