all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Wrong type error in dbus method
@ 2010-07-02  2:23 Patrick Michael Niedzielski
  2010-07-02  9:04 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 12+ messages in thread
From: Patrick Michael Niedzielski @ 2010-07-02  2:23 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

Hi all,

I'm new here, but this is the last place I can find to look for help
regarding dbus and emacs specifics.

I am writing an elisp file to integrate GNU Emacs with Zeitgeist over
dbus. Because of the lack of good documentation on dbus in emacs and my
lack of experience with advanced elisp, I am coming up with the
following error in my method zeitgeist-send:

    Wrong type argument: D-Bus, (zeitgeist-event-timestamp)

I have tried correcting the issue by placing :string before all the
arguments, but that gave me the error:

    Wrong type argument: stringp, (zeitgeist-event-timestamp)

This makes no sense, as I am positive that the value of
(zeitgeist-event-timestamp) is a string.

If you need, the dbus documentation for zeitgeist is here:
http://zeitgeist-project.com/docs/0.4/dbus_api.html#index-0  The format
for it is asaasay.

I have attached the source code (it's a single file, a few functions).

Thanks for any help!
Patrick Niedzielski
-- 
Humm and Strumm <http://hummstrumm.blogspot.com/>, a Free Software 3D
adventure game for both Windows and *NIX.

freeSoftwareHacker(); <http://freesoftwarehacker.blogspot.com/>, a blog
about Free Software, music, and law.

[-- Attachment #2: zeitgeist.el --]
[-- Type: text/x-emacs-lisp, Size: 2328 bytes --]

(require 'dbus)
(defun zeitgeist-call (method &rest args)
  "Call the zeitgeist method METHOD with ARGS over dbus"
  (apply 'dbus-call-method 
    :session                            ; use the session (not system) bus
    "org.gnome.zeitgeist.Engine"        ; service name
    "/org/gnome/zeitgeist/log/activity" ; path name
    "org.gnome.zeitgeist.Log"           ; interface name
    method args))

(defun zeitgeist-event-timestamp ()
  "Get the timestamp in zeitgeist format."
  (let* ((now-time (current-time))
         (hi       (car now-time))
         (lo       (car (cdr now-time)))
         (msecs    (car (cdr (cdr now-time))))) ; This is *micro*seconds. 

    (number-to-string (+ (/ msecs 1000)
       (* (+ lo (* hi 65536))     1000))))) ; Convert system time to milliseconds.

(defun zeitgeist-event-interpretation (event)
  "Get the Event Interpretation of EVENT."
  (case event
    ('zeitgeist-open-event
       "http://zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent")
    ('zeitgeist-close-event
       "http://zeitgeist-project.com/schema/1.0/core#CloseEvent")
    ('zeitgeist-create-event
       "http://zeitgeist-project.com/schema/1.0/core#CreateEvent")
    ('zeitgeist-modify-event
       "http://zeitgeist-project.com/schema/1.0/core#ModifyEvent")
    (otherwise nil)))

(defun zeitgeist-send (event fileurl filemime)
  "Send zeitgeist an event EVENT using the list FILEINFO."
  (let ((event-interpretation (zeitgeist-event-interpretation event)))
    (if (eq nil event-interpretation)
      (message "YOU FAIL")
      (zeitgeist-call "InsertEvents"
        '(:string ""
        :string (zeitgeist-event-timestamp)
        :string event-interpretation
        "http://zeitgeist-project.com/schema/1.0/core#UserActivity"
        "app://emacs.desktop")
        '((fileurl
        "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/#Document"
        "http://www.semanticdesktop.org/ontologies/nfo/#FileDataObject"
        fileurl
        filemime
        (file-name-sans-versions fileurl)
        "")) ; Some black magic later
        '(:array)))))

(defun zeitgeist-open-file ()
  "Tell zeitgeist we openned a file!"
  (if (eq nil (buffer-file-name))
    (message "You are not on a file.")
    (zeitgeist-send 'zeitgeist-open-event buffer-file-name "text/plain")))

(zeitgeist-open-file)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-07-09 19:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02  2:23 Wrong type error in dbus method Patrick Michael Niedzielski
2010-07-02  9:04 ` Thien-Thi Nguyen
2010-07-03  8:59   ` Michael Albinus
2010-07-05  9:00     ` Thien-Thi Nguyen
2010-07-05 15:04       ` Drew Adams
2010-07-05 18:34         ` Michael Albinus
2010-07-05 19:03           ` Thien-Thi Nguyen
2010-07-05 19:35             ` Michael Albinus
2010-07-05 20:40               ` Chad Brown
2010-07-05 15:45       ` Patrick Michael Niedzielski
2010-07-05 18:40         ` Michael Albinus
2010-07-09 19:47       ` Michael Albinus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.