| 46 | | /** |
| 47 | | * Get a pointer to a dialog for sending events with the given @a type, to the contact |
| 48 | | * @a id over the protocol @a ppid. If the dialog is already open, the dialog is |
| 49 | | * converted to the correct type before being returned. |
| 50 | | * |
| 51 | | * @returns a pointer to a send event dialog of type @a T, or NULL on error. |
| 52 | | */ |
| 53 | | template<typename T> |
| 54 | | static T* getSendEventDialog(EventType type, QString id, unsigned long ppid) |
| 55 | | { |
| 56 | | UserEventCommon* common = LicqGui::instance()->showEventDialog(type, id, ppid); |
| 57 | | if (!common) |
| 58 | | return NULL; |
| 59 | | |
| 60 | | T* dialog = dynamic_cast<T*>(common); |
| 61 | | if (!dialog) |
| 62 | | { |
| 63 | | UserSendCommon* base = dynamic_cast<UserSendCommon*>(common); |
| 64 | | if (!base) |
| 65 | | return NULL; |
| 66 | | |
| 67 | | base->changeEventType(type); |
| 68 | | dialog = dynamic_cast<T*>(LicqGui::instance()->showEventDialog(type, id, ppid)); |
| 69 | | if (!dialog) |
| 70 | | return NULL; |
| 71 | | } |
| 72 | | |
| 73 | | return dialog; |
| 74 | | } |
| 75 | | |
| 76 | | /// Convenient, wrapper functions for getSendEventDialog. |
| 77 | | static inline UserSendContactEvent* getSendContactEventDialog(QString id, unsigned long ppid) |
| 78 | | { |
| 79 | | return getSendEventDialog<UserSendContactEvent>(ContactEvent, id, ppid); |
| 80 | | } |
| 81 | | |
| 82 | | static inline UserSendFileEvent* getSendFileEventDialog(QString id, unsigned long ppid) |
| 83 | | { |
| 84 | | return getSendEventDialog<UserSendFileEvent>(FileEvent, id, ppid); |
| 85 | | } |
| 86 | | |
| 87 | | static inline UserSendMsgEvent* getSendMsgEventDialog(QString id, unsigned long ppid) |
| 88 | | { |
| 89 | | return getSendEventDialog<UserSendMsgEvent>(MessageEvent, id, ppid); |
| 90 | | } |
| 91 | | |
| 92 | | static inline UserSendUrlEvent* getSendUrlEventDialog(QString id, unsigned long ppid) |
| 93 | | { |
| 94 | | return getSendEventDialog<UserSendUrlEvent>(UrlEvent, id, ppid); |
| 95 | | } |
| 96 | | |