//Copyright (c) 2007 Joshua R. Rodgers //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: //The above copyright notice and this permission notice shall be included in //all copies or substantial portions of the Software. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Bone { static class Importer { [StructLayout(LayoutKind.Sequential)] internal struct Message { internal IntPtr handle; internal uint msg; internal IntPtr wParam; internal IntPtr lParam; internal uint time; internal System.Drawing.Point p; } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_Login(IntPtr bhnd, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelAttributes(IntPtr bhnd, string channel, byte channeltype, string owner, string channelpassword); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_Disconnect(IntPtr bhnd); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_Text (IntPtr bhnd, string origin, string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_IsOnline (IntPtr bhnd, string name, int onlinestatus); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_Welcome (IntPtr bhnd, string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_Ping(IntPtr bhnd, string user, int delay); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_SendText(IntPtr bhnd, int error, string target); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelSub(IntPtr bhnd, string channel, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelAddUser(IntPtr bhnd, string channel, string user); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelDelUser(IntPtr bhnd, string channel, string user); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_BadContact(IntPtr bhnd, string contact); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ContactIsOnline(IntPtr bhnd, string contact, int onlinestatus); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelText(IntPtr bhnd, string origin, string channel, string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_DelayedText(IntPtr bhnd, string origin, int sendtime, string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void CallBack_Broadcast(IntPtr bhnd, string origin, string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_CreateUser(IntPtr bhnd, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ReqPassword(IntPtr bhnd, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_InviteUser(IntPtr bnd, string user, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ReqUserProfile(IntPtr bhnd, int error, string user, string password, string email, int usertype, int creation, int lastlogin, int selfcreated, int isdisabled); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ModifyUserProfile(IntPtr bhnd, int error, string user); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChangeEmail(IntPtr bhnd, int error); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_ChannelList(IntPtr bhnd, string channel, byte type, int usercount); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Callback_InviteNotify(IntPtr bhnd, string user, string channel); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_addcontact(IntPtr bhnd, string contact); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_changeemail(IntPtr bhnd, string newemail); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern IntPtr bone_create(); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_createuser(IntPtr bhnd, string user, string email); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_delcontact(IntPtr bhnd, string contact); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_destroy(IntPtr bhnd); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern IntPtr bone_geterrortext(int error); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern int bone_getlasterror(); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern IntPtr bone_getuserdata(IntPtr bhnd); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_init(int build); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_inviteuser(IntPtr bhnd, string channelname, string name); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_isonline(IntPtr bhnd, string name); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_joinchannel(IntPtr bhnd, string channelname, int inviteonly, string password); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_leavechannel(IntPtr bhnd, string channelname); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_login(IntPtr bhnd, string user, string password); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_modifyuserprofile(IntPtr bhnd, string user, string password, string email, int usertype, int isdisabled); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_pinguser(IntPtr bhnd, string user); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_reqchannellist(IntPtr bhnd); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_reqpassword(IntPtr bhnd, string user, string email); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_requserprofile(IntPtr bhnd, string user); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_sendtext(IntPtr bhnd, string target, string message); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_setuserdata(IntPtr bhnd, IntPtr userdata); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_setcallback(Callbacks category, MulticastDelegate handler); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern void bone_term(); [DllImport("bone.dll", CharSet=CharSet.Ansi)] internal static extern bool bone_updatecontacts(IntPtr bhnd); [return: MarshalAs(UnmanagedType.Bool)] [DllImport("User32.dll", SetLastError = true)] internal static extern bool GetMessage(out Message message, IntPtr handle, uint filterMin, uint filterMax); [DllImport("user32.dll", SetLastError = true)] internal static extern bool TranslateMessage(out Message msg); [DllImport("user32.dll", SetLastError = true)] internal static extern int DispatchMessage(out Message msg); } }