File: ContactPhoto.custom

package info (click to toggle)
evolution-sharp 0.11.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,684 kB
  • ctags: 3,577
  • sloc: ansic: 11,275; sh: 8,735; cs: 1,145; makefile: 222; xml: 46
file content (41 lines) | stat: -rw-r--r-- 953 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//  ContactPhoto.custom - customizations for ContactPhoto.
//
//  Author: Mike Kestner  <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.

		[StructLayout (LayoutKind.Sequential)]
		private struct UnmanagedContactPhoto {
			public int length;
			public IntPtr data;
		}

		private byte[] data;

		public static Evolution.ContactPhoto New(IntPtr raw) 
		{
			if (raw == IntPtr.Zero)
				return Evolution.ContactPhoto.Zero;

			Evolution.ContactPhoto self = new Evolution.ContactPhoto();

			UnmanagedContactPhoto raw_photo = (UnmanagedContactPhoto) Marshal.PtrToStructure (raw, typeof (UnmanagedContactPhoto));

			self.Length = raw_photo.length;
			self.data = new byte [self.Length];

			if (self.Length > 0 && raw_photo.data != IntPtr.Zero)
				Marshal.Copy (raw_photo.data, self.data, 0, self.Length);

			return self;
		}

		public byte[] Data {
			get {
				return data;
			}
			set {
				data = value;
				Length = data.Length;
			}
		}