@@ -34,6 +34,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3434#include " mblsyntax.h"
3535#include " mblnotification.h"
3636
37+ #include < stdarg.h>
38+
3739// //////////////////////////////////////////////////////////////////////////////
3840
3941void FreeNotification (MCNotification &p_notification)
@@ -45,22 +47,34 @@ void FreeNotification(MCNotification &p_notification)
4547
4648// //////////////////////////////////////////////////////////////////////////////
4749
50+ static void MCParameterDeleteList (MCParameter *p_params)
51+ {
52+ while (p_params != nil)
53+ {
54+ MCParameter *t_param;
55+ t_param = p_params;
56+ p_params = p_params->getnext ();
57+ delete t_param;
58+ }
59+ }
60+
4861class MCNotificationEvent : public MCCustomEvent
4962{
5063private:
5164 MCNameRef m_message;
52- MCStringRef m_notification ;
53-
65+ MCParameter *m_params ;
66+
5467public:
55- MCNotificationEvent (MCNameRef p_message, MCStringRef p_notification )
68+ MCNotificationEvent (MCNameRef p_message, MCParameter *p_params )
5669 {
57- m_message = p_message;
58- m_notification = MCValueRetain (p_notification) ;
70+ m_message = MCValueRetain ( p_message) ;
71+ m_params = p_params ;
5972 }
6073
6174 ~MCNotificationEvent ()
6275 {
63- MCValueRelease (m_notification);
76+ MCValueRelease (m_message);
77+ MCParameterDeleteList (m_params);
6478 }
6579
6680 void Destroy (void )
@@ -70,31 +84,100 @@ class MCNotificationEvent: public MCCustomEvent
7084
7185 void Dispatch (void )
7286 {
73- MCdefaultstackptr -> getcurcard () -> message_with_valueref_args (m_message, m_notification );
87+ MCdefaultstackptr -> getcurcard () -> message (m_message, m_params );
7488 }
7589};
7690
91+ bool MCNotificationPostCustom (MCNameRef p_name, uint32_t p_param_count, ...)
92+ {
93+ bool t_success;
94+ t_success = true ;
95+
96+ MCParameter *t_param_list;
97+ t_param_list = nil;
98+
99+ MCParameter *t_param;
100+ t_param = nil;
101+
102+ va_list t_args;
103+ va_start (t_args, p_param_count);
104+
105+ for (uint32_t i = 0 ; t_success && i < p_param_count; i++)
106+ {
107+ MCValueRef t_value;
108+ t_value = va_arg (t_args, MCValueRef);
109+
110+ MCParameter *t_new_param;
111+ t_new_param = new MCParameter ();
112+ t_success = t_new_param != nil;
113+
114+ if (t_success)
115+ {
116+ t_new_param->setvalueref_argument (t_value);
117+ if (t_param != nil)
118+ t_param->setnext (t_new_param);
119+ t_param = t_new_param;
120+
121+ if (t_param_list == nil)
122+ t_param_list = t_param;
123+ }
124+ }
125+
126+ va_end (t_args);
127+
128+ MCNotificationEvent *t_event;
129+ t_event = nil;
130+
131+ if (t_success)
132+ {
133+ t_event = new MCNotificationEvent (p_name, t_param_list);
134+ t_success = t_event != nil;
135+ }
136+
137+ if (t_success)
138+ t_success = MCEventQueuePostCustom (t_event);
139+
140+ if (!t_success)
141+ {
142+ if (t_event != nil)
143+ delete t_event;
144+ else
145+ MCParameterDeleteList (t_param_list);
146+ }
147+
148+ return t_success;
149+ }
150+
151+ // //////////////////////////////////////////////////////////////////////////////
152+
77153void MCNotificationPostLocalNotificationEvent (MCStringRef p_payload)
78154{
79- MCEventQueuePostCustom ( new MCNotificationEvent (MCM_local_notification_received, p_payload) );
155+ /* UNCHECKED */ MCNotificationPostCustom (MCM_local_notification_received, 1 , p_payload);
80156}
81157
82158void MCNotificationPostPushNotificationEvent (MCStringRef p_payload)
83159{
84- MCEventQueuePostCustom ( new MCNotificationEvent (MCM_push_notification_received, p_payload) );
160+ /* UNCHECKED */ MCNotificationPostCustom (MCM_push_notification_received, 1 , p_payload);
85161}
86162
87163void MCNotificationPostPushRegistered (MCStringRef p_registration_text)
88164{
89- MCEventQueuePostCustom ( new MCNotificationEvent (MCM_push_notification_registered, p_registration_text) );
165+ /* UNCHECKED */ MCNotificationPostCustom (MCM_push_notification_registered, 1 , p_registration_text);
90166}
91167
92168void MCNotificationPostPushRegistrationError (MCStringRef p_error_text)
93169{
94- MCEventQueuePostCustom ( new MCNotificationEvent (MCM_push_notification_registration_error, p_error_text) );
170+ /* UNCHECKED */ MCNotificationPostCustom (MCM_push_notification_registration_error, 1 , p_error_text);
95171}
96172
97173void MCNotificationPostUrlWakeUp (MCStringRef p_url_wake_up_text)
98174{
99- MCEventQueuePostCustom (new MCNotificationEvent (MCM_url_wake_up, p_url_wake_up_text));
175+ /* UNCHECKED */ MCNotificationPostCustom (MCM_url_wake_up, 1 , p_url_wake_up_text);
176+ }
177+
178+ void MCNotificationPostLaunchDataChanged (MCArrayRef p_launch_data)
179+ {
180+ /* UNCHECKED */ MCNotificationPostCustom (MCM_launch_data_changed, 1 , p_launch_data);
100181}
182+
183+ // //////////////////////////////////////////////////////////////////////////////
0 commit comments