AimSixPreferencesInSQLiteMigrationTool

Introduction

Support for migrating commonly used windows setting lowers the barriers for new users trying ubuntu. AOL's Aim client represents > 50% of the marketshare of OSCAR clients. Migrating settings from Aim would make it easier for users coming from windows and aim6 to move to ubuntu and pidgin/telepathy.

Scope and Use Cases

Kathy has used aim6 for a few years and has hundreds of saved away messages. She want to use ubuntu, but doesnt feel like recreating them. Adding support for migrating these preferences would mean a more comfortable install for Kathy.

Implemetation Plan

aim 6.5 stores user preferences in SQLite3 databases. It is relatively simple to extract the preferences. As a quick Hello World application, below is the code for a small C# app that will print away messages from the database, to the console. 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.SQLite;



namespace AwayMessage_Exporter

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("AIM Away Message Extraction Tool");

            Messages myMessages = new Messages();

            myMessages.Populate(@"Data Source=C:\common.cls");

        }

    }



    class Message

    {

        public string Title { get; set; }

        public string Body { get; set; }

        public MessageType Type { get; set; }

        public bool IsDefault { get; set; }



        public void ToConsole()

        {

            Console.WriteLine("Extracted Away Message: {0} Type: {2} \n Code:\n {1} \n", Title, Body, Type);

        }

    }



    enum MessageType

    {

        away,

        idle

    }



    enum AimKeys

    {

        type,

        message,

        title,

        isDefault

    }



    class Messages

    {

        private List<Message> m_Messages;



        private const string GetAwayMessages = @"

        SELECT

            * 

        FROM 

            preferences

        WHERE

            key LIKE '%aol.imApp.status.messages%'";



        public void Populate(string path)

        {

            Dictionary<string, Message> AimKvps = new Dictionary<string, Message>();

            using (SQLiteConnection conn = new SQLiteConnection(path))

            {

                conn.Open();

                SQLiteCommand cmd = new SQLiteCommand(GetAwayMessages, conn);

                SQLiteDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())

                {

                    string[] idparam = rdr.GetString(0).Split('.');

                    if (!(AimKvps.ContainsKey(idparam[4])))

                        AimKvps[idparam[4]] = new Message();



                    AimKeys ak = (AimKeys)Enum.Parse(typeof(AimKeys), idparam[5]);



                    switch (ak)

                    {

                        case AimKeys.type:

                            AimKvps[idparam[4]].Type = (MessageType)Enum.Parse(typeof(MessageType), rdr.GetString(1));

                            break;

                        case AimKeys.title:

                            AimKvps[idparam[4]].Title = rdr.GetString(1);

                            break;

                        case AimKeys.message:

                            AimKvps[idparam[4]].Body = rdr.GetString(1);

                            break;

                        case AimKeys.isDefault:

                            AimKvps[idparam[4]].IsDefault = false;

                            if (Int32.Parse(rdr.GetString(1)) == 1)

                                AimKvps[idparam[4]].IsDefault = true;

                            break;

                    }

                }

                conn.Close();

            }

            m_Messages = new List<Message>();

            foreach (KeyValuePair<string, Message> IdToAwayMessage in AimKvps)

            {

                

                m_Messages.Add(IdToAwayMessage.Value);

            }



            foreach (Message m in m_Messages)

            {

                m.ToConsole();

            }

            Console.ReadLine();

        }

    }



}

For a real implementation we will need to write to xml files supported by pidgin instead of the console. This is a trivial step. Correctly handling multiple users is trickier but still doable

AimSixPreferencesInSQLiteMigrationTool (last edited 2008-11-06 16:46:39 by c-24-2-149-90)