~ubuntu-branches/debian/jessie/banshee-community-extensions/jessie

« back to all changes in this revision

Viewing changes to .pc/0001-Use-DBus-instead-of-NDesk.DBus.patch/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixMonoTransport.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-09-20 18:45:46 UTC
  • mfrom: (1.2.9 upstream) (5.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20110920184546-3ahue2qplydc4t0e
Tags: 2.2.0-1
* [4940fab] Imported Upstream version 2.2.0
  + Notable bug fixes:
    - Karaoke: Fix crash when switching to Now Playing
    - Lyrics: Fix crash when switching to Now Playing

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006 Alp Toker <alp@atoker.com>
2
 
// This software is made available under the MIT License
3
 
// See COPYING for details
4
 
 
5
 
using System;
6
 
using System.IO;
7
 
using System.Net;
8
 
using System.Net.Sockets;
9
 
 
10
 
using Mono.Unix;
11
 
using Mono.Unix.Native;
12
 
 
13
 
namespace NDesk.DBus.Transports
14
 
{
15
 
        class UnixMonoTransport : UnixTransport
16
 
        {
17
 
                protected Socket socket;
18
 
 
19
 
                public override void Open (string path, bool @abstract)
20
 
                {
21
 
                        if (@abstract)
22
 
                                socket = OpenAbstractUnix (path);
23
 
                        else
24
 
                                socket = OpenUnix (path);
25
 
 
26
 
                        socket.Blocking = true;
27
 
                        SocketHandle = (long)socket.Handle;
28
 
                        //Stream = new UnixStream ((int)socket.Handle);
29
 
                        Stream = new NetworkStream (socket);
30
 
                }
31
 
 
32
 
                //send peer credentials null byte. note that this might not be portable
33
 
                //there are also selinux, BSD etc. considerations
34
 
                public override void WriteCred ()
35
 
                {
36
 
                        Stream.WriteByte (0);
37
 
                }
38
 
 
39
 
                public override string AuthString ()
40
 
                {
41
 
                        long uid = UnixUserInfo.GetRealUserId ();
42
 
 
43
 
                        return uid.ToString ();
44
 
                }
45
 
 
46
 
                protected Socket OpenAbstractUnix (string path)
47
 
                {
48
 
                        AbstractUnixEndPoint ep = new AbstractUnixEndPoint (path);
49
 
 
50
 
                        Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
51
 
                        client.Connect (ep);
52
 
 
53
 
                        return client;
54
 
                }
55
 
 
56
 
                public Socket OpenUnix (string path)
57
 
                {
58
 
                        UnixEndPoint remoteEndPoint = new UnixEndPoint (path);
59
 
 
60
 
                        Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
61
 
                        client.Connect (remoteEndPoint);
62
 
 
63
 
                        return client;
64
 
                }
65
 
        }
66
 
}