2011-08-13 4 views
0

[DBus (name = ...)]로 주석을 달아 클래스에 인터페이스를 구현할 수 있습니까?Vala : 인터페이스를 구현하는 D-BUS 객체, 속성 오류

예를 들어 https://live.gnome.org/Vala/DBusServerSample에 따라 D-BUS 클라이언트/서버 응용 프로그램을 구현하고 있습니다.

예에 대해 특이한 점은 별도의 인터페이스 정의가 없다는 것입니다. 클라이언트 측에서 별도의 파일로 인터페이스를 사용하고 서버 클래스에서 해당 인터페이스를 구현하도록하고 싶습니다. 그렇게하면 컴파일러가 뭔가를 놓칠 때 알려줄 수 있습니다.

이것은 속성과 함께 작동하지 않습니다. 다음 정의는 내가 무슨와 호환됩니다

/* interface.vala */ 
namespace org.test { 
    [DBus (name = "org.test.Items")] 
    public interface IItems : Object { 
     /** 
     * The object paths to the item instances. 
     * 
     * These objects are of type org.test.items.Item. 
     */ 
     public abstract ObjectPath[] items { 
      owned get; 
     } 

     /** 
     * The signal that is emitted when a new item is added. 
     * 
     * When this signal is emitted, the item will be available. 
     * 
     * @param id 
     *  The object path to the item instance. 
     */ 
     public signal void item_added(ObjectPath id); 

     /** 
     * The signal that is emitted when an item is removed. 
     * 
     * When this signal is emitted, the item will be unavailable. 
     * 
     * @param id 
     *  The object path to the item instance. 
     */ 
     public signal void item_removed(ObjectPath id); 

     /** 
     * Adds a new item. 
     * 
     * The URL will be parsed, and if it contains a valid item, it will be 
     * added. 
     * 
     * @param url 
     *  The URL to the item. This should typically be the URL of the 
     *  RSS feed. 
     * @return the ID of the item added, which can be used to query D-BUS 
     *  for it 
     * @throws IOError if a D-BUS error occurs 
     */ 
     public abstract ObjectPath add_item(string url) throws IOError; 

     /** 
     * Removes an item. 
     * 
     * @param id 
     *  The ID of the item to remove. 
     * @throws IOError if a D-BUS error occurs 
     */ 
     public abstract void remove_item(ObjectPath id) throws IOError; 
    } 
} 

/* server.vala */ 
using Gee; 

namespace org.test { 
    [DBus (name = "org.test.Items")] 
    public class Items : DBUSObject, IItems { 
     private ArrayList<Item> _items; 

     [DBus (visible = false)] 
     protected override void dbus_register(DBusConnection conn, 
       ObjectPath path) throws IOError { 
      conn.register_object(path, this); 
     } 

     [DBus (visible = false)] 
     public Items() { 
      base("org.test.Items", "/org/test", "Items", true); 
      _items = new ArrayList<Item>(); 
     } 

     [DBus (visible = false)] 
     ~Items() { 
      unregister(); 
     } 

     /** 
     * @see interface.vala::org.test.IItems.comics 
     */ 
     public ObjectPath[] items { 
      owned get { 
       ObjectPath[] result = {}; 
       foreach (var item in _items) { 
        result += new ObjectPath(item.path); 
       } 
       return result; 
      } 
     } 

     /** 
     * @see interface.vala::org.test.IItems.add_comic 
     */ 
     public ObjectPath add_item(string url) throws IOError { 
      /* . . . */ 
     } 

     /** 
     * @see interface.vala::org.test.IItems.remove_item 
     */ 
     public void remove_item(ObjectPath id) throws IOError { 
      /* . . . */ 
     } 
    } 
} 

내가 컴파일 할 때, 나는 valac에서 오류를 얻을 수 없지만, 생성 된 C 코드를 컴파일 할 때, 링커는 불평 : undefined reference to 'org_test_items_get_items'은.

이 기능은 _dbus_org_test_items_get_items에서 참조, 그러나 그것은 분명히 버그

답변

관련 문제