1 ;;; emchat-convert.el --- Utilities to convert other ICQ configurations to EMCHAT
3 ;; Copyright (C) 2001 - 2011 Steve Youngs, Erik Arneson
5 ;; OriginalAuthor: Erik Arneson <erik@emchat.org>
6 ;; Maintainer: Erik Arneson <erik@emchat.org>
7 ;; Created: Aug 06, 2001
8 ;; Homepage: http://www.emchat.org/
11 ;; This file is part of EMchat.
13 ;; Redistribution and use in source and binary forms, with or without
14 ;; modification, are permitted provided that the following conditions
17 ;; 1. Redistributions of source code must retain the above copyright
18 ;; notice, this list of conditions and the following disclaimer.
20 ;; 2. Redistributions in binary form must reproduce the above copyright
21 ;; notice, this list of conditions and the following disclaimer in the
22 ;; documentation and/or other materials provided with the distribution.
24 ;; 3. Neither the name of the author nor the names of any contributors
25 ;; may be used to endorse or promote products derived from this
26 ;; software without specific prior written permission.
28 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
29 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
38 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 (require 'emchat-world))
44 (defun emchat-import-from-licq ()
45 "Import your contact list from LICQ. It doesn't import ignored UIDs."
47 (let (uin udat user-alist ignored)
49 (loop for file in (directory-files
50 (expand-file-name "~/.licq/users/") t nil nil t)
51 when (file-readable-p file)
53 (string-match "/\\([0-9]+\\)\\.uin$" file)
54 ;; Why can't I use 'match-string' here? Gah!
55 (setq uin (subseq file (match-beginning 1) (match-end 1)))
56 (set-buffer (find-file-noselect file))
57 ;; Need to also look for 'Groups.System = 24' to find
58 ;; out if the user is ignored.
59 (if (re-search-forward "^Groups.System = 24$" nil t)
62 (goto-char (point-min))
63 ;; If an Alias is listed, use that. Otherwise, set
64 ;; the alias to the UIN.
65 (if (re-search-forward "^Alias = \\(.*\\)$" nil t)
66 (setq udat (cons uin (match-string 1)))
67 (setq udat (cons uin uin))))
68 (kill-buffer (current-buffer)))
71 (set-buffer (find-file-noselect (expand-file-name emchat-world-rc-filename)))
72 (goto-char (point-max))
73 (insert "\n\n==== These entries were imported from your LICQ configuration.\n")
74 (loop for udat in user-alist
75 do (insert (format ":icq %s %s :licq\n" (car udat) (cdr udat))))
76 (save-buffer (current-buffer))
77 (kill-buffer (current-buffer))))
80 (defun emchat-import-from-micq ()
81 "Import ICQ contact data from a .micqrc file."
85 (set-buffer (find-file-noselect
86 (or (expand-file-name "micqrc"
87 (file-name-as-directory
88 (expand-file-name ".micq"
89 (user-home-directory))))
90 (expand-file-name ".micqrc" (user-home-directory)))))
91 (goto-char (point-min))
92 (if (re-search-forward "^UIN \\([0-9]+\\)$" nil t)
93 (setq me (match-string 1)))
94 (if (re-search-forward "^Contacts$\\|^\\[Contacts\\]$" nil t)
96 (loop while (re-search-forward
97 "^[ \t]*\\*?\\([0-9]+\\)[ \t]+\\(.*\\)$" nil t)
98 do (setq unode (cons (match-string 1) (match-string 2)))
100 (kill-buffer (current-buffer))
101 (set-buffer (find-file-noselect (expand-file-name emchat-world-rc-filename)))
102 (goto-char (point-max))
103 (insert "\n\n==== These entries were imported from your MICQ configuration.\n")
105 (insert (format ":icq %s me\n\n" me)))
106 (loop for unode in user-alist
107 do (insert (format ":icq %s %s :micq\n" (car unode) (cdr unode))))
108 (save-buffer (current-buffer))
109 (kill-buffer (current-buffer))))