import dbus
import time

TOMBOY_DBUS_PATH = "/org/gnome/Tomboy/RemoteControl"
TOMBOY_DBUS_IFACE = "org.gnome.Tomboy"
TOMBOY_TEST_NOTE = "Conduit_Test_Case"

# Get the current session bus
bus = dbus.SessionBus()

# Get a hold of tomboy
obj = bus.get_object(TOMBOY_DBUS_IFACE, TOMBOY_DBUS_PATH)
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")

# Make sure the test note isn't there...
uid = tomboy.FindNote(TOMBOY_TEST_NOTE)
if len(uid) > 0:
    tomboy.DeleteNote(uid)

# This is the content we are going to attach to our note
data = ""
data += "<note-content>" + TOMBOY_TEST_NOTE + "\n"
data += "\n"
data += ":O\n"
data += "<bold>bold</bold>\n"
data += "<italic>italics</italic>\n"
data += "\n"
data += "<list><list-item dir=\"ltr\">bullet 1\n"
data += "</list-item><list-item dir=\"ltr\">bullet 2</list-item></list></note-content>"

# Create a new note
uid = tomboy.CreateNamedNote(TOMBOY_TEST_NOTE)
assert uid != ""

# Stuff in the raw xml
ok = tomboy.SetNoteContentsXml(uid, data)
assert ok

