You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7556 lines
240 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. Copyright 2006 - 2011 Intel Corporation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <sys/types.h>
  16. #include <sys/socket.h>
  17. #include <netinet/in.h>
  18. #include <arpa/inet.h>
  19. #include <sys/time.h>
  20. #include <netdb.h>
  21. #include <string.h>
  22. #include <sys/ioctl.h>
  23. #include <net/if.h>
  24. #include <sys/utsname.h>
  25. #include <sys/socket.h>
  26. #include <netinet/in.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <errno.h>
  30. #include "ILibParsers.h"
  31. #include "ILibHTTPClient.h"
  32. #include "ILibSSDPClient.h"
  33. #include "ILibMiniWebServer.h"
  34. #include "RNDControlPoint.h"
  35. #include <semaphore.h>
  36. #define INVALID_DATA 0
  37. #define DEBUGSTATEMENT(x)
  38. #define LVL3DEBUG(x)
  39. const char *UPNPCP_SOAP_Header = "POST %s HTTP/1.0\r\nHost: %s:%d\r\nUser-Agent: POSIX, UPnP/1.0, Intel MicroStack/1.0.1189\r\nSOAPACTION: \"%s#%s\"\r\nContent-Type: text/xml\r\nContent-Length: %d\r\n\r\n";
  40. const char *UPNPCP_SOAP_BodyHead = "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><u:";
  41. const char *UPNPCP_SOAP_BodyTail = "></s:Body></s:Envelope>";
  42. void RNDRenew(void *state);
  43. void RNDSSDP_Sink(void *sender, char* UDN, int Alive, char* LocationURL, int Timeout,void *cp);
  44. struct CustomUserData
  45. {
  46. int Timeout;
  47. char* buffer;
  48. };
  49. struct RNDCP
  50. {
  51. void (*PreSelect)(void* object,fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime);
  52. void (*PostSelect)(void* object,int slct, fd_set *readset, fd_set *writeset, fd_set *errorset);
  53. void (*Destroy)(void* object);
  54. void (*DiscoverSink)(struct UPnPDevice *device);
  55. void (*RemoveSink)(struct UPnPDevice *device);
  56. void (*EventCallback_ConnectionManager_SourceProtocolInfo)(struct UPnPService* Service,char* value);
  57. void (*EventCallback_ConnectionManager_SinkProtocolInfo)(struct UPnPService* Service,char* value);
  58. void (*EventCallback_ConnectionManager_CurrentConnectionIDs)(struct UPnPService* Service,char* value);
  59. void (*EventCallback_AVTransport_LastChange)(struct UPnPService* Service,char* value);
  60. void (*EventCallback_RenderingControl_LastChange)(struct UPnPService* Service,char* value);
  61. struct UDNMapNode *UDN_Head;
  62. struct LifeTimeMonitorStruct *LifeTimeMonitor;
  63. void *HTTP;
  64. void *SSDP;
  65. void *WebServer;
  66. sem_t DeviceLock;
  67. void* SIDTable;
  68. void *Chain;
  69. int RecheckFlag;
  70. int AddressListLength;
  71. int *AddressList;
  72. };
  73. void (*RNDEventCallback_ConnectionManager_SourceProtocolInfo)(struct UPnPService* Service,char* value);
  74. void (*RNDEventCallback_ConnectionManager_SinkProtocolInfo)(struct UPnPService* Service,char* value);
  75. void (*RNDEventCallback_ConnectionManager_CurrentConnectionIDs)(struct UPnPService* Service,char* value);
  76. void (*RNDEventCallback_AVTransport_LastChange)(struct UPnPService* Service,char* value);
  77. void (*RNDEventCallback_RenderingControl_LastChange)(struct UPnPService* Service,char* value);
  78. struct InvokeStruct
  79. {
  80. struct UPnPService *Service;
  81. void *CallbackPtr;
  82. void *User;
  83. };
  84. struct UPnPServiceInfo
  85. {
  86. char* serviceType;
  87. char* SCPDURL;
  88. char* controlURL;
  89. char* eventSubURL;
  90. char* serviceId;
  91. struct UPnPServiceInfo *Next;
  92. };
  93. struct UPnP_Stack
  94. {
  95. void *data;
  96. struct UPnP_Stack *next;
  97. };
  98. struct UDNMapNode
  99. {
  100. char* UDN;
  101. char* RootUDN;
  102. long TimeStamp;
  103. struct UPnPDevice *device;
  104. struct UDNMapNode *Next;
  105. struct UDNMapNode *Previous;
  106. };
  107. void RNDDestructUPnPService(struct UPnPService *service)
  108. {
  109. struct UPnPAction *a1,*a2;
  110. struct UPnPStateVariable *sv1,*sv2;
  111. int i;
  112. a1 = service->Actions;
  113. while(a1!=NULL)
  114. {
  115. a2 = a1->Next;
  116. FREE(a1->Name);
  117. FREE(a1);
  118. a1 = a2;
  119. }
  120. sv1 = service->Variables;
  121. while(sv1!=NULL)
  122. {
  123. sv2 = sv1->Next;
  124. FREE(sv1->Name);
  125. if(sv1->Min!=NULL) {FREE(sv1->Min);}
  126. if(sv1->Max!=NULL) {FREE(sv1->Max);}
  127. if(sv1->Step!=NULL) {FREE(sv1->Step);}
  128. for(i=0;i<sv1->NumAllowedValues;++i)
  129. {
  130. FREE(sv1->AllowedValues[i]);
  131. }
  132. if(sv1->AllowedValues!=NULL) {FREE(sv1->AllowedValues);}
  133. FREE(sv1);
  134. sv1 = sv2;
  135. }
  136. if(service->ControlURL!=NULL) {FREE(service->ControlURL);}
  137. if(service->SCPDURL!=NULL) {FREE(service->SCPDURL);}
  138. if(service->ServiceId!=NULL) {FREE(service->ServiceId);}
  139. if(service->ServiceType!=NULL) {FREE(service->ServiceType);}
  140. if(service->SubscriptionURL!=NULL) {FREE(service->SubscriptionURL);}
  141. if(service->SubscriptionID!=NULL)
  142. {
  143. ILibLifeTime_Remove(((struct RNDCP*)service->Parent->CP)->LifeTimeMonitor,service);
  144. ILibDeleteEntry(((struct RNDCP*)service->Parent->CP)->SIDTable,service->SubscriptionID,(int)strlen(service->SubscriptionID));
  145. FREE(service->SubscriptionID);
  146. service->SubscriptionID = NULL;
  147. }
  148. FREE(service);
  149. }
  150. void RNDDestructUPnPDevice(struct UPnPDevice *device)
  151. {
  152. struct UPnPDevice *d1,*d2;
  153. struct UPnPService *s1,*s2;
  154. d1 = device->EmbeddedDevices;
  155. while(d1!=NULL)
  156. {
  157. d2 = d1->Next;
  158. RNDDestructUPnPDevice(d1);
  159. d1 = d2;
  160. }
  161. s1 = device->Services;
  162. while(s1!=NULL)
  163. {
  164. s2 = s1->Next;
  165. RNDDestructUPnPService(s1);
  166. s1 = s2;
  167. }
  168. LVL3DEBUG(printf("\r\n\r\nDevice Destructed\r\n");)
  169. if(device->PresentationURL!=NULL) {FREE(device->PresentationURL);}
  170. if(device->ManufacturerName!=NULL) {FREE(device->ManufacturerName);}
  171. if(device->ManufacturerURL!=NULL) {FREE(device->ManufacturerURL);}
  172. if(device->ModelName!=NULL) {FREE(device->ModelName);}
  173. if(device->ModelNumber!=NULL) {FREE(device->ModelNumber);}
  174. if(device->ModelURL!=NULL) {FREE(device->ModelURL);}
  175. if(device->DeviceType!=NULL) {FREE(device->DeviceType);}
  176. if(device->FriendlyName!=NULL) {FREE(device->FriendlyName);}
  177. if(device->LocationURL!=NULL) {FREE(device->LocationURL);}
  178. if(device->UDN!=NULL) {FREE(device->UDN);}
  179. if(device->InterfaceToHost!=NULL) {FREE(device->InterfaceToHost);}
  180. FREE(device);
  181. }
  182. void RNDAddRef(struct UPnPDevice *device)
  183. {
  184. struct RNDCP *CP = (struct RNDCP*)device->CP;
  185. struct UPnPDevice *d = device;
  186. sem_wait(&(CP->DeviceLock));
  187. while(d->Parent!=NULL) {d = d->Parent;}
  188. ++d->ReferenceCount;
  189. sem_post(&(CP->DeviceLock));
  190. }
  191. void RNDRelease(struct UPnPDevice *device)
  192. {
  193. struct RNDCP *CP = (struct RNDCP*)device->CP;
  194. struct UPnPDevice *d = device;
  195. sem_wait(&(CP->DeviceLock));
  196. while(d->Parent!=NULL) {d = d->Parent;}
  197. --d->ReferenceCount;
  198. if(d->ReferenceCount==0)
  199. {
  200. RNDDestructUPnPDevice(d);
  201. }
  202. sem_post(&(CP->DeviceLock));
  203. }
  204. void RNDPush(struct UPnP_Stack **pp_Top, void *data)
  205. {
  206. struct UPnP_Stack *frame = (struct UPnP_Stack*)MALLOC(sizeof(struct UPnP_Stack));
  207. frame->data = data;
  208. frame->next = *pp_Top;
  209. *pp_Top = frame;
  210. }
  211. void *RNDPop(struct UPnP_Stack **pp_Top)
  212. {
  213. struct UPnP_Stack *frame = *pp_Top;
  214. void *RetVal = NULL;
  215. if(frame!=NULL)
  216. {
  217. *pp_Top = frame->next;
  218. RetVal = frame->data;
  219. FREE(frame);
  220. }
  221. return(RetVal);
  222. }
  223. void *RNDPeek(struct UPnP_Stack **pp_Top)
  224. {
  225. struct UPnP_Stack *frame = *pp_Top;
  226. void *RetVal = NULL;
  227. if(frame!=NULL)
  228. {
  229. RetVal = (*pp_Top)->data;
  230. }
  231. return(RetVal);
  232. }
  233. void RNDFlush(struct UPnP_Stack **pp_Top)
  234. {
  235. while(RNDPop(pp_Top)!=NULL) {}
  236. *pp_Top = NULL;
  237. }
  238. void RNDAttachRootUDNToUDN(void *v_CP,char* UDN, char* RootUDN)
  239. {
  240. struct UDNMapNode *node;
  241. struct RNDCP* CP = (struct RNDCP*)v_CP;
  242. if(CP->UDN_Head==NULL) {return;}
  243. sem_wait(&(CP->DeviceLock));
  244. node = CP->UDN_Head;
  245. while(node!=NULL)
  246. {
  247. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  248. {
  249. if(node->RootUDN!=NULL)
  250. {
  251. FREE(node->RootUDN);
  252. }
  253. node->RootUDN = MALLOC(1+strlen(RootUDN));
  254. sprintf(node->RootUDN,"%s",RootUDN);
  255. break;
  256. }
  257. node=node->Next;
  258. }
  259. sem_post(&(CP->DeviceLock));
  260. }
  261. void RNDAttachDeviceToUDN(void *v_CP,char* UDN, struct UPnPDevice *device)
  262. {
  263. struct UDNMapNode *node;
  264. struct RNDCP* CP = (struct RNDCP*)v_CP;
  265. if(CP->UDN_Head==NULL) {return;}
  266. sem_wait(&(CP->DeviceLock));
  267. node = CP->UDN_Head;
  268. while(node!=NULL)
  269. {
  270. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  271. {
  272. node->device = device;
  273. ++device->ReferenceCount;
  274. break;
  275. }
  276. node=node->Next;
  277. }
  278. sem_post(&(CP->DeviceLock));
  279. }
  280. void RNDRemoveUDN(void *v_CP,char* UDN)
  281. {
  282. struct RNDCP* CP = (struct RNDCP*)v_CP;
  283. struct UPnPDevice *device = NULL;
  284. struct UDNMapNode *node,*prevNode;
  285. if(CP->UDN_Head==NULL) {return;}
  286. sem_wait(&(CP->DeviceLock));
  287. node = CP->UDN_Head;
  288. prevNode = NULL;
  289. while (node!=NULL)
  290. {
  291. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  292. {
  293. device = node->device;
  294. node->device = NULL;
  295. if(node->RootUDN!=NULL)
  296. {
  297. FREE(node->RootUDN);
  298. node->RootUDN = NULL;
  299. }
  300. if(prevNode!=NULL)
  301. {
  302. prevNode->Next = node->Next;
  303. if(node->Next!=NULL)
  304. {
  305. node->Next->Previous = prevNode;
  306. }
  307. }
  308. else
  309. {
  310. CP->UDN_Head = node->Next;
  311. if(node->Next!=NULL)
  312. {
  313. node->Next->Previous = NULL;
  314. }
  315. }
  316. FREE(node->UDN);
  317. FREE(node);
  318. break;
  319. }
  320. prevNode = node;
  321. node=node->Next;
  322. }
  323. sem_post(&(CP->DeviceLock));
  324. if(device!=NULL) {RNDRelease(device);}
  325. }
  326. void RNDAddUDN(void *v_CP,char *UDN)
  327. {
  328. struct RNDCP* CP = (struct RNDCP*)v_CP;
  329. struct UDNMapNode *node;
  330. int has = 0;
  331. sem_wait(&(CP->DeviceLock));
  332. node = CP->UDN_Head;
  333. while(node!=NULL)
  334. {
  335. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  336. {
  337. has = -1;
  338. break;
  339. }
  340. node=node->Next;
  341. }
  342. if(has==0)
  343. {
  344. node = (struct UDNMapNode*)MALLOC(sizeof(struct UDNMapNode));
  345. node->UDN = (char*)MALLOC((int)strlen(UDN)+1);
  346. memcpy(node->UDN,UDN,(int)strlen(UDN));
  347. node->UDN[(int)strlen(UDN)] = '\0';
  348. node->device = NULL;
  349. node->RootUDN = NULL;
  350. node->Next = CP->UDN_Head;
  351. CP->UDN_Head = node;
  352. CP->UDN_Head->Previous = NULL;
  353. if(CP->UDN_Head->Next!=NULL)
  354. {
  355. CP->UDN_Head->Next->Previous = CP->UDN_Head;
  356. }
  357. }
  358. sem_post(&(CP->DeviceLock));
  359. }
  360. struct UPnPDevice* RNDGetDeviceAtUDN(void *v_CP,char* UDN)
  361. {
  362. struct UDNMapNode *node;
  363. struct UPnPDevice *RetVal = NULL;
  364. struct RNDCP* CP = (struct RNDCP*)v_CP;
  365. if(CP->UDN_Head==NULL) {return(NULL);}
  366. sem_wait(&(CP->DeviceLock));
  367. node = CP->UDN_Head;
  368. while(node!=NULL)
  369. {
  370. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  371. {
  372. RetVal = node->device;
  373. if(RetVal!=NULL){++RetVal->ReferenceCount;}
  374. break;
  375. }
  376. node=node->Next;
  377. }
  378. sem_post(&(CP->DeviceLock));
  379. return(RetVal);
  380. }
  381. char* RNDGetRootUDNAtUDN(void *v_CP,char* UDN)
  382. {
  383. struct UDNMapNode *node;
  384. char *RetVal = NULL;
  385. struct RNDCP* CP = (struct RNDCP*)v_CP;
  386. if(CP->UDN_Head==NULL) {return(NULL);}
  387. sem_wait(&(CP->DeviceLock));
  388. node = CP->UDN_Head;
  389. while(node!=NULL)
  390. {
  391. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  392. {
  393. RetVal = node->RootUDN;
  394. break;
  395. }
  396. node=node->Next;
  397. }
  398. sem_post(&(CP->DeviceLock));
  399. return(RetVal);
  400. }
  401. int RNDHasUDN(void *v_CP,char *UDN)
  402. {
  403. struct UDNMapNode *node;
  404. struct RNDCP* CP = (struct RNDCP*)v_CP;
  405. int RetVal = 0;
  406. if(CP->UDN_Head==NULL) {return(0);}
  407. sem_wait(&(CP->DeviceLock));
  408. node = CP->UDN_Head;
  409. while(node!=NULL)
  410. {
  411. if(strncmp(node->UDN,UDN,(int)strlen(UDN))==0)
  412. {
  413. RetVal = -1;
  414. break;
  415. }
  416. node=node->Next;
  417. }
  418. sem_post(&(CP->DeviceLock));
  419. return(RetVal);
  420. }
  421. void RNDParseUri(char* URI, char** IP, unsigned short* Port, char** Path)
  422. {
  423. struct parser_result *result,*result2,*result3;
  424. char *TempString,*TempString2;
  425. int TempStringLength,TempStringLength2;
  426. result = ILibParseString(URI, 0, (int)strlen(URI), "://", 3);
  427. TempString = result->LastResult->data;
  428. TempStringLength = result->LastResult->datalength;
  429. /* Parse Path */
  430. result2 = ILibParseString(TempString,0,TempStringLength,"/",1);
  431. TempStringLength2 = TempStringLength-result2->FirstResult->datalength;
  432. *Path = (char*)MALLOC(TempStringLength2+1);
  433. memcpy(*Path,TempString+(result2->FirstResult->datalength),TempStringLength2);
  434. (*Path)[TempStringLength2] = '\0';
  435. /* Parse Port Number */
  436. result3 = ILibParseString(result2->FirstResult->data,0,result2->FirstResult->datalength,":",1);
  437. if(result3->NumResults==1)
  438. {
  439. *Port = 80;
  440. }
  441. else
  442. {
  443. TempString2 = (char*)MALLOC(result3->LastResult->datalength+1);
  444. memcpy(TempString2,result3->LastResult->data,result3->LastResult->datalength);
  445. TempString2[result3->LastResult->datalength] = '\0';
  446. *Port = (unsigned short)atoi(TempString2);
  447. FREE(TempString2);
  448. }
  449. /* Parse IP Address */
  450. TempStringLength2 = result3->FirstResult->datalength;
  451. *IP = (char*)MALLOC(TempStringLength2+1);
  452. memcpy(*IP,result3->FirstResult->data,TempStringLength2);
  453. (*IP)[TempStringLength2] = '\0';
  454. ILibDestructParserResults(result3);
  455. ILibDestructParserResults(result2);
  456. ILibDestructParserResults(result);
  457. }
  458. struct packetheader *RNDBuildPacket(char* IP, int Port, char* Path, char* cmd)
  459. {
  460. struct packetheader *RetVal = ILibCreateEmptyPacket();
  461. char* HostLine = (char*)MALLOC((int)strlen(IP)+7);
  462. int HostLineLength = sprintf(HostLine,"%s:%d",IP,Port);
  463. ILibSetDirective(RetVal,cmd,(int)strlen(cmd),Path,(int)strlen(Path));
  464. ILibAddHeaderLine(RetVal,"Host",4,HostLine,HostLineLength);
  465. ILibAddHeaderLine(RetVal,"User-Agent",10,"POSIX, UPnP/1.0, Intel MicroStack/1.0.1189",42);
  466. FREE(HostLine);
  467. return(RetVal);
  468. }
  469. void RNDRemoveServiceFromDevice(struct UPnPDevice *device, struct UPnPService *service)
  470. {
  471. struct UPnPService *s = device->Services;
  472. if(s==service)
  473. {
  474. device->Services = s->Next;
  475. RNDDestructUPnPService(service);
  476. return;
  477. }
  478. while(s->Next!=NULL)
  479. {
  480. if(s->Next == service)
  481. {
  482. s->Next = s->Next->Next;
  483. RNDDestructUPnPService(service);
  484. return;
  485. }
  486. s = s->Next;
  487. }
  488. }
  489. void RNDProcessDevice(struct UPnPDevice *device)
  490. {
  491. int OK = 0;
  492. struct UPnPService *s,*s2;
  493. struct UPnPDevice *EmbeddedDevice = device->EmbeddedDevices;
  494. while(EmbeddedDevice!=NULL)
  495. {
  496. RNDProcessDevice(EmbeddedDevice);
  497. EmbeddedDevice = EmbeddedDevice->Next;
  498. }
  499. if(strncmp(device->DeviceType,"urn:schemas-upnp-org:device:MediaRenderer:1",43)==0)
  500. {
  501. s = device->Services;
  502. while(s!=NULL)
  503. {
  504. OK = 0;
  505. if(strncmp(s->ServiceType,"urn:schemas-upnp-org:service:ConnectionManager:1",48)==0)
  506. {
  507. OK = 1;
  508. }
  509. if(strncmp(s->ServiceType,"urn:schemas-upnp-org:service:AVTransport:1",42)==0)
  510. {
  511. OK = 1;
  512. }
  513. if(strncmp(s->ServiceType,"urn:schemas-upnp-org:service:RenderingControl:1",47)==0)
  514. {
  515. OK = 1;
  516. }
  517. s2 = s->Next;
  518. if(OK==0) {RNDRemoveServiceFromDevice(device,s);}
  519. s = s2;
  520. }
  521. }
  522. }
  523. void RNDPrintUPnPDevice(int indents, struct UPnPDevice *device)
  524. {
  525. struct UPnPService *s;
  526. struct UPnPDevice *d;
  527. struct UPnPAction *a;
  528. int x=0;
  529. for(x=0;x<indents;++x) {printf(" ");}
  530. printf("Device: %s\r\n",device->DeviceType);
  531. for(x=0;x<indents;++x) {printf(" ");}
  532. printf("Friendly: %s\r\n",device->FriendlyName);
  533. s = device->Services;
  534. while(s!=NULL)
  535. {
  536. for(x=0;x<indents;++x) {printf(" ");}
  537. printf(" Service: %s\r\n",s->ServiceType);
  538. a = s->Actions;
  539. while(a!=NULL)
  540. {
  541. for(x=0;x<indents;++x) {printf(" ");}
  542. printf(" Action: %s\r\n",a->Name);
  543. a = a->Next;
  544. }
  545. s = s->Next;
  546. }
  547. d = device->EmbeddedDevices;
  548. while(d!=NULL)
  549. {
  550. RNDPrintUPnPDevice(indents+5,d);
  551. d = d->Next;
  552. }
  553. }
  554. struct UPnPService *RNDGetService(struct UPnPDevice *device, char* ServiceName, int length)
  555. {
  556. struct UPnPService *RetService = NULL;
  557. struct UPnPService *s = device->Services;
  558. while(s!=NULL)
  559. {
  560. if((int)strlen(s->ServiceType)==length)
  561. {
  562. if(strncmp(s->ServiceType,ServiceName,length)==0)
  563. {
  564. RetService = s;
  565. break;
  566. }
  567. }
  568. s = s->Next;
  569. }
  570. return(RetService);
  571. }
  572. struct UPnPService *RNDGetService_ConnectionManager(struct UPnPDevice *device)
  573. {
  574. return(RNDGetService(device,"urn:schemas-upnp-org:service:ConnectionManager:1",48));
  575. }
  576. struct UPnPService *RNDGetService_AVTransport(struct UPnPDevice *device)
  577. {
  578. return(RNDGetService(device,"urn:schemas-upnp-org:service:AVTransport:1",42));
  579. }
  580. struct UPnPService *RNDGetService_RenderingControl(struct UPnPDevice *device)
  581. {
  582. return(RNDGetService(device,"urn:schemas-upnp-org:service:RenderingControl:1",47));
  583. }
  584. struct UPnPDevice *RNDGetDevice2(struct UPnPDevice *device, int index, int *c_Index)
  585. {
  586. struct UPnPDevice *RetVal = NULL;
  587. struct UPnPDevice *e_Device = NULL;
  588. int currentIndex = *c_Index;
  589. if(strncmp(device->DeviceType,"urn:schemas-upnp-org:device:MediaRenderer:1",43)==0)
  590. {
  591. ++currentIndex;
  592. if(currentIndex==index)
  593. {
  594. *c_Index = currentIndex;
  595. return(device);
  596. }
  597. }
  598. e_Device = device->EmbeddedDevices;
  599. while(e_Device!=NULL)
  600. {
  601. RetVal = RNDGetDevice2(e_Device,index,&currentIndex);
  602. if(RetVal!=NULL)
  603. {
  604. break;
  605. }
  606. e_Device = e_Device->Next;
  607. }
  608. *c_Index = currentIndex;
  609. return(RetVal);
  610. }
  611. struct UPnPDevice* RNDGetDevice1(struct UPnPDevice *device,int index)
  612. {
  613. int c_Index = -1;
  614. return(RNDGetDevice2(device,index,&c_Index));
  615. }
  616. int RNDGetDeviceCount(struct UPnPDevice *device)
  617. {
  618. int RetVal = 0;
  619. struct UPnPDevice *e_Device = device->EmbeddedDevices;
  620. while(e_Device!=NULL)
  621. {
  622. RetVal += RNDGetDeviceCount(e_Device);
  623. e_Device = e_Device->Next;
  624. }
  625. if(strncmp(device->DeviceType,"urn:schemas-upnp-org:device:MediaRenderer:1",43)==0)
  626. {
  627. ++RetVal;
  628. }
  629. return(RetVal);
  630. }
  631. int RNDGetErrorCode(char *buffer, int length)
  632. {
  633. int RetVal = 500;
  634. struct ILibXMLNode *xml,*rootXML;
  635. char *temp;
  636. int tempLength;
  637. rootXML = xml = ILibParseXML(buffer,0,length);
  638. ILibProcessXMLNodeList(xml);
  639. while(xml!=NULL)
  640. {
  641. if(xml->NameLength==8 && memcmp(xml->Name,"Envelope",8)==0)
  642. {
  643. xml = xml->Next;
  644. while(xml!=NULL)
  645. {
  646. if(xml->NameLength==4 && memcmp(xml->Name,"Body",4)==0)
  647. {
  648. xml = xml->Next;
  649. while(xml!=NULL)
  650. {
  651. if(xml->NameLength==5 && memcmp(xml->Name,"Fault",5)==0)
  652. {
  653. xml = xml->Next;
  654. while(xml!=NULL)
  655. {
  656. if(xml->NameLength==6 && memcmp(xml->Name,"detail",6)==0)
  657. {
  658. xml = xml->Next;
  659. while(xml!=NULL)
  660. {
  661. if(xml->NameLength==9 && memcmp(xml->Name,"UPnPError",9)==0)
  662. {
  663. xml = xml->Next;
  664. while(xml!=NULL)
  665. {
  666. if(xml->NameLength==9 && memcmp(xml->Name,"errorCode",9)==0)
  667. {
  668. tempLength = ILibReadInnerXML(xml,&temp);
  669. temp[tempLength] = 0;
  670. RetVal =atoi(temp);
  671. xml = NULL;
  672. }
  673. if(xml!=NULL) {xml = xml->Peer;}
  674. }
  675. }
  676. if(xml!=NULL) {xml = xml->Peer;}
  677. }
  678. }
  679. if(xml!=NULL) {xml = xml->Peer;}
  680. }
  681. }
  682. if(xml!=NULL) {xml = xml->Peer;}
  683. }
  684. }
  685. if(xml!=NULL) {xml = xml->Peer;}
  686. }
  687. }
  688. if(xml!=NULL) {xml = xml->Peer;}
  689. }
  690. ILibDestructXMLNodeList(rootXML);
  691. return(RetVal);
  692. }
  693. void RNDProcessSCPD(char* buffer, int length, struct UPnPService *service)
  694. {
  695. struct UPnPAction *action;
  696. struct UPnPStateVariable *sv = NULL;
  697. struct UPnPAllowedValue *av = NULL;
  698. struct UPnPAllowedValue *avs = NULL;
  699. struct ILibXMLNode *xml,*rootXML;
  700. int flg2,flg3,flg4;
  701. char* tempString;
  702. int tempStringLength;
  703. rootXML = xml = ILibParseXML(buffer,0,length);
  704. ILibProcessXMLNodeList(xml);
  705. xml = xml->Next;
  706. while(xml!=NULL)
  707. {
  708. if(xml->NameLength==10 && memcmp(xml->Name,"actionList",10)==0)
  709. {
  710. xml = xml->Next;
  711. flg2 = 0;
  712. while(flg2==0)
  713. {
  714. if(xml->NameLength==6 && memcmp(xml->Name,"action",6)==0)
  715. {
  716. action = (struct UPnPAction*)MALLOC(sizeof(struct UPnPAction));
  717. action->Name = NULL;
  718. action->Next = service->Actions;
  719. service->Actions = action;
  720. xml = xml->Next;
  721. flg3 = 0;
  722. while(flg3==0)
  723. {
  724. if(xml->NameLength==4 && memcmp(xml->Name,"name",4)==0)
  725. {
  726. tempStringLength = ILibReadInnerXML(xml,&tempString);
  727. action->Name = (char*)MALLOC(1+tempStringLength);
  728. memcpy(action->Name,tempString,tempStringLength);
  729. action->Name[tempStringLength] = '\0';
  730. }
  731. if(xml->Peer==NULL)
  732. {
  733. flg3 = -1;
  734. xml = xml->Parent;
  735. }
  736. else
  737. {
  738. xml = xml->Peer;
  739. }
  740. }
  741. }
  742. if(xml->Peer==NULL)
  743. {
  744. flg2 = -1;
  745. xml = xml->Parent;
  746. }
  747. else
  748. {
  749. xml = xml->Peer;
  750. }
  751. }
  752. }
  753. if(xml->NameLength==17 && memcmp(xml->Name,"serviceStateTable",17)==0)
  754. {
  755. if(xml->Next->StartTag!=0)
  756. {
  757. xml = xml->Next;
  758. flg2 = 0;
  759. while(flg2==0)
  760. {
  761. if(xml->NameLength==13 && memcmp(xml->Name,"stateVariable",13)==0)
  762. {
  763. sv = (struct UPnPStateVariable*)MALLOC(sizeof(struct UPnPStateVariable));
  764. sv->AllowedValues = NULL;
  765. sv->NumAllowedValues = 0;
  766. sv->Max = NULL;
  767. sv->Min = NULL;
  768. sv->Step = NULL;
  769. sv->Name = NULL;
  770. sv->Next = service->Variables;
  771. service->Variables = sv;
  772. sv->Parent = service;
  773. xml = xml->Next;
  774. flg3 = 0;
  775. while(flg3==0)
  776. {
  777. if(xml->NameLength==4 && memcmp(xml->Name,"name",4)==0)
  778. {
  779. tempStringLength = ILibReadInnerXML(xml,&tempString);
  780. sv->Name = (char*)MALLOC(1+tempStringLength);
  781. memcpy(sv->Name,tempString,tempStringLength);
  782. sv->Name[tempStringLength] = '\0';
  783. }
  784. if(xml->NameLength==16 && memcmp(xml->Name,"allowedValueList",16)==0)
  785. {
  786. if(xml->Next->StartTag!=0)
  787. {
  788. avs = NULL;
  789. xml = xml->Next;
  790. flg4 = 0;
  791. while(flg4==0)
  792. {
  793. if(xml->NameLength==12 && memcmp(xml->Name,"allowedValue",12)==0)
  794. {
  795. av = (struct UPnPAllowedValue*)MALLOC(sizeof(struct UPnPAllowedValue));
  796. av->Next = avs;
  797. avs = av;
  798. tempStringLength = ILibReadInnerXML(xml,&tempString);
  799. av->Value = (char*)MALLOC(1+tempStringLength);
  800. memcpy(av->Value,tempString,tempStringLength);
  801. av->Value[tempStringLength] = '\0';
  802. }
  803. if(xml->Peer!=NULL)
  804. {
  805. xml = xml->Peer;
  806. }
  807. else
  808. {
  809. xml = xml->Parent;
  810. flg4 = -1;
  811. }
  812. }
  813. av = avs;
  814. while(av!=NULL)
  815. {
  816. ++sv->NumAllowedValues;
  817. av = av->Next;
  818. }
  819. av = avs;
  820. sv->AllowedValues = (char**)MALLOC(sv->NumAllowedValues*sizeof(char*));
  821. for(flg4=0;flg4<sv->NumAllowedValues;++flg4)
  822. {
  823. sv->AllowedValues[flg4] = av->Value;
  824. av = av->Next;
  825. }
  826. av = avs;
  827. while(av!=NULL)
  828. {
  829. avs = av->Next;
  830. FREE(av);
  831. av = avs;
  832. }
  833. }
  834. }
  835. if(xml->NameLength==17 && memcmp(xml->Name,"allowedValueRange",17)==0)
  836. {
  837. if(xml->Next->StartTag!=0)
  838. {
  839. xml = xml->Next;
  840. flg4 = 0;
  841. while(flg4==0)
  842. {
  843. if(xml->NameLength==7)
  844. {
  845. if(memcmp(xml->Name,"minimum",7)==0)
  846. {
  847. tempStringLength = ILibReadInnerXML(xml,&tempString);
  848. sv->Min = (char*)MALLOC(1+tempStringLength);
  849. memcpy(sv->Min,tempString,tempStringLength);
  850. sv->Min[tempStringLength] = '\0';
  851. }
  852. else if(memcmp(xml->Name,"maximum",7)==0)
  853. {
  854. tempStringLength = ILibReadInnerXML(xml,&tempString);
  855. sv->Max = (char*)MALLOC(1+tempStringLength);
  856. memcpy(sv->Max,tempString,tempStringLength);
  857. sv->Max[tempStringLength] = '\0';
  858. }
  859. }
  860. if(xml->NameLength==4 && memcmp(xml->Name,"step",4)==0)
  861. {
  862. tempStringLength = ILibReadInnerXML(xml,&tempString);
  863. sv->Step = (char*)MALLOC(1+tempStringLength);
  864. memcpy(sv->Step,tempString,tempStringLength);
  865. sv->Step[tempStringLength] = '\0';
  866. }
  867. if(xml->Peer!=NULL)
  868. {
  869. xml = xml->Peer;
  870. }
  871. else
  872. {
  873. xml = xml->Parent;
  874. flg4 = -1;
  875. }
  876. }
  877. }
  878. }
  879. if(xml->Peer!=NULL)
  880. {
  881. xml = xml->Peer;
  882. }
  883. else
  884. {
  885. flg3 = -1;
  886. xml = xml->Parent;
  887. }
  888. }
  889. }
  890. if(xml->Peer!=NULL)
  891. {
  892. xml = xml->Peer;
  893. }
  894. else
  895. {
  896. xml = xml->Parent;
  897. flg2 = -1;
  898. }
  899. }
  900. }
  901. }
  902. xml = xml->Peer;
  903. }
  904. ILibDestructXMLNodeList(rootXML);
  905. }
  906. void RNDExpireRequests(struct UPnPDevice *device)
  907. {
  908. struct UPnPDevice *ed = device->EmbeddedDevices;
  909. struct UPnPService *s = device->Services;
  910. while(ed!=NULL)
  911. {
  912. RNDExpireRequests(ed);
  913. ed = ed->Next;
  914. }
  915. while(s!=NULL)
  916. {
  917. ILibDeleteRequests(((struct RNDCP*)s->Parent->CP)->HTTP,s);
  918. s = s->Next;
  919. }
  920. }
  921. void RNDDeviceExpired(struct UPnPDevice *device)
  922. {
  923. printf("Device[%s] failed to re-advertise in a timely manner\r\n",device->FriendlyName);
  924. RNDExpireRequests(device);
  925. RNDSSDP_Sink(NULL, device->UDN, 0, NULL, 0,device->CP);
  926. }
  927. void RNDFinishProcessingDevice(struct RNDCP* CP, struct UPnPDevice *RootDevice)
  928. {
  929. char *RootUDN = RootDevice->UDN;
  930. int Timeout = RootDevice->CacheTime;
  931. struct UPnPDevice *RetDevice;
  932. int i=0;
  933. RootDevice->ReferenceCount = 0;
  934. RNDAttachDeviceToUDN(CP,RootDevice->UDN,RootDevice);
  935. do
  936. {
  937. RetDevice = RNDGetDevice1(RootDevice,i++);
  938. if(RetDevice!=NULL)
  939. {
  940. RNDAddUDN(CP,RetDevice->UDN);
  941. RNDAttachRootUDNToUDN(CP,RetDevice->UDN,RootUDN);
  942. if(CP->DiscoverSink!=NULL)
  943. {
  944. CP->DiscoverSink(RetDevice);
  945. }
  946. }
  947. }while(RetDevice!=NULL);
  948. RetDevice = RNDGetDeviceAtUDN(CP,RootUDN);
  949. if(RetDevice!=NULL)
  950. {
  951. ILibLifeTime_Add(CP->LifeTimeMonitor,RetDevice,Timeout,&RNDDeviceExpired,NULL);
  952. RNDRelease(RetDevice);
  953. }
  954. }
  955. void RNDSCPD_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* dv, void* sv)
  956. {
  957. struct UPnPDevice *device;
  958. struct UPnPService *service = (struct UPnPService*)sv;
  959. struct RNDCP *CP = service->Parent->CP;
  960. if(!(header==NULL || header->StatusCode!=200) && done!=0)
  961. {
  962. RNDProcessSCPD(buffer,EndPointer, service);
  963. device = service->Parent;
  964. while(device->Parent!=NULL)
  965. {
  966. device = device->Parent;
  967. }
  968. --device->SCPDLeft;
  969. if(device->SCPDLeft==0)
  970. {
  971. RNDFinishProcessingDevice(CP,device);
  972. }
  973. }
  974. else
  975. {
  976. if(done!=0 && (header==NULL || header->StatusCode!=200))
  977. {
  978. ILibDeleteRequests(CP->HTTP,dv);
  979. RNDDestructUPnPDevice(dv);
  980. }
  981. }
  982. }
  983. void RNDCalculateSCPD_FetchCount(struct UPnPDevice *device)
  984. {
  985. int count = 0;
  986. struct UPnPDevice *root;
  987. struct UPnPDevice *e_Device = device->EmbeddedDevices;
  988. struct UPnPService *s;
  989. while(e_Device!=NULL)
  990. {
  991. RNDCalculateSCPD_FetchCount(e_Device);
  992. e_Device = e_Device->Next;
  993. }
  994. s = device->Services;
  995. while(s!=NULL)
  996. {
  997. ++count;
  998. s = s->Next;
  999. }
  1000. root = device;
  1001. while(root->Parent!=NULL)
  1002. {
  1003. root = root->Parent;
  1004. }
  1005. root->SCPDLeft += count;
  1006. }
  1007. void RNDSCPD_Fetch(struct UPnPDevice *device)
  1008. {
  1009. struct UPnPDevice *e_Device = device->EmbeddedDevices;
  1010. struct UPnPService *s;
  1011. char *IP,*Path;
  1012. unsigned short Port;
  1013. struct packetheader *p;
  1014. struct sockaddr_in addr;
  1015. while(e_Device!=NULL)
  1016. {
  1017. RNDSCPD_Fetch(e_Device);
  1018. e_Device = e_Device->Next;
  1019. }
  1020. s = device->Services;
  1021. while(s!=NULL)
  1022. {
  1023. RNDParseUri(s->SCPDURL,&IP,&Port,&Path);
  1024. DEBUGSTATEMENT(printf("SCPD: %s Port: %d Path: %s\r\n",IP,Port,Path));
  1025. p = RNDBuildPacket(IP,Port,Path,"GET");
  1026. memset((char *)&addr, 0,sizeof(addr));
  1027. addr.sin_family = AF_INET;
  1028. addr.sin_addr.s_addr = inet_addr(IP);
  1029. addr.sin_port = htons(Port);
  1030. ILibAddRequest(((struct RNDCP*)device->CP)->HTTP, p,&addr, &RNDSCPD_Sink, device, s);
  1031. FREE(IP);
  1032. FREE(Path);
  1033. s = s->Next;
  1034. }
  1035. }
  1036. struct UPnPDevice* RNDProcessDeviceXML_device(struct ILibXMLNode *xml, void *v_CP,const char *BaseURL, int Timeout, int RecvAddr)
  1037. {
  1038. struct ILibXMLNode *tempNode;
  1039. int flg,flg2;
  1040. char *tempString;
  1041. int tempStringLength;
  1042. struct parser_result *tpr;
  1043. char* ServiceType = NULL;
  1044. int ServiceTypeLength = 0;
  1045. char* SCPDURL = NULL;
  1046. int SCPDURLLength = 0;
  1047. char* EventSubURL = NULL;
  1048. int EventSubURLLength = 0;
  1049. char* ControlURL = NULL;
  1050. int ControlURLLength = 0;
  1051. struct UPnPDevice *tempDevice;
  1052. struct UPnPService *TempService;
  1053. struct UPnPDevice *device = (struct UPnPDevice*)MALLOC(sizeof(struct UPnPDevice));
  1054. device->CP = v_CP;
  1055. device->CacheTime = Timeout;
  1056. device->Tag = NULL;
  1057. device->InterfaceToHost = (char*)MALLOC(16);
  1058. sprintf(device->InterfaceToHost,"%d.%d.%d.%d",(RecvAddr&0xFF),((RecvAddr>>8)&0xFF),((RecvAddr>>16)&0xFF),((RecvAddr>>24)&0xFF));
  1059. device->DeviceType = NULL;
  1060. device->UDN = NULL;
  1061. device->LocationURL = NULL;
  1062. device->FriendlyName = NULL;
  1063. device->Parent = NULL;
  1064. device->EmbeddedDevices = NULL;
  1065. device->Services = NULL;
  1066. device->Next = NULL;
  1067. device->LocationURL = NULL;
  1068. device->PresentationURL = NULL;
  1069. device->FriendlyName = NULL;
  1070. device->ManufacturerName = NULL;
  1071. device->ManufacturerURL = NULL;
  1072. device->ModelName = NULL;
  1073. device->ModelDescription = NULL;
  1074. device->ModelNumber = NULL;
  1075. device->ModelURL = NULL;
  1076. device->SCPDLeft = 0;
  1077. xml = xml->Next;
  1078. while(xml!=NULL)
  1079. {
  1080. if(xml->NameLength==10 && memcmp(xml->Name,"deviceList",10)==0)
  1081. {
  1082. if(xml->Next->StartTag!=0)
  1083. {
  1084. xml = xml->Next;
  1085. flg2 = 0;
  1086. while(flg2==0)
  1087. {
  1088. if(xml->NameLength==6 && memcmp(xml->Name,"device",6)==0)
  1089. {
  1090. tempDevice = RNDProcessDeviceXML_device(xml,v_CP,BaseURL,Timeout, RecvAddr);
  1091. tempDevice->Parent = device;
  1092. tempDevice->Next = device->EmbeddedDevices;
  1093. device->EmbeddedDevices = tempDevice;
  1094. }
  1095. if(xml->Peer==NULL)
  1096. {
  1097. flg2 = 1;
  1098. xml = xml->Parent;
  1099. }
  1100. else
  1101. {
  1102. xml = xml->Peer;
  1103. }
  1104. }
  1105. }
  1106. } else
  1107. if(xml->NameLength==3 && memcmp(xml->Name,"UDN",3)==0)
  1108. {
  1109. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1110. if(tempStringLength>5)
  1111. {
  1112. if(memcmp(tempString,"uuid:",5)==0)
  1113. {
  1114. tempString += 5;
  1115. tempStringLength -= 5;
  1116. }
  1117. device->UDN = (char*)MALLOC(tempStringLength+1);
  1118. memcpy(device->UDN,tempString,tempStringLength);
  1119. device->UDN[tempStringLength] = '\0';
  1120. }
  1121. } else
  1122. if(xml->NameLength==10 && memcmp(xml->Name,"deviceType",10) == 0)
  1123. {
  1124. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1125. device->DeviceType = (char*)MALLOC(tempStringLength+1);
  1126. memcpy(device->DeviceType,tempString,tempStringLength);
  1127. device->DeviceType[tempStringLength] = '\0';
  1128. } else
  1129. if(xml->NameLength==12 && memcmp(xml->Name,"friendlyName",12) == 0)
  1130. {
  1131. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1132. device->FriendlyName = (char*)MALLOC(1+tempStringLength);
  1133. memcpy(device->FriendlyName,tempString,tempStringLength);
  1134. device->FriendlyName[tempStringLength] = '\0';
  1135. } else
  1136. if(xml->NameLength==12 && memcmp(xml->Name,"manufacturer",12) == 0)
  1137. {
  1138. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1139. device->ManufacturerName = (char*)MALLOC(1+tempStringLength);
  1140. memcpy(device->ManufacturerName,tempString,tempStringLength);
  1141. device->ManufacturerName[tempStringLength] = '\0';
  1142. } else
  1143. if(xml->NameLength==15 && memcmp(xml->Name,"manufacturerURL",15) == 0)
  1144. {
  1145. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1146. device->ManufacturerURL = (char*)MALLOC(1+tempStringLength);
  1147. memcpy(device->ManufacturerURL,tempString,tempStringLength);
  1148. device->ManufacturerURL[tempStringLength] = '\0';
  1149. } else
  1150. if(xml->NameLength==16 && memcmp(xml->Name,"modelDescription",16) == 0)
  1151. {
  1152. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1153. device->ModelDescription = (char*)MALLOC(1+tempStringLength);
  1154. memcpy(device->ModelDescription,tempString,tempStringLength);
  1155. device->ModelDescription[tempStringLength] = '\0';
  1156. } else
  1157. if(xml->NameLength==9 && memcmp(xml->Name,"modelName",9) == 0)
  1158. {
  1159. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1160. device->ModelName = (char*)MALLOC(1+tempStringLength);
  1161. memcpy(device->ModelName,tempString,tempStringLength);
  1162. device->ModelName[tempStringLength] = '\0';
  1163. } else
  1164. if(xml->NameLength==11 && memcmp(xml->Name,"modelNumber",11) == 0)
  1165. {
  1166. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1167. device->ModelNumber = (char*)MALLOC(1+tempStringLength);
  1168. memcpy(device->ModelNumber,tempString,tempStringLength);
  1169. device->ModelNumber[tempStringLength] = '\0';
  1170. } else
  1171. if(xml->NameLength==8 && memcmp(xml->Name,"modelURL",8) == 0)
  1172. {
  1173. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1174. device->ModelURL = (char*)MALLOC(1+tempStringLength);
  1175. memcpy(device->ModelURL,tempString,tempStringLength);
  1176. device->ModelURL[tempStringLength] = '\0';
  1177. } else
  1178. if(xml->NameLength==15 && memcmp(xml->Name,"presentationURL",15) == 0)
  1179. {
  1180. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1181. tempString[tempStringLength] = 0;
  1182. tpr = ILibParseString(tempString,0,tempStringLength,"://",3);
  1183. if(tpr->NumResults==1)
  1184. {
  1185. /* RelativeURL */
  1186. if(tempString[0]=='/')
  1187. {
  1188. device->PresentationURL = (char*)MALLOC(1+strlen(BaseURL)+tempStringLength);
  1189. memcpy(device->PresentationURL,BaseURL,strlen(BaseURL));
  1190. strcpy(device->PresentationURL+strlen(BaseURL),tempString+1);
  1191. }
  1192. else
  1193. {
  1194. device->PresentationURL = (char*)MALLOC(2+strlen(BaseURL)+tempStringLength);
  1195. memcpy(device->PresentationURL,BaseURL,strlen(BaseURL));
  1196. strcpy(device->PresentationURL+strlen(BaseURL),tempString);
  1197. }
  1198. }
  1199. else
  1200. {
  1201. /* AbsoluteURL */
  1202. device->PresentationURL = (char*)MALLOC(1+tempStringLength);
  1203. memcpy(device->PresentationURL,tempString,tempStringLength);
  1204. device->PresentationURL[tempStringLength] = '\0';
  1205. }
  1206. ILibDestructParserResults(tpr);
  1207. } else
  1208. if(xml->NameLength==11 && memcmp(xml->Name,"serviceList",11)==0)
  1209. {
  1210. xml = xml->Next;
  1211. tempNode = xml;
  1212. while(xml!=NULL)
  1213. {
  1214. if(xml->NameLength==7 && memcmp(xml->Name,"service",7)==0)
  1215. {
  1216. ServiceType = NULL;
  1217. ServiceTypeLength = 0;
  1218. SCPDURL = NULL;
  1219. SCPDURLLength = 0;
  1220. EventSubURL = NULL;
  1221. EventSubURLLength = 0;
  1222. ControlURL = NULL;
  1223. ControlURLLength = 0;
  1224. xml = xml->Next;
  1225. flg = 0;
  1226. while(flg==0)
  1227. {
  1228. if(xml->NameLength==11 && memcmp(xml->Name,"serviceType",11)==0)
  1229. {
  1230. ServiceTypeLength = ILibReadInnerXML(xml,&ServiceType);
  1231. } else
  1232. if(xml->NameLength==7 && memcmp(xml->Name,"SCPDURL",7) == 0)
  1233. {
  1234. SCPDURLLength = ILibReadInnerXML(xml,&SCPDURL);
  1235. } else
  1236. if(xml->NameLength==10 && memcmp(xml->Name,"controlURL",10) == 0)
  1237. {
  1238. ControlURLLength = ILibReadInnerXML(xml,&ControlURL);
  1239. } else
  1240. if(xml->NameLength==11 && memcmp(xml->Name,"eventSubURL",11) == 0)
  1241. {
  1242. EventSubURLLength = ILibReadInnerXML(xml,&EventSubURL);
  1243. }
  1244. if(xml->Peer!=NULL)
  1245. {
  1246. xml = xml->Peer;
  1247. }
  1248. else
  1249. {
  1250. flg = 1;
  1251. xml = xml->Parent;
  1252. }
  1253. }
  1254. /* Finished Parsing the ServiceSection, build the Service */
  1255. ServiceType[ServiceTypeLength] = '\0';
  1256. SCPDURL[SCPDURLLength] = '\0';
  1257. EventSubURL[EventSubURLLength] = '\0';
  1258. ControlURL[ControlURLLength] = '\0';
  1259. TempService = (struct UPnPService*)MALLOC(sizeof(struct UPnPService));
  1260. TempService->SubscriptionID = NULL;
  1261. TempService->ServiceId = NULL;
  1262. TempService->Actions = NULL;
  1263. TempService->Variables = NULL;
  1264. TempService->Next = NULL;
  1265. TempService->Parent = device;
  1266. if(EventSubURLLength>=7 && memcmp(EventSubURL,"http://",6)==0)
  1267. {
  1268. /* Explicit */
  1269. TempService->SubscriptionURL = (char*)MALLOC(EventSubURLLength+1);
  1270. memcpy(TempService->SubscriptionURL,EventSubURL,EventSubURLLength);
  1271. TempService->SubscriptionURL[EventSubURLLength] = '\0';
  1272. }
  1273. else
  1274. {
  1275. /* Relative */
  1276. if(memcmp(EventSubURL,"/",1)!=0)
  1277. {
  1278. TempService->SubscriptionURL = (char*)MALLOC(EventSubURLLength+(int)strlen(BaseURL)+1);
  1279. memcpy(TempService->SubscriptionURL,BaseURL,(int)strlen(BaseURL));
  1280. memcpy(TempService->SubscriptionURL+(int)strlen(BaseURL),EventSubURL,EventSubURLLength);
  1281. TempService->SubscriptionURL[EventSubURLLength+(int)strlen(BaseURL)] = '\0';
  1282. }
  1283. else
  1284. {
  1285. TempService->SubscriptionURL = (char*)MALLOC(EventSubURLLength+(int)strlen(BaseURL)+1);
  1286. memcpy(TempService->SubscriptionURL,BaseURL,(int)strlen(BaseURL));
  1287. memcpy(TempService->SubscriptionURL+(int)strlen(BaseURL),EventSubURL+1,EventSubURLLength-1);
  1288. TempService->SubscriptionURL[EventSubURLLength+(int)strlen(BaseURL)-1] = '\0';
  1289. }
  1290. }
  1291. if(ControlURLLength>=7 && memcmp(ControlURL,"http://",6)==0)
  1292. {
  1293. /* Explicit */
  1294. TempService->ControlURL = (char*)MALLOC(ControlURLLength+1);
  1295. memcpy(TempService->ControlURL,ControlURL,ControlURLLength);
  1296. TempService->ControlURL[ControlURLLength] = '\0';
  1297. }
  1298. else
  1299. {
  1300. /* Relative */
  1301. if(memcmp(ControlURL,"/",1)!=0)
  1302. {
  1303. TempService->ControlURL = (char*)MALLOC(ControlURLLength+(int)strlen(BaseURL)+1);
  1304. memcpy(TempService->ControlURL,BaseURL,(int)strlen(BaseURL));
  1305. memcpy(TempService->ControlURL+(int)strlen(BaseURL),ControlURL,ControlURLLength);
  1306. TempService->ControlURL[ControlURLLength+(int)strlen(BaseURL)] = '\0';
  1307. }
  1308. else
  1309. {
  1310. TempService->ControlURL = (char*)MALLOC(ControlURLLength+(int)strlen(BaseURL)+1);
  1311. memcpy(TempService->ControlURL,BaseURL,(int)strlen(BaseURL));
  1312. memcpy(TempService->ControlURL+(int)strlen(BaseURL),ControlURL+1,ControlURLLength-1);
  1313. TempService->ControlURL[ControlURLLength+(int)strlen(BaseURL)-1] = '\0';
  1314. }
  1315. }
  1316. if(SCPDURLLength>=7 && memcmp(SCPDURL,"http://",6)==0)
  1317. {
  1318. /* Explicit */
  1319. TempService->SCPDURL = (char*)MALLOC(SCPDURLLength+1);
  1320. memcpy(TempService->SCPDURL,SCPDURL,SCPDURLLength);
  1321. TempService->SCPDURL[SCPDURLLength] = '\0';
  1322. }
  1323. else
  1324. {
  1325. /* Relative */
  1326. if(memcmp(SCPDURL,"/",1)!=0)
  1327. {
  1328. TempService->SCPDURL = (char*)MALLOC(SCPDURLLength+(int)strlen(BaseURL)+1);
  1329. memcpy(TempService->SCPDURL,BaseURL,(int)strlen(BaseURL));
  1330. memcpy(TempService->SCPDURL+(int)strlen(BaseURL),SCPDURL,SCPDURLLength);
  1331. TempService->SCPDURL[SCPDURLLength+(int)strlen(BaseURL)] = '\0';
  1332. }
  1333. else
  1334. {
  1335. TempService->SCPDURL = (char*)MALLOC(SCPDURLLength+(int)strlen(BaseURL)+1);
  1336. memcpy(TempService->SCPDURL,BaseURL,(int)strlen(BaseURL));
  1337. memcpy(TempService->SCPDURL+(int)strlen(BaseURL),SCPDURL+1,SCPDURLLength-1);
  1338. TempService->SCPDURL[SCPDURLLength+(int)strlen(BaseURL)-1] = '\0';
  1339. }
  1340. }
  1341. TempService->ServiceType = (char*)MALLOC(ServiceTypeLength+1);
  1342. sprintf(TempService->ServiceType,ServiceType,ServiceTypeLength);
  1343. TempService->Next = device->Services;
  1344. device->Services = TempService;
  1345. DEBUGSTATEMENT(printf("ServiceType: %s\r\nSCPDURL: %s\r\nEventSubURL: %s\r\nControl URL: %s\r\n",ServiceType,SCPDURL,EventSubURL,ControlURL));
  1346. }
  1347. xml = xml->Peer;
  1348. }
  1349. xml = tempNode;
  1350. } // End of ServiceList
  1351. xml = xml->Peer;
  1352. } // End of While
  1353. return(device);
  1354. }
  1355. void RNDProcessDeviceXML(void *v_CP,char* buffer, int BufferSize, char* LocationURL, int RecvAddr, int Timeout)
  1356. {
  1357. struct UPnPDevice *RootDevice = NULL;
  1358. char* IP;
  1359. unsigned short Port;
  1360. char* Path;
  1361. char* BaseURL = NULL;
  1362. struct ILibXMLNode *rootXML;
  1363. struct ILibXMLNode *xml;
  1364. char* tempString;
  1365. int tempStringLength;
  1366. rootXML = ILibParseXML(buffer,0,BufferSize);
  1367. ILibProcessXMLNodeList(rootXML);
  1368. xml = rootXML;
  1369. xml = xml->Next;
  1370. while(xml!=NULL)
  1371. {
  1372. if(xml->NameLength==7 && memcmp(xml->Name,"URLBase",7)==0)
  1373. {
  1374. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1375. if(tempString[tempStringLength-1]!='/')
  1376. {
  1377. BaseURL = (char*)MALLOC(2+tempStringLength);
  1378. memcpy(BaseURL,tempString,tempStringLength);
  1379. BaseURL[tempStringLength] = '/';
  1380. BaseURL[tempStringLength+1] = '\0';
  1381. }
  1382. else
  1383. {
  1384. BaseURL = (char*)MALLOC(1+tempStringLength);
  1385. memcpy(BaseURL,tempString,tempStringLength);
  1386. BaseURL[tempStringLength] = '\0';
  1387. }
  1388. break;
  1389. }
  1390. xml = xml->Peer;
  1391. }
  1392. if(BaseURL==NULL)
  1393. {
  1394. RNDParseUri(LocationURL,&IP,&Port,&Path);
  1395. BaseURL = (char*)MALLOC(18+(int)strlen(IP));
  1396. sprintf(BaseURL,"http://%s:%d/",IP,Port);
  1397. FREE(IP);
  1398. FREE(Path);
  1399. }
  1400. DEBUGSTATEMENT(printf("BaseURL: %s\r\n",BaseURL));
  1401. xml = rootXML;
  1402. xml = xml->Next;
  1403. while(xml->NameLength!=6 && memcmp(xml->Name,"device",6)!=0 && xml!=NULL)
  1404. {
  1405. xml = xml->Peer;
  1406. }
  1407. if(xml==NULL)
  1408. {
  1409. /* Error */
  1410. ILibDestructXMLNodeList(rootXML);
  1411. return;
  1412. }
  1413. RootDevice = RNDProcessDeviceXML_device(xml,v_CP,BaseURL,Timeout,RecvAddr);
  1414. FREE(BaseURL);
  1415. ILibDestructXMLNodeList(rootXML);
  1416. /* Add Root Device to UDNTable */
  1417. RNDAddUDN(v_CP,RootDevice->UDN);
  1418. /* Save reference to LocationURL in the RootDevice */
  1419. RootDevice->LocationURL = (char*)MALLOC(strlen(LocationURL)+1);
  1420. sprintf(RootDevice->LocationURL,"%s",LocationURL);
  1421. /* Trim Object Structure */
  1422. RNDProcessDevice(RootDevice);
  1423. RootDevice->SCPDLeft = 0;
  1424. RNDCalculateSCPD_FetchCount(RootDevice);
  1425. if(RootDevice->SCPDLeft==0)
  1426. {
  1427. RNDFinishProcessingDevice(v_CP,RootDevice);
  1428. }
  1429. else
  1430. {
  1431. RNDSCPD_Fetch(RootDevice);
  1432. }
  1433. }
  1434. void RNDHTTP_Sink_DeviceDescription(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* user, void* cp)
  1435. {
  1436. struct CustomUserData *customData = (struct CustomUserData*)user;
  1437. if(header!=NULL && done!=0)
  1438. {
  1439. RNDProcessDeviceXML(cp,buffer,EndPointer-(*p_BeginPointer),customData->buffer,header->ReceivingAddress,customData->Timeout);
  1440. }
  1441. if(done!=0)
  1442. {
  1443. FREE(customData->buffer);
  1444. FREE(user);
  1445. }
  1446. }
  1447. void RND_FlushRequest(struct UPnPDevice *device)
  1448. {
  1449. struct UPnPDevice *ed = device->EmbeddedDevices;
  1450. struct UPnPService *s = device->Services;
  1451. while(ed!=NULL)
  1452. {
  1453. RND_FlushRequest(ed);
  1454. ed = ed->Next;
  1455. }
  1456. while(s!=NULL)
  1457. {
  1458. ILibDeleteRequests(((struct RNDCP*)device->CP)->HTTP, s);
  1459. s = s->Next;
  1460. }
  1461. }
  1462. void RNDSSDP_Sink(void *sender, char* UDN, int Alive, char* LocationURL, int Timeout,void *cp)
  1463. {
  1464. struct CustomUserData *customData;
  1465. char* buffer;
  1466. char* IP;
  1467. unsigned short Port;
  1468. char* Path;
  1469. struct packetheader *p;
  1470. struct sockaddr_in addr;
  1471. struct UPnPDevice *device,*tempDevice;
  1472. int i=0;
  1473. if(Alive!=0)
  1474. {
  1475. /* Hello */
  1476. DEBUGSTATEMENT(printf("MediaRenderer Hello\r\n"));
  1477. DEBUGSTATEMENT(printf("LocationURL: %s\r\n",LocationURL));
  1478. if(RNDHasUDN(cp,LocationURL)==0)
  1479. {
  1480. RNDAddUDN(cp,LocationURL);
  1481. if(RNDHasUDN(cp,UDN)==0)
  1482. {
  1483. RNDAddUDN(cp,UDN);
  1484. RNDParseUri(LocationURL,&IP,&Port,&Path);
  1485. DEBUGSTATEMENT(printf("IP: %s Port: %d Path: %s\r\n",IP,Port,Path));
  1486. p = RNDBuildPacket(IP,Port,Path,"GET");
  1487. memset((char *)&addr, 0,sizeof(addr));
  1488. addr.sin_family = AF_INET;
  1489. addr.sin_addr.s_addr = inet_addr(IP);
  1490. addr.sin_port = htons(Port);
  1491. buffer = (char*)MALLOC((int)strlen(LocationURL)+1);
  1492. strcpy(buffer,LocationURL);
  1493. customData = (struct CustomUserData*)MALLOC(sizeof(struct CustomUserData));
  1494. customData->Timeout = Timeout;
  1495. customData->buffer = buffer;
  1496. ILibAddRequest(((struct RNDCP*)cp)->HTTP, p,&addr, &RNDHTTP_Sink_DeviceDescription, customData, cp);
  1497. FREE(IP);
  1498. FREE(Path);
  1499. }
  1500. }
  1501. else
  1502. {
  1503. // Periodic Notify Packets
  1504. if(RNDHasUDN(cp,UDN)!=0)
  1505. {
  1506. buffer = RNDGetRootUDNAtUDN(cp,UDN);
  1507. if(buffer!=NULL)
  1508. {
  1509. device = RNDGetDeviceAtUDN(cp,buffer);
  1510. if(device!=NULL)
  1511. {
  1512. //Extend LifetimeMonitor duration
  1513. ILibLifeTime_Remove(((struct RNDCP*)cp)->LifeTimeMonitor,device);
  1514. ILibLifeTime_Add(((struct RNDCP*)cp)->LifeTimeMonitor,device,Timeout,&RNDDeviceExpired,NULL);
  1515. RNDRelease(device);
  1516. }
  1517. }
  1518. }
  1519. }
  1520. }
  1521. else
  1522. {
  1523. /* Bye Bye */
  1524. DEBUGSTATEMENT(printf("MediaRenderer ByeBye\r\n"));
  1525. device = RNDGetDeviceAtUDN(cp,UDN);
  1526. if(device!=NULL)
  1527. {
  1528. ILibLifeTime_Remove(((struct RNDCP*)cp)->LifeTimeMonitor,device);
  1529. RNDRemoveUDN(cp,device->LocationURL);
  1530. do
  1531. {
  1532. tempDevice = RNDGetDevice1(device,i++);
  1533. if(tempDevice!=NULL)
  1534. {
  1535. RND_FlushRequest(tempDevice);
  1536. if(((struct RNDCP*)cp)->RemoveSink!=NULL)
  1537. {
  1538. ((struct RNDCP*)cp)->RemoveSink(tempDevice);
  1539. }
  1540. }
  1541. } while(tempDevice!=NULL);
  1542. RNDRelease(device);
  1543. RNDRemoveUDN(cp,UDN);
  1544. }
  1545. }
  1546. }
  1547. void RNDConnectionManager_EventSink(char* buffer, int bufferlength, struct UPnPService *service)
  1548. {
  1549. struct ILibXMLNode *xml,*rootXML;
  1550. char *tempString;
  1551. int tempStringLength;
  1552. int flg,flg2;
  1553. char* SourceProtocolInfo = 0;
  1554. char* SinkProtocolInfo = 0;
  1555. char* CurrentConnectionIDs = 0;
  1556. /* Parse SOAP */
  1557. rootXML = xml = ILibParseXML(buffer,0,bufferlength);
  1558. ILibProcessXMLNodeList(xml);
  1559. while(xml!=NULL)
  1560. {
  1561. if(xml->NameLength==11 && memcmp(xml->Name,"propertyset",11)==0)
  1562. {
  1563. if(xml->Next->StartTag!=0)
  1564. {
  1565. flg = 0;
  1566. xml = xml->Next;
  1567. while(flg==0)
  1568. {
  1569. if(xml->NameLength==8 && memcmp(xml->Name,"property",8)==0)
  1570. {
  1571. xml = xml->Next;
  1572. flg2 = 0;
  1573. while(flg2==0)
  1574. {
  1575. if(xml->NameLength==18 && memcmp(xml->Name,"SourceProtocolInfo",18) == 0)
  1576. {
  1577. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1578. tempString[tempStringLength] = '\0';
  1579. SourceProtocolInfo = tempString;
  1580. if(RNDEventCallback_ConnectionManager_SourceProtocolInfo != NULL)
  1581. {
  1582. RNDEventCallback_ConnectionManager_SourceProtocolInfo(service,SourceProtocolInfo);
  1583. }
  1584. }
  1585. if(xml->NameLength==16 && memcmp(xml->Name,"SinkProtocolInfo",16) == 0)
  1586. {
  1587. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1588. tempString[tempStringLength] = '\0';
  1589. SinkProtocolInfo = tempString;
  1590. if(RNDEventCallback_ConnectionManager_SinkProtocolInfo != NULL)
  1591. {
  1592. RNDEventCallback_ConnectionManager_SinkProtocolInfo(service,SinkProtocolInfo);
  1593. }
  1594. }
  1595. if(xml->NameLength==20 && memcmp(xml->Name,"CurrentConnectionIDs",20) == 0)
  1596. {
  1597. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1598. tempString[tempStringLength] = '\0';
  1599. CurrentConnectionIDs = tempString;
  1600. if(RNDEventCallback_ConnectionManager_CurrentConnectionIDs != NULL)
  1601. {
  1602. RNDEventCallback_ConnectionManager_CurrentConnectionIDs(service,CurrentConnectionIDs);
  1603. }
  1604. }
  1605. if(xml->Peer!=NULL)
  1606. {
  1607. xml = xml->Peer;
  1608. }
  1609. else
  1610. {
  1611. flg2 = -1;
  1612. xml = xml->Parent;
  1613. }
  1614. }
  1615. }
  1616. if(xml->Peer!=NULL)
  1617. {
  1618. xml = xml->Peer;
  1619. }
  1620. else
  1621. {
  1622. flg = -1;
  1623. xml = xml->Parent;
  1624. }
  1625. }
  1626. }
  1627. }
  1628. xml = xml->Peer;
  1629. }
  1630. ILibDestructXMLNodeList(rootXML);
  1631. }
  1632. void RNDAVTransport_EventSink(char* buffer, int bufferlength, struct UPnPService *service)
  1633. {
  1634. struct ILibXMLNode *xml,*rootXML;
  1635. char *tempString;
  1636. int tempStringLength;
  1637. int flg,flg2;
  1638. char* LastChange = 0;
  1639. /* Parse SOAP */
  1640. rootXML = xml = ILibParseXML(buffer,0,bufferlength);
  1641. ILibProcessXMLNodeList(xml);
  1642. while(xml!=NULL)
  1643. {
  1644. if(xml->NameLength==11 && memcmp(xml->Name,"propertyset",11)==0)
  1645. {
  1646. if(xml->Next->StartTag!=0)
  1647. {
  1648. flg = 0;
  1649. xml = xml->Next;
  1650. while(flg==0)
  1651. {
  1652. if(xml->NameLength==8 && memcmp(xml->Name,"property",8)==0)
  1653. {
  1654. xml = xml->Next;
  1655. flg2 = 0;
  1656. while(flg2==0)
  1657. {
  1658. if(xml->NameLength==10 && memcmp(xml->Name,"LastChange",10) == 0)
  1659. {
  1660. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1661. tempString[tempStringLength] = '\0';
  1662. LastChange = tempString;
  1663. if(RNDEventCallback_AVTransport_LastChange != NULL)
  1664. {
  1665. RNDEventCallback_AVTransport_LastChange(service,LastChange);
  1666. }
  1667. }
  1668. if(xml->Peer!=NULL)
  1669. {
  1670. xml = xml->Peer;
  1671. }
  1672. else
  1673. {
  1674. flg2 = -1;
  1675. xml = xml->Parent;
  1676. }
  1677. }
  1678. }
  1679. if(xml->Peer!=NULL)
  1680. {
  1681. xml = xml->Peer;
  1682. }
  1683. else
  1684. {
  1685. flg = -1;
  1686. xml = xml->Parent;
  1687. }
  1688. }
  1689. }
  1690. }
  1691. xml = xml->Peer;
  1692. }
  1693. ILibDestructXMLNodeList(rootXML);
  1694. }
  1695. void RNDRenderingControl_EventSink(char* buffer, int bufferlength, struct UPnPService *service)
  1696. {
  1697. struct ILibXMLNode *xml,*rootXML;
  1698. char *tempString;
  1699. int tempStringLength;
  1700. int flg,flg2;
  1701. char* LastChange = 0;
  1702. /* Parse SOAP */
  1703. rootXML = xml = ILibParseXML(buffer,0,bufferlength);
  1704. ILibProcessXMLNodeList(xml);
  1705. while(xml!=NULL)
  1706. {
  1707. if(xml->NameLength==11 && memcmp(xml->Name,"propertyset",11)==0)
  1708. {
  1709. if(xml->Next->StartTag!=0)
  1710. {
  1711. flg = 0;
  1712. xml = xml->Next;
  1713. while(flg==0)
  1714. {
  1715. if(xml->NameLength==8 && memcmp(xml->Name,"property",8)==0)
  1716. {
  1717. xml = xml->Next;
  1718. flg2 = 0;
  1719. while(flg2==0)
  1720. {
  1721. if(xml->NameLength==10 && memcmp(xml->Name,"LastChange",10) == 0)
  1722. {
  1723. tempStringLength = ILibReadInnerXML(xml,&tempString);
  1724. tempString[tempStringLength] = '\0';
  1725. LastChange = tempString;
  1726. if(RNDEventCallback_RenderingControl_LastChange != NULL)
  1727. {
  1728. RNDEventCallback_RenderingControl_LastChange(service,LastChange);
  1729. }
  1730. }
  1731. if(xml->Peer!=NULL)
  1732. {
  1733. xml = xml->Peer;
  1734. }
  1735. else
  1736. {
  1737. flg2 = -1;
  1738. xml = xml->Parent;
  1739. }
  1740. }
  1741. }
  1742. if(xml->Peer!=NULL)
  1743. {
  1744. xml = xml->Peer;
  1745. }
  1746. else
  1747. {
  1748. flg = -1;
  1749. xml = xml->Parent;
  1750. }
  1751. }
  1752. }
  1753. }
  1754. xml = xml->Peer;
  1755. }
  1756. ILibDestructXMLNodeList(rootXML);
  1757. }
  1758. void RNDOnEventSink(void *ReaderObject, struct packetheader *header, char* buffer, int *BeginPointer, int BufferSize, int done, void* user)
  1759. {
  1760. int type_length;
  1761. char* sid = NULL;
  1762. void* value = NULL;
  1763. struct UPnPService *service = NULL;
  1764. struct packetheader_field_node *field = NULL;
  1765. struct packetheader *resp;
  1766. if(done!=0)
  1767. {
  1768. resp = ILibCreateEmptyPacket();
  1769. ILibAddHeaderLine(resp,"Server",6,"POSIX, UPnP/1.0, Intel MicroStack/1.0.1189",42);
  1770. field = header->FirstField;
  1771. while(field!=NULL)
  1772. {
  1773. if(field->FieldLength==3)
  1774. {
  1775. if(strncasecmp(field->Field,"SID",3)==0)
  1776. {
  1777. sid = (char*)MALLOC(field->FieldDataLength+1);
  1778. sprintf(sid,"%s",field->FieldData);
  1779. value = ILibGetEntry(((struct RNDCP*)user)->SIDTable,field->FieldData,field->FieldDataLength);
  1780. break;
  1781. }
  1782. }
  1783. field = field->NextField;
  1784. }
  1785. if(value==NULL)
  1786. {
  1787. /* Not a valid SID */
  1788. ILibSetStatusCode(resp,412,"Failed",6);
  1789. if(sid!=NULL) {FREE(sid);}
  1790. }
  1791. else
  1792. {
  1793. ILibSetStatusCode(resp,200,"OK",2);
  1794. service = (struct UPnPService*)value;
  1795. type_length = (int)strlen(service->ServiceType);
  1796. if(type_length>47 && strncmp("urn:schemas-upnp-org:service:ConnectionManager:",service->ServiceType,47)==0)
  1797. {
  1798. RNDConnectionManager_EventSink(buffer, BufferSize, service);
  1799. }
  1800. else
  1801. if(type_length>41 && strncmp("urn:schemas-upnp-org:service:AVTransport:",service->ServiceType,41)==0)
  1802. {
  1803. RNDAVTransport_EventSink(buffer, BufferSize, service);
  1804. }
  1805. else
  1806. if(type_length>46 && strncmp("urn:schemas-upnp-org:service:RenderingControl:",service->ServiceType,46)==0)
  1807. {
  1808. RNDRenderingControl_EventSink(buffer, BufferSize, service);
  1809. }
  1810. }
  1811. ILibMiniWebServerSend(ReaderObject,resp);
  1812. ILibDestructPacket(resp);
  1813. ILibMiniWebServerCloseSession(ReaderObject);
  1814. }
  1815. }
  1816. void RNDOnSubscribeSink(void *ReaderObject, struct packetheader *header, char* buffer, int *BeginPointer, int BufferSize, int done, void* user, void *vcp)
  1817. {
  1818. struct UPnPService *s;
  1819. struct packetheader_field_node *field;
  1820. struct parser_result *p;
  1821. struct RNDCP *cp = (struct RNDCP*)vcp;
  1822. if(done!=0)
  1823. {
  1824. s = (struct UPnPService*)user;
  1825. if(header!=NULL)
  1826. {
  1827. if(header->StatusCode==200)
  1828. {
  1829. /* Successful */
  1830. field = header->FirstField;
  1831. while(field!=NULL)
  1832. {
  1833. if(field->FieldLength==3 && strncasecmp(field->Field,"SID",3)==0)
  1834. {
  1835. s->SubscriptionID = (char*)MALLOC(1+field->FieldDataLength);
  1836. strcpy(s->SubscriptionID,field->FieldData);
  1837. ILibAddEntry(cp->SIDTable,field->FieldData,field->FieldDataLength,s);
  1838. } else
  1839. if(field->FieldLength==7 && strncasecmp(field->Field,"TIMEOUT",7)==0)
  1840. {
  1841. p = ILibParseString(field->FieldData,0,field->FieldDataLength,"-",1);
  1842. p->LastResult->data[p->LastResult->datalength] = '\0';
  1843. RNDAddRef(s->Parent);
  1844. ILibLifeTime_Add(cp->LifeTimeMonitor,s,atoi(p->LastResult->data)/2,&RNDRenew,NULL);
  1845. ILibDestructParserResults(p);
  1846. }
  1847. field = field->NextField;
  1848. }
  1849. }
  1850. }
  1851. RNDRelease(s->Parent);
  1852. }
  1853. }
  1854. void RNDRenew(void *state)
  1855. {
  1856. struct UPnPService *service = (struct UPnPService*)state;
  1857. char *IP;
  1858. char *Path;
  1859. unsigned short Port;
  1860. struct packetheader *p;
  1861. char* TempString;
  1862. struct sockaddr_in destaddr;
  1863. RNDParseUri(service->SubscriptionURL,&IP,&Port,&Path);
  1864. p = ILibCreateEmptyPacket();
  1865. ILibSetDirective(p,"SUBSCRIBE",9,Path,(int)strlen(Path));
  1866. TempString = (char*)MALLOC((int)strlen(IP)+7);
  1867. sprintf(TempString,"%s:%d",IP,Port);
  1868. ILibAddHeaderLine(p,"HOST",4,TempString,(int)strlen(TempString));
  1869. FREE(TempString);
  1870. ILibAddHeaderLine(p,"SID",3,service->SubscriptionID,(int)strlen(service->SubscriptionID));
  1871. ILibAddHeaderLine(p,"TIMEOUT",7,"Second-180",10);
  1872. ILibAddHeaderLine(p,"User-Agent",10,"POSIX, UPnP/1.0, Intel MicroStack/1.0.1189",42);
  1873. memset((char *)&destaddr, 0,sizeof(destaddr));
  1874. destaddr.sin_family = AF_INET;
  1875. destaddr.sin_addr.s_addr = inet_addr(IP);
  1876. destaddr.sin_port = htons(Port);
  1877. ILibAddRequest(((struct RNDCP*)service->Parent->CP)->HTTP, p,&destaddr, &RNDOnSubscribeSink, (void*)service, service->Parent->CP);
  1878. FREE(IP);
  1879. FREE(Path);
  1880. }
  1881. struct UPnPDevice* RNDGetDevice(struct UPnPDevice *device, char* DeviceType, int number)
  1882. {
  1883. int counter = 0;
  1884. device = device->EmbeddedDevices;
  1885. while(device != NULL)
  1886. {
  1887. if(strlen(device->DeviceType)>=strlen(DeviceType))
  1888. {
  1889. if(memcmp(device->DeviceType,DeviceType,strlen(DeviceType))==0)
  1890. {
  1891. if(number == (++counter)) return(device);
  1892. }
  1893. }
  1894. device = device->Next;
  1895. }
  1896. return(NULL);
  1897. }
  1898. int RNDHasAction(struct UPnPService *s, char* action)
  1899. {
  1900. struct UPnPAction *a = s->Actions;
  1901. while(a!=NULL)
  1902. {
  1903. if(strcmp(action,a->Name)==0) return(-1);
  1904. a = a->Next;
  1905. }
  1906. return(0);
  1907. }
  1908. void RNDStopCP(void *v_CP)
  1909. {
  1910. int i;
  1911. struct UPnPDevice *RetDevice;
  1912. struct UDNMapNode *mn,*mn2;
  1913. struct RNDCP *CP= (struct RNDCP*)v_CP;
  1914. sem_destroy(&(CP->DeviceLock));
  1915. mn = CP->UDN_Head;
  1916. while(mn!=NULL)
  1917. {
  1918. mn2 = mn->Next;
  1919. if(mn->RootUDN!=NULL){FREE(mn->RootUDN);}
  1920. if(mn->device!=NULL)
  1921. {
  1922. i = 0;
  1923. if(CP->RemoveSink!=NULL)
  1924. {
  1925. do
  1926. {
  1927. RetDevice = RNDGetDevice1(mn->device,i++);
  1928. if(RetDevice!=NULL)
  1929. {
  1930. CP->RemoveSink(RetDevice);
  1931. }
  1932. }while(RetDevice!=NULL);
  1933. }
  1934. RNDDestructUPnPDevice(mn->device);
  1935. }
  1936. FREE(mn->UDN);
  1937. FREE(mn);
  1938. mn = mn2;
  1939. }
  1940. ILibDestroyHashTree(CP->SIDTable);
  1941. }
  1942. void RND_CP_IPAddressListChanged(void *CPToken)
  1943. {
  1944. ((struct RNDCP*)CPToken)->RecheckFlag = 1;
  1945. ILibForceUnBlockChain(((struct RNDCP*)CPToken)->Chain);
  1946. }
  1947. void RNDCP_ProcessDeviceRemoval(struct RNDCP* CP, struct UPnPDevice *device)
  1948. {
  1949. struct UPnPDevice *temp = device->EmbeddedDevices;
  1950. struct UPnPService *s;
  1951. while(temp!=NULL)
  1952. {
  1953. RNDCP_ProcessDeviceRemoval(CP,temp);
  1954. temp = temp->Next;
  1955. }
  1956. s = device->Services;
  1957. while(s!=NULL)
  1958. {
  1959. ILibLifeTime_Remove(CP->LifeTimeMonitor,s);
  1960. s = s->Next;
  1961. }
  1962. }
  1963. void RNDCP_PreSelect(void *CPToken,fd_set *readset, fd_set *writeset, fd_set *errorset, int *blocktime)
  1964. {
  1965. struct UDNMapNode *mn,*mn2;
  1966. struct RNDCP *CP= (struct RNDCP*)CPToken;
  1967. int *IPAddressList;
  1968. int NumAddressList;
  1969. int i;
  1970. int found;
  1971. if(CP->RecheckFlag!=0)
  1972. {
  1973. CP->RecheckFlag = 0;
  1974. NumAddressList = ILibGetLocalIPAddressList(&IPAddressList);
  1975. mn = CP->UDN_Head;
  1976. while(mn!=NULL)
  1977. {
  1978. mn2 = mn->Next;
  1979. found = 0;
  1980. for(i=0;i<NumAddressList;++i)
  1981. {
  1982. if(mn->device!=NULL && IPAddressList[i]==inet_addr(mn->device->InterfaceToHost))
  1983. {
  1984. found = 1;
  1985. break;
  1986. }
  1987. }
  1988. if(found==0)
  1989. {
  1990. // Clear LifeTime for services contained
  1991. RNDCP_ProcessDeviceRemoval(CP,mn->device);
  1992. CP->RemoveSink(mn->device);
  1993. RNDDestructUPnPDevice(mn->device);
  1994. if(mn->Previous==NULL)
  1995. {
  1996. // This is the head
  1997. CP->UDN_Head = mn->Next;
  1998. if(CP->UDN_Head!=NULL)
  1999. {
  2000. CP->UDN_Head->Previous = NULL;
  2001. }
  2002. }
  2003. else
  2004. {
  2005. mn->Previous->Next = mn->Next;
  2006. if(mn->Next!=NULL)
  2007. {
  2008. mn->Next->Previous = mn->Previous;
  2009. }
  2010. }
  2011. FREE(mn->UDN);
  2012. FREE(mn);
  2013. }
  2014. mn = mn2;
  2015. }
  2016. ILibSSDP_IPAddressListChanged(CP->SSDP);
  2017. FREE(CP->AddressList);
  2018. CP->AddressListLength = NumAddressList;
  2019. CP->AddressList = IPAddressList;
  2020. }
  2021. }
  2022. void *RNDCreateControlPoint(void *Chain, void(*A)(struct UPnPDevice*),void(*R)(struct UPnPDevice*))
  2023. {
  2024. struct RNDCP *cp = (struct RNDCP*)MALLOC(sizeof(struct RNDCP));
  2025. cp->Destroy = &RNDStopCP;
  2026. cp->PostSelect = NULL;
  2027. cp->PreSelect = &RNDCP_PreSelect;
  2028. cp->DiscoverSink = A;
  2029. cp->RemoveSink = R;
  2030. sem_init(&(cp->DeviceLock),0,1);
  2031. cp->UDN_Head = NULL;
  2032. cp->WebServer = ILibCreateMiniWebServer(Chain,5,&RNDOnEventSink,cp);
  2033. cp->SIDTable = ILibInitHashTree();
  2034. ILibAddToChain(Chain,cp);
  2035. cp->LifeTimeMonitor = ILibCreateLifeTime(Chain);
  2036. cp->SSDP = ILibCreateSSDPClientModule(Chain,"urn:schemas-upnp-org:device:MediaRenderer:1", 43, &RNDSSDP_Sink,cp);
  2037. cp->HTTP = ILibCreateHTTPClientModule(Chain,5);
  2038. cp->Chain = Chain;
  2039. cp->RecheckFlag = 0;
  2040. cp->AddressListLength = ILibGetLocalIPAddressList(&(cp->AddressList));
  2041. return((void*)cp);
  2042. }
  2043. void RNDInvoke_ConnectionManager_GetCurrentConnectionInfo_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2044. {
  2045. struct UPnPService *Service = (struct UPnPService*)_service;
  2046. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2047. int ArgLeft = 7;
  2048. struct ILibXMLNode *xml;
  2049. struct ILibXMLNode *__xml;
  2050. char *tempBuffer;
  2051. int tempBufferLength;
  2052. long TempLong;
  2053. int RcsID = 0;
  2054. int AVTransportID = 0;
  2055. char* ProtocolInfo = NULL;
  2056. char* PeerConnectionManager = NULL;
  2057. int PeerConnectionID = 0;
  2058. char* Direction = NULL;
  2059. char* Status = NULL;
  2060. if(done==0){return;}
  2061. if(_InvokeData->CallbackPtr==NULL)
  2062. {
  2063. RNDRelease(Service->Parent);
  2064. FREE(_InvokeData);
  2065. return;
  2066. }
  2067. else
  2068. {
  2069. if(header==NULL)
  2070. {
  2071. /* Connection Failed */
  2072. ((void (*)(struct UPnPService*,int,void*,int,int,char*,char*,int,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  2073. RNDRelease(Service->Parent);
  2074. FREE(_InvokeData);
  2075. return;
  2076. }
  2077. else if(header->StatusCode!=200)
  2078. {
  2079. /* SOAP Fault */
  2080. ((void (*)(struct UPnPService*,int,void*,int,int,char*,char*,int,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  2081. RNDRelease(Service->Parent);
  2082. FREE(_InvokeData);
  2083. return;
  2084. }
  2085. }
  2086. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  2087. ILibProcessXMLNodeList(xml);
  2088. while(xml!=NULL)
  2089. {
  2090. if(xml->NameLength==32 && memcmp(xml->Name,"GetCurrentConnectionInfoResponse",32)==0)
  2091. {
  2092. xml = xml->Next;
  2093. while(xml!=NULL)
  2094. {
  2095. if(xml->NameLength==5 && memcmp(xml->Name,"RcsID",5) == 0)
  2096. {
  2097. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2098. --ArgLeft;
  2099. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  2100. {
  2101. RcsID = (int) TempLong;
  2102. }
  2103. }
  2104. else
  2105. if(xml->NameLength==13 && memcmp(xml->Name,"AVTransportID",13) == 0)
  2106. {
  2107. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2108. --ArgLeft;
  2109. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  2110. {
  2111. AVTransportID = (int) TempLong;
  2112. }
  2113. }
  2114. else
  2115. if(xml->NameLength==12 && memcmp(xml->Name,"ProtocolInfo",12) == 0)
  2116. {
  2117. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2118. --ArgLeft;
  2119. if(tempBufferLength!=0)
  2120. {
  2121. tempBuffer[tempBufferLength] = '\0';
  2122. ProtocolInfo = tempBuffer;
  2123. }
  2124. }
  2125. else
  2126. if(xml->NameLength==21 && memcmp(xml->Name,"PeerConnectionManager",21) == 0)
  2127. {
  2128. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2129. --ArgLeft;
  2130. if(tempBufferLength!=0)
  2131. {
  2132. tempBuffer[tempBufferLength] = '\0';
  2133. PeerConnectionManager = tempBuffer;
  2134. }
  2135. }
  2136. else
  2137. if(xml->NameLength==16 && memcmp(xml->Name,"PeerConnectionID",16) == 0)
  2138. {
  2139. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2140. --ArgLeft;
  2141. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  2142. {
  2143. PeerConnectionID = (int) TempLong;
  2144. }
  2145. }
  2146. else
  2147. if(xml->NameLength==9 && memcmp(xml->Name,"Direction",9) == 0)
  2148. {
  2149. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2150. --ArgLeft;
  2151. if(tempBufferLength!=0)
  2152. {
  2153. tempBuffer[tempBufferLength] = '\0';
  2154. Direction = tempBuffer;
  2155. }
  2156. }
  2157. else
  2158. if(xml->NameLength==6 && memcmp(xml->Name,"Status",6) == 0)
  2159. {
  2160. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2161. --ArgLeft;
  2162. if(tempBufferLength!=0)
  2163. {
  2164. tempBuffer[tempBufferLength] = '\0';
  2165. Status = tempBuffer;
  2166. }
  2167. }
  2168. xml = xml->Peer;
  2169. }
  2170. }
  2171. if(xml!=NULL) {xml = xml->Next;}
  2172. }
  2173. ILibDestructXMLNodeList(__xml);
  2174. if(ArgLeft!=0)
  2175. {
  2176. ((void (*)(struct UPnPService*,int,void*,int,int,char*,char*,int,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  2177. }
  2178. else
  2179. {
  2180. ((void (*)(struct UPnPService*,int,void*,int,int,char*,char*,int,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,RcsID,AVTransportID,ProtocolInfo,PeerConnectionManager,PeerConnectionID,Direction,Status);
  2181. }
  2182. RNDRelease(Service->Parent);
  2183. FREE(_InvokeData);
  2184. }
  2185. void RNDInvoke_ConnectionManager_GetCurrentConnectionInfo(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,int,int,char*,char*,int,char*,char*), void* user, int ConnectionID)
  2186. {
  2187. int headerLength;
  2188. char *headerBuffer;
  2189. char *SoapBodyTemplate;
  2190. char* buffer;
  2191. int bufferLength;
  2192. char* IP;
  2193. unsigned short Port;
  2194. char* Path;
  2195. struct sockaddr_in addr;
  2196. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2197. if(service==NULL)
  2198. {
  2199. FREE(invoke_data);
  2200. return;
  2201. }
  2202. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+320);
  2203. SoapBodyTemplate = "%sGetCurrentConnectionInfo xmlns:u=\"%s\"><ConnectionID>%d</ConnectionID></u:GetCurrentConnectionInfo%s";
  2204. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, ConnectionID,UPNPCP_SOAP_BodyTail);
  2205. RNDAddRef(service->Parent);
  2206. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2207. headerBuffer = (char*)MALLOC(177 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2208. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetCurrentConnectionInfo",bufferLength);
  2209. memset((char *)&addr, 0, sizeof(addr));
  2210. addr.sin_family = AF_INET;
  2211. addr.sin_addr.s_addr = inet_addr(IP);
  2212. addr.sin_port = htons(Port);
  2213. invoke_data->CallbackPtr = CallbackPtr;
  2214. invoke_data->User = user;
  2215. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_ConnectionManager_GetCurrentConnectionInfo_Sink, service, invoke_data);
  2216. FREE(IP);
  2217. FREE(Path);
  2218. }
  2219. void RNDInvoke_ConnectionManager_GetProtocolInfo_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2220. {
  2221. struct UPnPService *Service = (struct UPnPService*)_service;
  2222. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2223. int ArgLeft = 2;
  2224. struct ILibXMLNode *xml;
  2225. struct ILibXMLNode *__xml;
  2226. char *tempBuffer;
  2227. int tempBufferLength;
  2228. char* Source = NULL;
  2229. char* Sink = NULL;
  2230. if(done==0){return;}
  2231. if(_InvokeData->CallbackPtr==NULL)
  2232. {
  2233. RNDRelease(Service->Parent);
  2234. FREE(_InvokeData);
  2235. return;
  2236. }
  2237. else
  2238. {
  2239. if(header==NULL)
  2240. {
  2241. /* Connection Failed */
  2242. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2243. RNDRelease(Service->Parent);
  2244. FREE(_InvokeData);
  2245. return;
  2246. }
  2247. else if(header->StatusCode!=200)
  2248. {
  2249. /* SOAP Fault */
  2250. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2251. RNDRelease(Service->Parent);
  2252. FREE(_InvokeData);
  2253. return;
  2254. }
  2255. }
  2256. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  2257. ILibProcessXMLNodeList(xml);
  2258. while(xml!=NULL)
  2259. {
  2260. if(xml->NameLength==23 && memcmp(xml->Name,"GetProtocolInfoResponse",23)==0)
  2261. {
  2262. xml = xml->Next;
  2263. while(xml!=NULL)
  2264. {
  2265. if(xml->NameLength==6 && memcmp(xml->Name,"Source",6) == 0)
  2266. {
  2267. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2268. --ArgLeft;
  2269. if(tempBufferLength!=0)
  2270. {
  2271. tempBuffer[tempBufferLength] = '\0';
  2272. Source = tempBuffer;
  2273. }
  2274. }
  2275. else
  2276. if(xml->NameLength==4 && memcmp(xml->Name,"Sink",4) == 0)
  2277. {
  2278. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2279. --ArgLeft;
  2280. if(tempBufferLength!=0)
  2281. {
  2282. tempBuffer[tempBufferLength] = '\0';
  2283. Sink = tempBuffer;
  2284. }
  2285. }
  2286. xml = xml->Peer;
  2287. }
  2288. }
  2289. if(xml!=NULL) {xml = xml->Next;}
  2290. }
  2291. ILibDestructXMLNodeList(__xml);
  2292. if(ArgLeft!=0)
  2293. {
  2294. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2295. }
  2296. else
  2297. {
  2298. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,Source,Sink);
  2299. }
  2300. RNDRelease(Service->Parent);
  2301. FREE(_InvokeData);
  2302. }
  2303. void RNDInvoke_ConnectionManager_GetProtocolInfo(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*,char*), void* user)
  2304. {
  2305. int headerLength;
  2306. char *headerBuffer;
  2307. char *SoapBodyTemplate;
  2308. char* buffer;
  2309. int bufferLength;
  2310. char* IP;
  2311. unsigned short Port;
  2312. char* Path;
  2313. struct sockaddr_in addr;
  2314. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2315. if(service==NULL)
  2316. {
  2317. FREE(invoke_data);
  2318. return;
  2319. }
  2320. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+262);
  2321. SoapBodyTemplate = "%sGetProtocolInfo xmlns:u=\"%s\"></u:GetProtocolInfo%s";
  2322. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType,UPNPCP_SOAP_BodyTail);
  2323. RNDAddRef(service->Parent);
  2324. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2325. headerBuffer = (char*)MALLOC(168 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2326. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetProtocolInfo",bufferLength);
  2327. memset((char *)&addr, 0, sizeof(addr));
  2328. addr.sin_family = AF_INET;
  2329. addr.sin_addr.s_addr = inet_addr(IP);
  2330. addr.sin_port = htons(Port);
  2331. invoke_data->CallbackPtr = CallbackPtr;
  2332. invoke_data->User = user;
  2333. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_ConnectionManager_GetProtocolInfo_Sink, service, invoke_data);
  2334. FREE(IP);
  2335. FREE(Path);
  2336. }
  2337. void RNDInvoke_ConnectionManager_GetCurrentConnectionIDs_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2338. {
  2339. struct UPnPService *Service = (struct UPnPService*)_service;
  2340. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2341. int ArgLeft = 1;
  2342. struct ILibXMLNode *xml;
  2343. struct ILibXMLNode *__xml;
  2344. char *tempBuffer;
  2345. int tempBufferLength;
  2346. char* ConnectionIDs = NULL;
  2347. if(done==0){return;}
  2348. if(_InvokeData->CallbackPtr==NULL)
  2349. {
  2350. RNDRelease(Service->Parent);
  2351. FREE(_InvokeData);
  2352. return;
  2353. }
  2354. else
  2355. {
  2356. if(header==NULL)
  2357. {
  2358. /* Connection Failed */
  2359. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  2360. RNDRelease(Service->Parent);
  2361. FREE(_InvokeData);
  2362. return;
  2363. }
  2364. else if(header->StatusCode!=200)
  2365. {
  2366. /* SOAP Fault */
  2367. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  2368. RNDRelease(Service->Parent);
  2369. FREE(_InvokeData);
  2370. return;
  2371. }
  2372. }
  2373. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  2374. ILibProcessXMLNodeList(xml);
  2375. while(xml!=NULL)
  2376. {
  2377. if(xml->NameLength==31 && memcmp(xml->Name,"GetCurrentConnectionIDsResponse",31)==0)
  2378. {
  2379. xml = xml->Next;
  2380. while(xml!=NULL)
  2381. {
  2382. if(xml->NameLength==13 && memcmp(xml->Name,"ConnectionIDs",13) == 0)
  2383. {
  2384. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2385. --ArgLeft;
  2386. if(tempBufferLength!=0)
  2387. {
  2388. tempBuffer[tempBufferLength] = '\0';
  2389. ConnectionIDs = tempBuffer;
  2390. }
  2391. }
  2392. xml = xml->Peer;
  2393. }
  2394. }
  2395. if(xml!=NULL) {xml = xml->Next;}
  2396. }
  2397. ILibDestructXMLNodeList(__xml);
  2398. if(ArgLeft!=0)
  2399. {
  2400. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  2401. }
  2402. else
  2403. {
  2404. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,ConnectionIDs);
  2405. }
  2406. RNDRelease(Service->Parent);
  2407. FREE(_InvokeData);
  2408. }
  2409. void RNDInvoke_ConnectionManager_GetCurrentConnectionIDs(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*), void* user)
  2410. {
  2411. int headerLength;
  2412. char *headerBuffer;
  2413. char *SoapBodyTemplate;
  2414. char* buffer;
  2415. int bufferLength;
  2416. char* IP;
  2417. unsigned short Port;
  2418. char* Path;
  2419. struct sockaddr_in addr;
  2420. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2421. if(service==NULL)
  2422. {
  2423. FREE(invoke_data);
  2424. return;
  2425. }
  2426. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+278);
  2427. SoapBodyTemplate = "%sGetCurrentConnectionIDs xmlns:u=\"%s\"></u:GetCurrentConnectionIDs%s";
  2428. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType,UPNPCP_SOAP_BodyTail);
  2429. RNDAddRef(service->Parent);
  2430. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2431. headerBuffer = (char*)MALLOC(176 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2432. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetCurrentConnectionIDs",bufferLength);
  2433. memset((char *)&addr, 0, sizeof(addr));
  2434. addr.sin_family = AF_INET;
  2435. addr.sin_addr.s_addr = inet_addr(IP);
  2436. addr.sin_port = htons(Port);
  2437. invoke_data->CallbackPtr = CallbackPtr;
  2438. invoke_data->User = user;
  2439. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_ConnectionManager_GetCurrentConnectionIDs_Sink, service, invoke_data);
  2440. FREE(IP);
  2441. FREE(Path);
  2442. }
  2443. void RNDInvoke_AVTransport_GetCurrentTransportActions_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2444. {
  2445. struct UPnPService *Service = (struct UPnPService*)_service;
  2446. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2447. int ArgLeft = 1;
  2448. struct ILibXMLNode *xml;
  2449. struct ILibXMLNode *__xml;
  2450. char *tempBuffer;
  2451. int tempBufferLength;
  2452. char* Actions = NULL;
  2453. if(done==0){return;}
  2454. if(_InvokeData->CallbackPtr==NULL)
  2455. {
  2456. RNDRelease(Service->Parent);
  2457. FREE(_InvokeData);
  2458. return;
  2459. }
  2460. else
  2461. {
  2462. if(header==NULL)
  2463. {
  2464. /* Connection Failed */
  2465. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  2466. RNDRelease(Service->Parent);
  2467. FREE(_InvokeData);
  2468. return;
  2469. }
  2470. else if(header->StatusCode!=200)
  2471. {
  2472. /* SOAP Fault */
  2473. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  2474. RNDRelease(Service->Parent);
  2475. FREE(_InvokeData);
  2476. return;
  2477. }
  2478. }
  2479. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  2480. ILibProcessXMLNodeList(xml);
  2481. while(xml!=NULL)
  2482. {
  2483. if(xml->NameLength==34 && memcmp(xml->Name,"GetCurrentTransportActionsResponse",34)==0)
  2484. {
  2485. xml = xml->Next;
  2486. while(xml!=NULL)
  2487. {
  2488. if(xml->NameLength==7 && memcmp(xml->Name,"Actions",7) == 0)
  2489. {
  2490. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2491. --ArgLeft;
  2492. if(tempBufferLength!=0)
  2493. {
  2494. tempBuffer[tempBufferLength] = '\0';
  2495. Actions = tempBuffer;
  2496. }
  2497. }
  2498. xml = xml->Peer;
  2499. }
  2500. }
  2501. if(xml!=NULL) {xml = xml->Next;}
  2502. }
  2503. ILibDestructXMLNodeList(__xml);
  2504. if(ArgLeft!=0)
  2505. {
  2506. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  2507. }
  2508. else
  2509. {
  2510. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,Actions);
  2511. }
  2512. RNDRelease(Service->Parent);
  2513. FREE(_InvokeData);
  2514. }
  2515. void RNDInvoke_AVTransport_GetCurrentTransportActions(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*), void* user, unsigned int InstanceID)
  2516. {
  2517. int headerLength;
  2518. char *headerBuffer;
  2519. char *SoapBodyTemplate;
  2520. char* buffer;
  2521. int bufferLength;
  2522. char* IP;
  2523. unsigned short Port;
  2524. char* Path;
  2525. struct sockaddr_in addr;
  2526. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2527. if(service==NULL)
  2528. {
  2529. FREE(invoke_data);
  2530. return;
  2531. }
  2532. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+319);
  2533. SoapBodyTemplate = "%sGetCurrentTransportActions xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetCurrentTransportActions%s";
  2534. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  2535. RNDAddRef(service->Parent);
  2536. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2537. headerBuffer = (char*)MALLOC(179 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2538. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetCurrentTransportActions",bufferLength);
  2539. memset((char *)&addr, 0, sizeof(addr));
  2540. addr.sin_family = AF_INET;
  2541. addr.sin_addr.s_addr = inet_addr(IP);
  2542. addr.sin_port = htons(Port);
  2543. invoke_data->CallbackPtr = CallbackPtr;
  2544. invoke_data->User = user;
  2545. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetCurrentTransportActions_Sink, service, invoke_data);
  2546. FREE(IP);
  2547. FREE(Path);
  2548. }
  2549. void RNDInvoke_AVTransport_Play_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2550. {
  2551. struct UPnPService *Service = (struct UPnPService*)_service;
  2552. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2553. if(done==0){return;}
  2554. if(_InvokeData->CallbackPtr==NULL)
  2555. {
  2556. RNDRelease(Service->Parent);
  2557. FREE(_InvokeData);
  2558. return;
  2559. }
  2560. else
  2561. {
  2562. if(header==NULL)
  2563. {
  2564. /* Connection Failed */
  2565. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  2566. RNDRelease(Service->Parent);
  2567. FREE(_InvokeData);
  2568. return;
  2569. }
  2570. else if(header->StatusCode!=200)
  2571. {
  2572. /* SOAP Fault */
  2573. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  2574. RNDRelease(Service->Parent);
  2575. FREE(_InvokeData);
  2576. return;
  2577. }
  2578. }
  2579. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  2580. RNDRelease(Service->Parent);
  2581. FREE(_InvokeData);
  2582. }
  2583. void RNDInvoke_AVTransport_Play(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Speed)
  2584. {
  2585. int headerLength;
  2586. char *headerBuffer;
  2587. char *SoapBodyTemplate;
  2588. char* buffer;
  2589. int bufferLength;
  2590. char* IP;
  2591. unsigned short Port;
  2592. char* Path;
  2593. struct sockaddr_in addr;
  2594. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2595. if(service==NULL)
  2596. {
  2597. FREE(invoke_data);
  2598. return;
  2599. }
  2600. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Speed)+290);
  2601. SoapBodyTemplate = "%sPlay xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Speed>%s</Speed></u:Play%s";
  2602. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Speed,UPNPCP_SOAP_BodyTail);
  2603. RNDAddRef(service->Parent);
  2604. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2605. headerBuffer = (char*)MALLOC(157 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2606. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Play",bufferLength);
  2607. memset((char *)&addr, 0, sizeof(addr));
  2608. addr.sin_family = AF_INET;
  2609. addr.sin_addr.s_addr = inet_addr(IP);
  2610. addr.sin_port = htons(Port);
  2611. invoke_data->CallbackPtr = CallbackPtr;
  2612. invoke_data->User = user;
  2613. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Play_Sink, service, invoke_data);
  2614. FREE(IP);
  2615. FREE(Path);
  2616. }
  2617. void RNDInvoke_AVTransport_Previous_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2618. {
  2619. struct UPnPService *Service = (struct UPnPService*)_service;
  2620. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2621. if(done==0){return;}
  2622. if(_InvokeData->CallbackPtr==NULL)
  2623. {
  2624. RNDRelease(Service->Parent);
  2625. FREE(_InvokeData);
  2626. return;
  2627. }
  2628. else
  2629. {
  2630. if(header==NULL)
  2631. {
  2632. /* Connection Failed */
  2633. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  2634. RNDRelease(Service->Parent);
  2635. FREE(_InvokeData);
  2636. return;
  2637. }
  2638. else if(header->StatusCode!=200)
  2639. {
  2640. /* SOAP Fault */
  2641. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  2642. RNDRelease(Service->Parent);
  2643. FREE(_InvokeData);
  2644. return;
  2645. }
  2646. }
  2647. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  2648. RNDRelease(Service->Parent);
  2649. FREE(_InvokeData);
  2650. }
  2651. void RNDInvoke_AVTransport_Previous(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID)
  2652. {
  2653. int headerLength;
  2654. char *headerBuffer;
  2655. char *SoapBodyTemplate;
  2656. char* buffer;
  2657. int bufferLength;
  2658. char* IP;
  2659. unsigned short Port;
  2660. char* Path;
  2661. struct sockaddr_in addr;
  2662. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2663. if(service==NULL)
  2664. {
  2665. FREE(invoke_data);
  2666. return;
  2667. }
  2668. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+283);
  2669. SoapBodyTemplate = "%sPrevious xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:Previous%s";
  2670. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  2671. RNDAddRef(service->Parent);
  2672. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2673. headerBuffer = (char*)MALLOC(161 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2674. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Previous",bufferLength);
  2675. memset((char *)&addr, 0, sizeof(addr));
  2676. addr.sin_family = AF_INET;
  2677. addr.sin_addr.s_addr = inet_addr(IP);
  2678. addr.sin_port = htons(Port);
  2679. invoke_data->CallbackPtr = CallbackPtr;
  2680. invoke_data->User = user;
  2681. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Previous_Sink, service, invoke_data);
  2682. FREE(IP);
  2683. FREE(Path);
  2684. }
  2685. void RNDInvoke_AVTransport_Next_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2686. {
  2687. struct UPnPService *Service = (struct UPnPService*)_service;
  2688. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2689. if(done==0){return;}
  2690. if(_InvokeData->CallbackPtr==NULL)
  2691. {
  2692. RNDRelease(Service->Parent);
  2693. FREE(_InvokeData);
  2694. return;
  2695. }
  2696. else
  2697. {
  2698. if(header==NULL)
  2699. {
  2700. /* Connection Failed */
  2701. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  2702. RNDRelease(Service->Parent);
  2703. FREE(_InvokeData);
  2704. return;
  2705. }
  2706. else if(header->StatusCode!=200)
  2707. {
  2708. /* SOAP Fault */
  2709. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  2710. RNDRelease(Service->Parent);
  2711. FREE(_InvokeData);
  2712. return;
  2713. }
  2714. }
  2715. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  2716. RNDRelease(Service->Parent);
  2717. FREE(_InvokeData);
  2718. }
  2719. void RNDInvoke_AVTransport_Next(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID)
  2720. {
  2721. int headerLength;
  2722. char *headerBuffer;
  2723. char *SoapBodyTemplate;
  2724. char* buffer;
  2725. int bufferLength;
  2726. char* IP;
  2727. unsigned short Port;
  2728. char* Path;
  2729. struct sockaddr_in addr;
  2730. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2731. if(service==NULL)
  2732. {
  2733. FREE(invoke_data);
  2734. return;
  2735. }
  2736. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+275);
  2737. SoapBodyTemplate = "%sNext xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:Next%s";
  2738. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  2739. RNDAddRef(service->Parent);
  2740. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2741. headerBuffer = (char*)MALLOC(157 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2742. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Next",bufferLength);
  2743. memset((char *)&addr, 0, sizeof(addr));
  2744. addr.sin_family = AF_INET;
  2745. addr.sin_addr.s_addr = inet_addr(IP);
  2746. addr.sin_port = htons(Port);
  2747. invoke_data->CallbackPtr = CallbackPtr;
  2748. invoke_data->User = user;
  2749. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Next_Sink, service, invoke_data);
  2750. FREE(IP);
  2751. FREE(Path);
  2752. }
  2753. void RNDInvoke_AVTransport_Stop_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2754. {
  2755. struct UPnPService *Service = (struct UPnPService*)_service;
  2756. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2757. if(done==0){return;}
  2758. if(_InvokeData->CallbackPtr==NULL)
  2759. {
  2760. RNDRelease(Service->Parent);
  2761. FREE(_InvokeData);
  2762. return;
  2763. }
  2764. else
  2765. {
  2766. if(header==NULL)
  2767. {
  2768. /* Connection Failed */
  2769. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  2770. RNDRelease(Service->Parent);
  2771. FREE(_InvokeData);
  2772. return;
  2773. }
  2774. else if(header->StatusCode!=200)
  2775. {
  2776. /* SOAP Fault */
  2777. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  2778. RNDRelease(Service->Parent);
  2779. FREE(_InvokeData);
  2780. return;
  2781. }
  2782. }
  2783. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  2784. RNDRelease(Service->Parent);
  2785. FREE(_InvokeData);
  2786. }
  2787. void RNDInvoke_AVTransport_Stop(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID)
  2788. {
  2789. int headerLength;
  2790. char *headerBuffer;
  2791. char *SoapBodyTemplate;
  2792. char* buffer;
  2793. int bufferLength;
  2794. char* IP;
  2795. unsigned short Port;
  2796. char* Path;
  2797. struct sockaddr_in addr;
  2798. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2799. if(service==NULL)
  2800. {
  2801. FREE(invoke_data);
  2802. return;
  2803. }
  2804. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+275);
  2805. SoapBodyTemplate = "%sStop xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:Stop%s";
  2806. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  2807. RNDAddRef(service->Parent);
  2808. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2809. headerBuffer = (char*)MALLOC(157 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2810. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Stop",bufferLength);
  2811. memset((char *)&addr, 0, sizeof(addr));
  2812. addr.sin_family = AF_INET;
  2813. addr.sin_addr.s_addr = inet_addr(IP);
  2814. addr.sin_port = htons(Port);
  2815. invoke_data->CallbackPtr = CallbackPtr;
  2816. invoke_data->User = user;
  2817. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Stop_Sink, service, invoke_data);
  2818. FREE(IP);
  2819. FREE(Path);
  2820. }
  2821. void RNDInvoke_AVTransport_GetTransportSettings_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2822. {
  2823. struct UPnPService *Service = (struct UPnPService*)_service;
  2824. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2825. int ArgLeft = 2;
  2826. struct ILibXMLNode *xml;
  2827. struct ILibXMLNode *__xml;
  2828. char *tempBuffer;
  2829. int tempBufferLength;
  2830. char* PlayMode = NULL;
  2831. char* RecQualityMode = NULL;
  2832. if(done==0){return;}
  2833. if(_InvokeData->CallbackPtr==NULL)
  2834. {
  2835. RNDRelease(Service->Parent);
  2836. FREE(_InvokeData);
  2837. return;
  2838. }
  2839. else
  2840. {
  2841. if(header==NULL)
  2842. {
  2843. /* Connection Failed */
  2844. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2845. RNDRelease(Service->Parent);
  2846. FREE(_InvokeData);
  2847. return;
  2848. }
  2849. else if(header->StatusCode!=200)
  2850. {
  2851. /* SOAP Fault */
  2852. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2853. RNDRelease(Service->Parent);
  2854. FREE(_InvokeData);
  2855. return;
  2856. }
  2857. }
  2858. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  2859. ILibProcessXMLNodeList(xml);
  2860. while(xml!=NULL)
  2861. {
  2862. if(xml->NameLength==28 && memcmp(xml->Name,"GetTransportSettingsResponse",28)==0)
  2863. {
  2864. xml = xml->Next;
  2865. while(xml!=NULL)
  2866. {
  2867. if(xml->NameLength==8 && memcmp(xml->Name,"PlayMode",8) == 0)
  2868. {
  2869. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2870. --ArgLeft;
  2871. if(tempBufferLength!=0)
  2872. {
  2873. tempBuffer[tempBufferLength] = '\0';
  2874. PlayMode = tempBuffer;
  2875. }
  2876. }
  2877. else
  2878. if(xml->NameLength==14 && memcmp(xml->Name,"RecQualityMode",14) == 0)
  2879. {
  2880. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  2881. --ArgLeft;
  2882. if(tempBufferLength!=0)
  2883. {
  2884. tempBuffer[tempBufferLength] = '\0';
  2885. RecQualityMode = tempBuffer;
  2886. }
  2887. }
  2888. xml = xml->Peer;
  2889. }
  2890. }
  2891. if(xml!=NULL) {xml = xml->Next;}
  2892. }
  2893. ILibDestructXMLNodeList(__xml);
  2894. if(ArgLeft!=0)
  2895. {
  2896. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  2897. }
  2898. else
  2899. {
  2900. ((void (*)(struct UPnPService*,int,void*,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,PlayMode,RecQualityMode);
  2901. }
  2902. RNDRelease(Service->Parent);
  2903. FREE(_InvokeData);
  2904. }
  2905. void RNDInvoke_AVTransport_GetTransportSettings(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*,char*), void* user, unsigned int InstanceID)
  2906. {
  2907. int headerLength;
  2908. char *headerBuffer;
  2909. char *SoapBodyTemplate;
  2910. char* buffer;
  2911. int bufferLength;
  2912. char* IP;
  2913. unsigned short Port;
  2914. char* Path;
  2915. struct sockaddr_in addr;
  2916. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2917. if(service==NULL)
  2918. {
  2919. FREE(invoke_data);
  2920. return;
  2921. }
  2922. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+307);
  2923. SoapBodyTemplate = "%sGetTransportSettings xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetTransportSettings%s";
  2924. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  2925. RNDAddRef(service->Parent);
  2926. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2927. headerBuffer = (char*)MALLOC(173 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2928. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetTransportSettings",bufferLength);
  2929. memset((char *)&addr, 0, sizeof(addr));
  2930. addr.sin_family = AF_INET;
  2931. addr.sin_addr.s_addr = inet_addr(IP);
  2932. addr.sin_port = htons(Port);
  2933. invoke_data->CallbackPtr = CallbackPtr;
  2934. invoke_data->User = user;
  2935. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetTransportSettings_Sink, service, invoke_data);
  2936. FREE(IP);
  2937. FREE(Path);
  2938. }
  2939. void RNDInvoke_AVTransport_Seek_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  2940. {
  2941. struct UPnPService *Service = (struct UPnPService*)_service;
  2942. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  2943. if(done==0){return;}
  2944. if(_InvokeData->CallbackPtr==NULL)
  2945. {
  2946. RNDRelease(Service->Parent);
  2947. FREE(_InvokeData);
  2948. return;
  2949. }
  2950. else
  2951. {
  2952. if(header==NULL)
  2953. {
  2954. /* Connection Failed */
  2955. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  2956. RNDRelease(Service->Parent);
  2957. FREE(_InvokeData);
  2958. return;
  2959. }
  2960. else if(header->StatusCode!=200)
  2961. {
  2962. /* SOAP Fault */
  2963. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  2964. RNDRelease(Service->Parent);
  2965. FREE(_InvokeData);
  2966. return;
  2967. }
  2968. }
  2969. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  2970. RNDRelease(Service->Parent);
  2971. FREE(_InvokeData);
  2972. }
  2973. void RNDInvoke_AVTransport_Seek(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Unit, char* Target)
  2974. {
  2975. int headerLength;
  2976. char *headerBuffer;
  2977. char *SoapBodyTemplate;
  2978. char* buffer;
  2979. int bufferLength;
  2980. char* IP;
  2981. unsigned short Port;
  2982. char* Path;
  2983. struct sockaddr_in addr;
  2984. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  2985. if(service==NULL)
  2986. {
  2987. FREE(invoke_data);
  2988. return;
  2989. }
  2990. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Unit)+(int)strlen(Target)+305);
  2991. SoapBodyTemplate = "%sSeek xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Unit>%s</Unit><Target>%s</Target></u:Seek%s";
  2992. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Unit, Target,UPNPCP_SOAP_BodyTail);
  2993. RNDAddRef(service->Parent);
  2994. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  2995. headerBuffer = (char*)MALLOC(157 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  2996. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Seek",bufferLength);
  2997. memset((char *)&addr, 0, sizeof(addr));
  2998. addr.sin_family = AF_INET;
  2999. addr.sin_addr.s_addr = inet_addr(IP);
  3000. addr.sin_port = htons(Port);
  3001. invoke_data->CallbackPtr = CallbackPtr;
  3002. invoke_data->User = user;
  3003. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Seek_Sink, service, invoke_data);
  3004. FREE(IP);
  3005. FREE(Path);
  3006. }
  3007. void RNDInvoke_AVTransport_Pause_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3008. {
  3009. struct UPnPService *Service = (struct UPnPService*)_service;
  3010. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3011. if(done==0){return;}
  3012. if(_InvokeData->CallbackPtr==NULL)
  3013. {
  3014. RNDRelease(Service->Parent);
  3015. FREE(_InvokeData);
  3016. return;
  3017. }
  3018. else
  3019. {
  3020. if(header==NULL)
  3021. {
  3022. /* Connection Failed */
  3023. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  3024. RNDRelease(Service->Parent);
  3025. FREE(_InvokeData);
  3026. return;
  3027. }
  3028. else if(header->StatusCode!=200)
  3029. {
  3030. /* SOAP Fault */
  3031. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  3032. RNDRelease(Service->Parent);
  3033. FREE(_InvokeData);
  3034. return;
  3035. }
  3036. }
  3037. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  3038. RNDRelease(Service->Parent);
  3039. FREE(_InvokeData);
  3040. }
  3041. void RNDInvoke_AVTransport_Pause(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID)
  3042. {
  3043. int headerLength;
  3044. char *headerBuffer;
  3045. char *SoapBodyTemplate;
  3046. char* buffer;
  3047. int bufferLength;
  3048. char* IP;
  3049. unsigned short Port;
  3050. char* Path;
  3051. struct sockaddr_in addr;
  3052. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3053. if(service==NULL)
  3054. {
  3055. FREE(invoke_data);
  3056. return;
  3057. }
  3058. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+277);
  3059. SoapBodyTemplate = "%sPause xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:Pause%s";
  3060. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3061. RNDAddRef(service->Parent);
  3062. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3063. headerBuffer = (char*)MALLOC(158 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3064. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"Pause",bufferLength);
  3065. memset((char *)&addr, 0, sizeof(addr));
  3066. addr.sin_family = AF_INET;
  3067. addr.sin_addr.s_addr = inet_addr(IP);
  3068. addr.sin_port = htons(Port);
  3069. invoke_data->CallbackPtr = CallbackPtr;
  3070. invoke_data->User = user;
  3071. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_Pause_Sink, service, invoke_data);
  3072. FREE(IP);
  3073. FREE(Path);
  3074. }
  3075. void RNDInvoke_AVTransport_GetPositionInfo_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3076. {
  3077. struct UPnPService *Service = (struct UPnPService*)_service;
  3078. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3079. int ArgLeft = 8;
  3080. struct ILibXMLNode *xml;
  3081. struct ILibXMLNode *__xml;
  3082. char *tempBuffer;
  3083. int tempBufferLength;
  3084. long TempLong;
  3085. unsigned long TempULong;
  3086. unsigned int Track = 0;
  3087. char* TrackDuration = NULL;
  3088. char* TrackMetaData = NULL;
  3089. char* TrackURI = NULL;
  3090. char* RelTime = NULL;
  3091. char* AbsTime = NULL;
  3092. int RelCount = 0;
  3093. int AbsCount = 0;
  3094. if(done==0){return;}
  3095. if(_InvokeData->CallbackPtr==NULL)
  3096. {
  3097. RNDRelease(Service->Parent);
  3098. FREE(_InvokeData);
  3099. return;
  3100. }
  3101. else
  3102. {
  3103. if(header==NULL)
  3104. {
  3105. /* Connection Failed */
  3106. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,int,int))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3107. RNDRelease(Service->Parent);
  3108. FREE(_InvokeData);
  3109. return;
  3110. }
  3111. else if(header->StatusCode!=200)
  3112. {
  3113. /* SOAP Fault */
  3114. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,int,int))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3115. RNDRelease(Service->Parent);
  3116. FREE(_InvokeData);
  3117. return;
  3118. }
  3119. }
  3120. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  3121. ILibProcessXMLNodeList(xml);
  3122. while(xml!=NULL)
  3123. {
  3124. if(xml->NameLength==23 && memcmp(xml->Name,"GetPositionInfoResponse",23)==0)
  3125. {
  3126. xml = xml->Next;
  3127. while(xml!=NULL)
  3128. {
  3129. if(xml->NameLength==5 && memcmp(xml->Name,"Track",5) == 0)
  3130. {
  3131. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3132. --ArgLeft;
  3133. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  3134. {
  3135. Track = (unsigned int) TempULong;
  3136. }
  3137. }
  3138. else
  3139. if(xml->NameLength==13 && memcmp(xml->Name,"TrackDuration",13) == 0)
  3140. {
  3141. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3142. --ArgLeft;
  3143. if(tempBufferLength!=0)
  3144. {
  3145. tempBuffer[tempBufferLength] = '\0';
  3146. TrackDuration = tempBuffer;
  3147. }
  3148. }
  3149. else
  3150. if(xml->NameLength==13 && memcmp(xml->Name,"TrackMetaData",13) == 0)
  3151. {
  3152. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3153. --ArgLeft;
  3154. if(tempBufferLength!=0)
  3155. {
  3156. tempBuffer[tempBufferLength] = '\0';
  3157. TrackMetaData = tempBuffer;
  3158. }
  3159. }
  3160. else
  3161. if(xml->NameLength==8 && memcmp(xml->Name,"TrackURI",8) == 0)
  3162. {
  3163. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3164. --ArgLeft;
  3165. if(tempBufferLength!=0)
  3166. {
  3167. tempBuffer[tempBufferLength] = '\0';
  3168. TrackURI = tempBuffer;
  3169. }
  3170. }
  3171. else
  3172. if(xml->NameLength==7 && memcmp(xml->Name,"RelTime",7) == 0)
  3173. {
  3174. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3175. --ArgLeft;
  3176. if(tempBufferLength!=0)
  3177. {
  3178. tempBuffer[tempBufferLength] = '\0';
  3179. RelTime = tempBuffer;
  3180. }
  3181. }
  3182. else
  3183. if(xml->NameLength==7 && memcmp(xml->Name,"AbsTime",7) == 0)
  3184. {
  3185. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3186. --ArgLeft;
  3187. if(tempBufferLength!=0)
  3188. {
  3189. tempBuffer[tempBufferLength] = '\0';
  3190. AbsTime = tempBuffer;
  3191. }
  3192. }
  3193. else
  3194. if(xml->NameLength==8 && memcmp(xml->Name,"RelCount",8) == 0)
  3195. {
  3196. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3197. --ArgLeft;
  3198. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  3199. {
  3200. RelCount = (int) TempLong;
  3201. }
  3202. }
  3203. else
  3204. if(xml->NameLength==8 && memcmp(xml->Name,"AbsCount",8) == 0)
  3205. {
  3206. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3207. --ArgLeft;
  3208. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  3209. {
  3210. AbsCount = (int) TempLong;
  3211. }
  3212. }
  3213. xml = xml->Peer;
  3214. }
  3215. }
  3216. if(xml!=NULL) {xml = xml->Next;}
  3217. }
  3218. ILibDestructXMLNodeList(__xml);
  3219. if(ArgLeft!=0)
  3220. {
  3221. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,int,int))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3222. }
  3223. else
  3224. {
  3225. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,int,int))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,Track,TrackDuration,TrackMetaData,TrackURI,RelTime,AbsTime,RelCount,AbsCount);
  3226. }
  3227. RNDRelease(Service->Parent);
  3228. FREE(_InvokeData);
  3229. }
  3230. void RNDInvoke_AVTransport_GetPositionInfo(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,int,int), void* user, unsigned int InstanceID)
  3231. {
  3232. int headerLength;
  3233. char *headerBuffer;
  3234. char *SoapBodyTemplate;
  3235. char* buffer;
  3236. int bufferLength;
  3237. char* IP;
  3238. unsigned short Port;
  3239. char* Path;
  3240. struct sockaddr_in addr;
  3241. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3242. if(service==NULL)
  3243. {
  3244. FREE(invoke_data);
  3245. return;
  3246. }
  3247. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+297);
  3248. SoapBodyTemplate = "%sGetPositionInfo xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetPositionInfo%s";
  3249. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3250. RNDAddRef(service->Parent);
  3251. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3252. headerBuffer = (char*)MALLOC(168 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3253. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetPositionInfo",bufferLength);
  3254. memset((char *)&addr, 0, sizeof(addr));
  3255. addr.sin_family = AF_INET;
  3256. addr.sin_addr.s_addr = inet_addr(IP);
  3257. addr.sin_port = htons(Port);
  3258. invoke_data->CallbackPtr = CallbackPtr;
  3259. invoke_data->User = user;
  3260. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetPositionInfo_Sink, service, invoke_data);
  3261. FREE(IP);
  3262. FREE(Path);
  3263. }
  3264. void RNDInvoke_AVTransport_GetTransportInfo_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3265. {
  3266. struct UPnPService *Service = (struct UPnPService*)_service;
  3267. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3268. int ArgLeft = 3;
  3269. struct ILibXMLNode *xml;
  3270. struct ILibXMLNode *__xml;
  3271. char *tempBuffer;
  3272. int tempBufferLength;
  3273. char* CurrentTransportState = NULL;
  3274. char* CurrentTransportStatus = NULL;
  3275. char* CurrentSpeed = NULL;
  3276. if(done==0){return;}
  3277. if(_InvokeData->CallbackPtr==NULL)
  3278. {
  3279. RNDRelease(Service->Parent);
  3280. FREE(_InvokeData);
  3281. return;
  3282. }
  3283. else
  3284. {
  3285. if(header==NULL)
  3286. {
  3287. /* Connection Failed */
  3288. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3289. RNDRelease(Service->Parent);
  3290. FREE(_InvokeData);
  3291. return;
  3292. }
  3293. else if(header->StatusCode!=200)
  3294. {
  3295. /* SOAP Fault */
  3296. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3297. RNDRelease(Service->Parent);
  3298. FREE(_InvokeData);
  3299. return;
  3300. }
  3301. }
  3302. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  3303. ILibProcessXMLNodeList(xml);
  3304. while(xml!=NULL)
  3305. {
  3306. if(xml->NameLength==24 && memcmp(xml->Name,"GetTransportInfoResponse",24)==0)
  3307. {
  3308. xml = xml->Next;
  3309. while(xml!=NULL)
  3310. {
  3311. if(xml->NameLength==21 && memcmp(xml->Name,"CurrentTransportState",21) == 0)
  3312. {
  3313. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3314. --ArgLeft;
  3315. if(tempBufferLength!=0)
  3316. {
  3317. tempBuffer[tempBufferLength] = '\0';
  3318. CurrentTransportState = tempBuffer;
  3319. }
  3320. }
  3321. else
  3322. if(xml->NameLength==22 && memcmp(xml->Name,"CurrentTransportStatus",22) == 0)
  3323. {
  3324. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3325. --ArgLeft;
  3326. if(tempBufferLength!=0)
  3327. {
  3328. tempBuffer[tempBufferLength] = '\0';
  3329. CurrentTransportStatus = tempBuffer;
  3330. }
  3331. }
  3332. else
  3333. if(xml->NameLength==12 && memcmp(xml->Name,"CurrentSpeed",12) == 0)
  3334. {
  3335. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3336. --ArgLeft;
  3337. if(tempBufferLength!=0)
  3338. {
  3339. tempBuffer[tempBufferLength] = '\0';
  3340. CurrentSpeed = tempBuffer;
  3341. }
  3342. }
  3343. xml = xml->Peer;
  3344. }
  3345. }
  3346. if(xml!=NULL) {xml = xml->Next;}
  3347. }
  3348. ILibDestructXMLNodeList(__xml);
  3349. if(ArgLeft!=0)
  3350. {
  3351. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3352. }
  3353. else
  3354. {
  3355. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentTransportState,CurrentTransportStatus,CurrentSpeed);
  3356. }
  3357. RNDRelease(Service->Parent);
  3358. FREE(_InvokeData);
  3359. }
  3360. void RNDInvoke_AVTransport_GetTransportInfo(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*,char*,char*), void* user, unsigned int InstanceID)
  3361. {
  3362. int headerLength;
  3363. char *headerBuffer;
  3364. char *SoapBodyTemplate;
  3365. char* buffer;
  3366. int bufferLength;
  3367. char* IP;
  3368. unsigned short Port;
  3369. char* Path;
  3370. struct sockaddr_in addr;
  3371. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3372. if(service==NULL)
  3373. {
  3374. FREE(invoke_data);
  3375. return;
  3376. }
  3377. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+299);
  3378. SoapBodyTemplate = "%sGetTransportInfo xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetTransportInfo%s";
  3379. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3380. RNDAddRef(service->Parent);
  3381. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3382. headerBuffer = (char*)MALLOC(169 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3383. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetTransportInfo",bufferLength);
  3384. memset((char *)&addr, 0, sizeof(addr));
  3385. addr.sin_family = AF_INET;
  3386. addr.sin_addr.s_addr = inet_addr(IP);
  3387. addr.sin_port = htons(Port);
  3388. invoke_data->CallbackPtr = CallbackPtr;
  3389. invoke_data->User = user;
  3390. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetTransportInfo_Sink, service, invoke_data);
  3391. FREE(IP);
  3392. FREE(Path);
  3393. }
  3394. void RNDInvoke_AVTransport_SetAVTransportURI_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3395. {
  3396. struct UPnPService *Service = (struct UPnPService*)_service;
  3397. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3398. if(done==0){return;}
  3399. if(_InvokeData->CallbackPtr==NULL)
  3400. {
  3401. RNDRelease(Service->Parent);
  3402. FREE(_InvokeData);
  3403. return;
  3404. }
  3405. else
  3406. {
  3407. if(header==NULL)
  3408. {
  3409. /* Connection Failed */
  3410. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  3411. RNDRelease(Service->Parent);
  3412. FREE(_InvokeData);
  3413. return;
  3414. }
  3415. else if(header->StatusCode!=200)
  3416. {
  3417. /* SOAP Fault */
  3418. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  3419. RNDRelease(Service->Parent);
  3420. FREE(_InvokeData);
  3421. return;
  3422. }
  3423. }
  3424. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  3425. RNDRelease(Service->Parent);
  3426. FREE(_InvokeData);
  3427. }
  3428. void RNDInvoke_AVTransport_SetAVTransportURI(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* CurrentURI, char* CurrentURIMetaData)
  3429. {
  3430. int headerLength;
  3431. char *headerBuffer;
  3432. char *SoapBodyTemplate;
  3433. char* buffer;
  3434. int bufferLength;
  3435. char* IP;
  3436. unsigned short Port;
  3437. char* Path;
  3438. struct sockaddr_in addr;
  3439. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3440. if(service==NULL)
  3441. {
  3442. FREE(invoke_data);
  3443. return;
  3444. }
  3445. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(CurrentURI)+(int)strlen(CurrentURIMetaData)+367);
  3446. SoapBodyTemplate = "%sSetAVTransportURI xmlns:u=\"%s\"><InstanceID>%u</InstanceID><CurrentURI>%s</CurrentURI><CurrentURIMetaData>%s</CurrentURIMetaData></u:SetAVTransportURI%s";
  3447. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, CurrentURI, CurrentURIMetaData,UPNPCP_SOAP_BodyTail);
  3448. RNDAddRef(service->Parent);
  3449. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3450. headerBuffer = (char*)MALLOC(170 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3451. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetAVTransportURI",bufferLength);
  3452. memset((char *)&addr, 0, sizeof(addr));
  3453. addr.sin_family = AF_INET;
  3454. addr.sin_addr.s_addr = inet_addr(IP);
  3455. addr.sin_port = htons(Port);
  3456. invoke_data->CallbackPtr = CallbackPtr;
  3457. invoke_data->User = user;
  3458. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_SetAVTransportURI_Sink, service, invoke_data);
  3459. FREE(IP);
  3460. FREE(Path);
  3461. }
  3462. void RNDInvoke_AVTransport_GetDeviceCapabilities_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3463. {
  3464. struct UPnPService *Service = (struct UPnPService*)_service;
  3465. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3466. int ArgLeft = 3;
  3467. struct ILibXMLNode *xml;
  3468. struct ILibXMLNode *__xml;
  3469. char *tempBuffer;
  3470. int tempBufferLength;
  3471. char* PlayMedia = NULL;
  3472. char* RecMedia = NULL;
  3473. char* RecQualityModes = NULL;
  3474. if(done==0){return;}
  3475. if(_InvokeData->CallbackPtr==NULL)
  3476. {
  3477. RNDRelease(Service->Parent);
  3478. FREE(_InvokeData);
  3479. return;
  3480. }
  3481. else
  3482. {
  3483. if(header==NULL)
  3484. {
  3485. /* Connection Failed */
  3486. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3487. RNDRelease(Service->Parent);
  3488. FREE(_InvokeData);
  3489. return;
  3490. }
  3491. else if(header->StatusCode!=200)
  3492. {
  3493. /* SOAP Fault */
  3494. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3495. RNDRelease(Service->Parent);
  3496. FREE(_InvokeData);
  3497. return;
  3498. }
  3499. }
  3500. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  3501. ILibProcessXMLNodeList(xml);
  3502. while(xml!=NULL)
  3503. {
  3504. if(xml->NameLength==29 && memcmp(xml->Name,"GetDeviceCapabilitiesResponse",29)==0)
  3505. {
  3506. xml = xml->Next;
  3507. while(xml!=NULL)
  3508. {
  3509. if(xml->NameLength==9 && memcmp(xml->Name,"PlayMedia",9) == 0)
  3510. {
  3511. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3512. --ArgLeft;
  3513. if(tempBufferLength!=0)
  3514. {
  3515. tempBuffer[tempBufferLength] = '\0';
  3516. PlayMedia = tempBuffer;
  3517. }
  3518. }
  3519. else
  3520. if(xml->NameLength==8 && memcmp(xml->Name,"RecMedia",8) == 0)
  3521. {
  3522. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3523. --ArgLeft;
  3524. if(tempBufferLength!=0)
  3525. {
  3526. tempBuffer[tempBufferLength] = '\0';
  3527. RecMedia = tempBuffer;
  3528. }
  3529. }
  3530. else
  3531. if(xml->NameLength==15 && memcmp(xml->Name,"RecQualityModes",15) == 0)
  3532. {
  3533. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3534. --ArgLeft;
  3535. if(tempBufferLength!=0)
  3536. {
  3537. tempBuffer[tempBufferLength] = '\0';
  3538. RecQualityModes = tempBuffer;
  3539. }
  3540. }
  3541. xml = xml->Peer;
  3542. }
  3543. }
  3544. if(xml!=NULL) {xml = xml->Next;}
  3545. }
  3546. ILibDestructXMLNodeList(__xml);
  3547. if(ArgLeft!=0)
  3548. {
  3549. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3550. }
  3551. else
  3552. {
  3553. ((void (*)(struct UPnPService*,int,void*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,PlayMedia,RecMedia,RecQualityModes);
  3554. }
  3555. RNDRelease(Service->Parent);
  3556. FREE(_InvokeData);
  3557. }
  3558. void RNDInvoke_AVTransport_GetDeviceCapabilities(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*,char*,char*), void* user, unsigned int InstanceID)
  3559. {
  3560. int headerLength;
  3561. char *headerBuffer;
  3562. char *SoapBodyTemplate;
  3563. char* buffer;
  3564. int bufferLength;
  3565. char* IP;
  3566. unsigned short Port;
  3567. char* Path;
  3568. struct sockaddr_in addr;
  3569. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3570. if(service==NULL)
  3571. {
  3572. FREE(invoke_data);
  3573. return;
  3574. }
  3575. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+309);
  3576. SoapBodyTemplate = "%sGetDeviceCapabilities xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetDeviceCapabilities%s";
  3577. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3578. RNDAddRef(service->Parent);
  3579. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3580. headerBuffer = (char*)MALLOC(174 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3581. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetDeviceCapabilities",bufferLength);
  3582. memset((char *)&addr, 0, sizeof(addr));
  3583. addr.sin_family = AF_INET;
  3584. addr.sin_addr.s_addr = inet_addr(IP);
  3585. addr.sin_port = htons(Port);
  3586. invoke_data->CallbackPtr = CallbackPtr;
  3587. invoke_data->User = user;
  3588. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetDeviceCapabilities_Sink, service, invoke_data);
  3589. FREE(IP);
  3590. FREE(Path);
  3591. }
  3592. void RNDInvoke_AVTransport_SetPlayMode_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3593. {
  3594. struct UPnPService *Service = (struct UPnPService*)_service;
  3595. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3596. if(done==0){return;}
  3597. if(_InvokeData->CallbackPtr==NULL)
  3598. {
  3599. RNDRelease(Service->Parent);
  3600. FREE(_InvokeData);
  3601. return;
  3602. }
  3603. else
  3604. {
  3605. if(header==NULL)
  3606. {
  3607. /* Connection Failed */
  3608. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  3609. RNDRelease(Service->Parent);
  3610. FREE(_InvokeData);
  3611. return;
  3612. }
  3613. else if(header->StatusCode!=200)
  3614. {
  3615. /* SOAP Fault */
  3616. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  3617. RNDRelease(Service->Parent);
  3618. FREE(_InvokeData);
  3619. return;
  3620. }
  3621. }
  3622. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  3623. RNDRelease(Service->Parent);
  3624. FREE(_InvokeData);
  3625. }
  3626. void RNDInvoke_AVTransport_SetPlayMode(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* NewPlayMode)
  3627. {
  3628. int headerLength;
  3629. char *headerBuffer;
  3630. char *SoapBodyTemplate;
  3631. char* buffer;
  3632. int bufferLength;
  3633. char* IP;
  3634. unsigned short Port;
  3635. char* Path;
  3636. struct sockaddr_in addr;
  3637. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3638. if(service==NULL)
  3639. {
  3640. FREE(invoke_data);
  3641. return;
  3642. }
  3643. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(NewPlayMode)+316);
  3644. SoapBodyTemplate = "%sSetPlayMode xmlns:u=\"%s\"><InstanceID>%u</InstanceID><NewPlayMode>%s</NewPlayMode></u:SetPlayMode%s";
  3645. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, NewPlayMode,UPNPCP_SOAP_BodyTail);
  3646. RNDAddRef(service->Parent);
  3647. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3648. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3649. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetPlayMode",bufferLength);
  3650. memset((char *)&addr, 0, sizeof(addr));
  3651. addr.sin_family = AF_INET;
  3652. addr.sin_addr.s_addr = inet_addr(IP);
  3653. addr.sin_port = htons(Port);
  3654. invoke_data->CallbackPtr = CallbackPtr;
  3655. invoke_data->User = user;
  3656. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_SetPlayMode_Sink, service, invoke_data);
  3657. FREE(IP);
  3658. FREE(Path);
  3659. }
  3660. void RNDInvoke_AVTransport_GetMediaInfo_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3661. {
  3662. struct UPnPService *Service = (struct UPnPService*)_service;
  3663. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3664. int ArgLeft = 9;
  3665. struct ILibXMLNode *xml;
  3666. struct ILibXMLNode *__xml;
  3667. char *tempBuffer;
  3668. int tempBufferLength;
  3669. unsigned long TempULong;
  3670. unsigned int NrTracks = 0;
  3671. char* MediaDuration = NULL;
  3672. char* CurrentURI = NULL;
  3673. char* CurrentURIMetaData = NULL;
  3674. char* NextURI = NULL;
  3675. char* NextURIMetaData = NULL;
  3676. char* PlayMedium = NULL;
  3677. char* RecordMedium = NULL;
  3678. char* WriteStatus = NULL;
  3679. if(done==0){return;}
  3680. if(_InvokeData->CallbackPtr==NULL)
  3681. {
  3682. RNDRelease(Service->Parent);
  3683. FREE(_InvokeData);
  3684. return;
  3685. }
  3686. else
  3687. {
  3688. if(header==NULL)
  3689. {
  3690. /* Connection Failed */
  3691. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3692. RNDRelease(Service->Parent);
  3693. FREE(_InvokeData);
  3694. return;
  3695. }
  3696. else if(header->StatusCode!=200)
  3697. {
  3698. /* SOAP Fault */
  3699. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3700. RNDRelease(Service->Parent);
  3701. FREE(_InvokeData);
  3702. return;
  3703. }
  3704. }
  3705. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  3706. ILibProcessXMLNodeList(xml);
  3707. while(xml!=NULL)
  3708. {
  3709. if(xml->NameLength==20 && memcmp(xml->Name,"GetMediaInfoResponse",20)==0)
  3710. {
  3711. xml = xml->Next;
  3712. while(xml!=NULL)
  3713. {
  3714. if(xml->NameLength==8 && memcmp(xml->Name,"NrTracks",8) == 0)
  3715. {
  3716. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3717. --ArgLeft;
  3718. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  3719. {
  3720. NrTracks = (unsigned int) TempULong;
  3721. }
  3722. }
  3723. else
  3724. if(xml->NameLength==13 && memcmp(xml->Name,"MediaDuration",13) == 0)
  3725. {
  3726. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3727. --ArgLeft;
  3728. if(tempBufferLength!=0)
  3729. {
  3730. tempBuffer[tempBufferLength] = '\0';
  3731. MediaDuration = tempBuffer;
  3732. }
  3733. }
  3734. else
  3735. if(xml->NameLength==10 && memcmp(xml->Name,"CurrentURI",10) == 0)
  3736. {
  3737. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3738. --ArgLeft;
  3739. if(tempBufferLength!=0)
  3740. {
  3741. tempBuffer[tempBufferLength] = '\0';
  3742. CurrentURI = tempBuffer;
  3743. }
  3744. }
  3745. else
  3746. if(xml->NameLength==18 && memcmp(xml->Name,"CurrentURIMetaData",18) == 0)
  3747. {
  3748. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3749. --ArgLeft;
  3750. if(tempBufferLength!=0)
  3751. {
  3752. tempBuffer[tempBufferLength] = '\0';
  3753. CurrentURIMetaData = tempBuffer;
  3754. }
  3755. }
  3756. else
  3757. if(xml->NameLength==7 && memcmp(xml->Name,"NextURI",7) == 0)
  3758. {
  3759. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3760. --ArgLeft;
  3761. if(tempBufferLength!=0)
  3762. {
  3763. tempBuffer[tempBufferLength] = '\0';
  3764. NextURI = tempBuffer;
  3765. }
  3766. }
  3767. else
  3768. if(xml->NameLength==15 && memcmp(xml->Name,"NextURIMetaData",15) == 0)
  3769. {
  3770. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3771. --ArgLeft;
  3772. if(tempBufferLength!=0)
  3773. {
  3774. tempBuffer[tempBufferLength] = '\0';
  3775. NextURIMetaData = tempBuffer;
  3776. }
  3777. }
  3778. else
  3779. if(xml->NameLength==10 && memcmp(xml->Name,"PlayMedium",10) == 0)
  3780. {
  3781. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3782. --ArgLeft;
  3783. if(tempBufferLength!=0)
  3784. {
  3785. tempBuffer[tempBufferLength] = '\0';
  3786. PlayMedium = tempBuffer;
  3787. }
  3788. }
  3789. else
  3790. if(xml->NameLength==12 && memcmp(xml->Name,"RecordMedium",12) == 0)
  3791. {
  3792. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3793. --ArgLeft;
  3794. if(tempBufferLength!=0)
  3795. {
  3796. tempBuffer[tempBufferLength] = '\0';
  3797. RecordMedium = tempBuffer;
  3798. }
  3799. }
  3800. else
  3801. if(xml->NameLength==11 && memcmp(xml->Name,"WriteStatus",11) == 0)
  3802. {
  3803. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3804. --ArgLeft;
  3805. if(tempBufferLength!=0)
  3806. {
  3807. tempBuffer[tempBufferLength] = '\0';
  3808. WriteStatus = tempBuffer;
  3809. }
  3810. }
  3811. xml = xml->Peer;
  3812. }
  3813. }
  3814. if(xml!=NULL) {xml = xml->Next;}
  3815. }
  3816. ILibDestructXMLNodeList(__xml);
  3817. if(ArgLeft!=0)
  3818. {
  3819. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA,INVALID_DATA);
  3820. }
  3821. else
  3822. {
  3823. ((void (*)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,char*,char*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,NrTracks,MediaDuration,CurrentURI,CurrentURIMetaData,NextURI,NextURIMetaData,PlayMedium,RecordMedium,WriteStatus);
  3824. }
  3825. RNDRelease(Service->Parent);
  3826. FREE(_InvokeData);
  3827. }
  3828. void RNDInvoke_AVTransport_GetMediaInfo(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned int,char*,char*,char*,char*,char*,char*,char*,char*), void* user, unsigned int InstanceID)
  3829. {
  3830. int headerLength;
  3831. char *headerBuffer;
  3832. char *SoapBodyTemplate;
  3833. char* buffer;
  3834. int bufferLength;
  3835. char* IP;
  3836. unsigned short Port;
  3837. char* Path;
  3838. struct sockaddr_in addr;
  3839. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3840. if(service==NULL)
  3841. {
  3842. FREE(invoke_data);
  3843. return;
  3844. }
  3845. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+291);
  3846. SoapBodyTemplate = "%sGetMediaInfo xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetMediaInfo%s";
  3847. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3848. RNDAddRef(service->Parent);
  3849. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3850. headerBuffer = (char*)MALLOC(165 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3851. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetMediaInfo",bufferLength);
  3852. memset((char *)&addr, 0, sizeof(addr));
  3853. addr.sin_family = AF_INET;
  3854. addr.sin_addr.s_addr = inet_addr(IP);
  3855. addr.sin_port = htons(Port);
  3856. invoke_data->CallbackPtr = CallbackPtr;
  3857. invoke_data->User = user;
  3858. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_AVTransport_GetMediaInfo_Sink, service, invoke_data);
  3859. FREE(IP);
  3860. FREE(Path);
  3861. }
  3862. void RNDInvoke_RenderingControl_GetHorizontalKeystone_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3863. {
  3864. struct UPnPService *Service = (struct UPnPService*)_service;
  3865. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3866. int ArgLeft = 1;
  3867. struct ILibXMLNode *xml;
  3868. struct ILibXMLNode *__xml;
  3869. char *tempBuffer;
  3870. int tempBufferLength;
  3871. long TempLong;
  3872. short CurrentHorizontalKeystone = 0;
  3873. if(done==0){return;}
  3874. if(_InvokeData->CallbackPtr==NULL)
  3875. {
  3876. RNDRelease(Service->Parent);
  3877. FREE(_InvokeData);
  3878. return;
  3879. }
  3880. else
  3881. {
  3882. if(header==NULL)
  3883. {
  3884. /* Connection Failed */
  3885. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  3886. RNDRelease(Service->Parent);
  3887. FREE(_InvokeData);
  3888. return;
  3889. }
  3890. else if(header->StatusCode!=200)
  3891. {
  3892. /* SOAP Fault */
  3893. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  3894. RNDRelease(Service->Parent);
  3895. FREE(_InvokeData);
  3896. return;
  3897. }
  3898. }
  3899. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  3900. ILibProcessXMLNodeList(xml);
  3901. while(xml!=NULL)
  3902. {
  3903. if(xml->NameLength==29 && memcmp(xml->Name,"GetHorizontalKeystoneResponse",29)==0)
  3904. {
  3905. xml = xml->Next;
  3906. while(xml!=NULL)
  3907. {
  3908. if(xml->NameLength==25 && memcmp(xml->Name,"CurrentHorizontalKeystone",25) == 0)
  3909. {
  3910. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  3911. --ArgLeft;
  3912. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  3913. {
  3914. CurrentHorizontalKeystone = (short) TempLong;
  3915. }
  3916. }
  3917. xml = xml->Peer;
  3918. }
  3919. }
  3920. if(xml!=NULL) {xml = xml->Next;}
  3921. }
  3922. ILibDestructXMLNodeList(__xml);
  3923. if(ArgLeft!=0)
  3924. {
  3925. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  3926. }
  3927. else
  3928. {
  3929. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentHorizontalKeystone);
  3930. }
  3931. RNDRelease(Service->Parent);
  3932. FREE(_InvokeData);
  3933. }
  3934. void RNDInvoke_RenderingControl_GetHorizontalKeystone(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,short), void* user, unsigned int InstanceID)
  3935. {
  3936. int headerLength;
  3937. char *headerBuffer;
  3938. char *SoapBodyTemplate;
  3939. char* buffer;
  3940. int bufferLength;
  3941. char* IP;
  3942. unsigned short Port;
  3943. char* Path;
  3944. struct sockaddr_in addr;
  3945. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  3946. if(service==NULL)
  3947. {
  3948. FREE(invoke_data);
  3949. return;
  3950. }
  3951. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+309);
  3952. SoapBodyTemplate = "%sGetHorizontalKeystone xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetHorizontalKeystone%s";
  3953. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  3954. RNDAddRef(service->Parent);
  3955. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  3956. headerBuffer = (char*)MALLOC(174 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  3957. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetHorizontalKeystone",bufferLength);
  3958. memset((char *)&addr, 0, sizeof(addr));
  3959. addr.sin_family = AF_INET;
  3960. addr.sin_addr.s_addr = inet_addr(IP);
  3961. addr.sin_port = htons(Port);
  3962. invoke_data->CallbackPtr = CallbackPtr;
  3963. invoke_data->User = user;
  3964. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetHorizontalKeystone_Sink, service, invoke_data);
  3965. FREE(IP);
  3966. FREE(Path);
  3967. }
  3968. void RNDInvoke_RenderingControl_GetVolume_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  3969. {
  3970. struct UPnPService *Service = (struct UPnPService*)_service;
  3971. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  3972. int ArgLeft = 1;
  3973. struct ILibXMLNode *xml;
  3974. struct ILibXMLNode *__xml;
  3975. char *tempBuffer;
  3976. int tempBufferLength;
  3977. unsigned long TempULong;
  3978. unsigned short CurrentVolume = 0;
  3979. if(done==0){return;}
  3980. if(_InvokeData->CallbackPtr==NULL)
  3981. {
  3982. RNDRelease(Service->Parent);
  3983. FREE(_InvokeData);
  3984. return;
  3985. }
  3986. else
  3987. {
  3988. if(header==NULL)
  3989. {
  3990. /* Connection Failed */
  3991. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  3992. RNDRelease(Service->Parent);
  3993. FREE(_InvokeData);
  3994. return;
  3995. }
  3996. else if(header->StatusCode!=200)
  3997. {
  3998. /* SOAP Fault */
  3999. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  4000. RNDRelease(Service->Parent);
  4001. FREE(_InvokeData);
  4002. return;
  4003. }
  4004. }
  4005. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  4006. ILibProcessXMLNodeList(xml);
  4007. while(xml!=NULL)
  4008. {
  4009. if(xml->NameLength==17 && memcmp(xml->Name,"GetVolumeResponse",17)==0)
  4010. {
  4011. xml = xml->Next;
  4012. while(xml!=NULL)
  4013. {
  4014. if(xml->NameLength==13 && memcmp(xml->Name,"CurrentVolume",13) == 0)
  4015. {
  4016. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  4017. --ArgLeft;
  4018. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  4019. {
  4020. CurrentVolume = (unsigned short) TempULong;
  4021. }
  4022. }
  4023. xml = xml->Peer;
  4024. }
  4025. }
  4026. if(xml!=NULL) {xml = xml->Next;}
  4027. }
  4028. ILibDestructXMLNodeList(__xml);
  4029. if(ArgLeft!=0)
  4030. {
  4031. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  4032. }
  4033. else
  4034. {
  4035. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentVolume);
  4036. }
  4037. RNDRelease(Service->Parent);
  4038. FREE(_InvokeData);
  4039. }
  4040. void RNDInvoke_RenderingControl_GetVolume(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID, char* Channel)
  4041. {
  4042. int headerLength;
  4043. char *headerBuffer;
  4044. char *SoapBodyTemplate;
  4045. char* buffer;
  4046. int bufferLength;
  4047. char* IP;
  4048. unsigned short Port;
  4049. char* Path;
  4050. struct sockaddr_in addr;
  4051. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4052. if(service==NULL)
  4053. {
  4054. FREE(invoke_data);
  4055. return;
  4056. }
  4057. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+304);
  4058. SoapBodyTemplate = "%sGetVolume xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel></u:GetVolume%s";
  4059. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel,UPNPCP_SOAP_BodyTail);
  4060. RNDAddRef(service->Parent);
  4061. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4062. headerBuffer = (char*)MALLOC(162 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4063. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetVolume",bufferLength);
  4064. memset((char *)&addr, 0, sizeof(addr));
  4065. addr.sin_family = AF_INET;
  4066. addr.sin_addr.s_addr = inet_addr(IP);
  4067. addr.sin_port = htons(Port);
  4068. invoke_data->CallbackPtr = CallbackPtr;
  4069. invoke_data->User = user;
  4070. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetVolume_Sink, service, invoke_data);
  4071. FREE(IP);
  4072. FREE(Path);
  4073. }
  4074. void RNDInvoke_RenderingControl_SelectPreset_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4075. {
  4076. struct UPnPService *Service = (struct UPnPService*)_service;
  4077. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4078. if(done==0){return;}
  4079. if(_InvokeData->CallbackPtr==NULL)
  4080. {
  4081. RNDRelease(Service->Parent);
  4082. FREE(_InvokeData);
  4083. return;
  4084. }
  4085. else
  4086. {
  4087. if(header==NULL)
  4088. {
  4089. /* Connection Failed */
  4090. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4091. RNDRelease(Service->Parent);
  4092. FREE(_InvokeData);
  4093. return;
  4094. }
  4095. else if(header->StatusCode!=200)
  4096. {
  4097. /* SOAP Fault */
  4098. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4099. RNDRelease(Service->Parent);
  4100. FREE(_InvokeData);
  4101. return;
  4102. }
  4103. }
  4104. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4105. RNDRelease(Service->Parent);
  4106. FREE(_InvokeData);
  4107. }
  4108. void RNDInvoke_RenderingControl_SelectPreset(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* PresetName)
  4109. {
  4110. int headerLength;
  4111. char *headerBuffer;
  4112. char *SoapBodyTemplate;
  4113. char* buffer;
  4114. int bufferLength;
  4115. char* IP;
  4116. unsigned short Port;
  4117. char* Path;
  4118. struct sockaddr_in addr;
  4119. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4120. if(service==NULL)
  4121. {
  4122. FREE(invoke_data);
  4123. return;
  4124. }
  4125. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(PresetName)+316);
  4126. SoapBodyTemplate = "%sSelectPreset xmlns:u=\"%s\"><InstanceID>%u</InstanceID><PresetName>%s</PresetName></u:SelectPreset%s";
  4127. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, PresetName,UPNPCP_SOAP_BodyTail);
  4128. RNDAddRef(service->Parent);
  4129. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4130. headerBuffer = (char*)MALLOC(165 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4131. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SelectPreset",bufferLength);
  4132. memset((char *)&addr, 0, sizeof(addr));
  4133. addr.sin_family = AF_INET;
  4134. addr.sin_addr.s_addr = inet_addr(IP);
  4135. addr.sin_port = htons(Port);
  4136. invoke_data->CallbackPtr = CallbackPtr;
  4137. invoke_data->User = user;
  4138. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SelectPreset_Sink, service, invoke_data);
  4139. FREE(IP);
  4140. FREE(Path);
  4141. }
  4142. void RNDInvoke_RenderingControl_SetVolume_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4143. {
  4144. struct UPnPService *Service = (struct UPnPService*)_service;
  4145. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4146. if(done==0){return;}
  4147. if(_InvokeData->CallbackPtr==NULL)
  4148. {
  4149. RNDRelease(Service->Parent);
  4150. FREE(_InvokeData);
  4151. return;
  4152. }
  4153. else
  4154. {
  4155. if(header==NULL)
  4156. {
  4157. /* Connection Failed */
  4158. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4159. RNDRelease(Service->Parent);
  4160. FREE(_InvokeData);
  4161. return;
  4162. }
  4163. else if(header->StatusCode!=200)
  4164. {
  4165. /* SOAP Fault */
  4166. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4167. RNDRelease(Service->Parent);
  4168. FREE(_InvokeData);
  4169. return;
  4170. }
  4171. }
  4172. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4173. RNDRelease(Service->Parent);
  4174. FREE(_InvokeData);
  4175. }
  4176. void RNDInvoke_RenderingControl_SetVolume(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Channel, unsigned short DesiredVolume)
  4177. {
  4178. int headerLength;
  4179. char *headerBuffer;
  4180. char *SoapBodyTemplate;
  4181. char* buffer;
  4182. int bufferLength;
  4183. char* IP;
  4184. unsigned short Port;
  4185. char* Path;
  4186. struct sockaddr_in addr;
  4187. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4188. if(service==NULL)
  4189. {
  4190. FREE(invoke_data);
  4191. return;
  4192. }
  4193. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+340);
  4194. SoapBodyTemplate = "%sSetVolume xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel><DesiredVolume>%u</DesiredVolume></u:SetVolume%s";
  4195. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel, DesiredVolume,UPNPCP_SOAP_BodyTail);
  4196. RNDAddRef(service->Parent);
  4197. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4198. headerBuffer = (char*)MALLOC(162 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4199. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetVolume",bufferLength);
  4200. memset((char *)&addr, 0, sizeof(addr));
  4201. addr.sin_family = AF_INET;
  4202. addr.sin_addr.s_addr = inet_addr(IP);
  4203. addr.sin_port = htons(Port);
  4204. invoke_data->CallbackPtr = CallbackPtr;
  4205. invoke_data->User = user;
  4206. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetVolume_Sink, service, invoke_data);
  4207. FREE(IP);
  4208. FREE(Path);
  4209. }
  4210. void RNDInvoke_RenderingControl_ListPresets_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4211. {
  4212. struct UPnPService *Service = (struct UPnPService*)_service;
  4213. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4214. int ArgLeft = 1;
  4215. struct ILibXMLNode *xml;
  4216. struct ILibXMLNode *__xml;
  4217. char *tempBuffer;
  4218. int tempBufferLength;
  4219. char* CurrentPresetNameList = NULL;
  4220. if(done==0){return;}
  4221. if(_InvokeData->CallbackPtr==NULL)
  4222. {
  4223. RNDRelease(Service->Parent);
  4224. FREE(_InvokeData);
  4225. return;
  4226. }
  4227. else
  4228. {
  4229. if(header==NULL)
  4230. {
  4231. /* Connection Failed */
  4232. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  4233. RNDRelease(Service->Parent);
  4234. FREE(_InvokeData);
  4235. return;
  4236. }
  4237. else if(header->StatusCode!=200)
  4238. {
  4239. /* SOAP Fault */
  4240. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  4241. RNDRelease(Service->Parent);
  4242. FREE(_InvokeData);
  4243. return;
  4244. }
  4245. }
  4246. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  4247. ILibProcessXMLNodeList(xml);
  4248. while(xml!=NULL)
  4249. {
  4250. if(xml->NameLength==19 && memcmp(xml->Name,"ListPresetsResponse",19)==0)
  4251. {
  4252. xml = xml->Next;
  4253. while(xml!=NULL)
  4254. {
  4255. if(xml->NameLength==21 && memcmp(xml->Name,"CurrentPresetNameList",21) == 0)
  4256. {
  4257. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  4258. --ArgLeft;
  4259. if(tempBufferLength!=0)
  4260. {
  4261. tempBuffer[tempBufferLength] = '\0';
  4262. CurrentPresetNameList = tempBuffer;
  4263. }
  4264. }
  4265. xml = xml->Peer;
  4266. }
  4267. }
  4268. if(xml!=NULL) {xml = xml->Next;}
  4269. }
  4270. ILibDestructXMLNodeList(__xml);
  4271. if(ArgLeft!=0)
  4272. {
  4273. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  4274. }
  4275. else
  4276. {
  4277. ((void (*)(struct UPnPService*,int,void*,char*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentPresetNameList);
  4278. }
  4279. RNDRelease(Service->Parent);
  4280. FREE(_InvokeData);
  4281. }
  4282. void RNDInvoke_RenderingControl_ListPresets(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,char*), void* user, unsigned int InstanceID)
  4283. {
  4284. int headerLength;
  4285. char *headerBuffer;
  4286. char *SoapBodyTemplate;
  4287. char* buffer;
  4288. int bufferLength;
  4289. char* IP;
  4290. unsigned short Port;
  4291. char* Path;
  4292. struct sockaddr_in addr;
  4293. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4294. if(service==NULL)
  4295. {
  4296. FREE(invoke_data);
  4297. return;
  4298. }
  4299. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+289);
  4300. SoapBodyTemplate = "%sListPresets xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:ListPresets%s";
  4301. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  4302. RNDAddRef(service->Parent);
  4303. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4304. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4305. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"ListPresets",bufferLength);
  4306. memset((char *)&addr, 0, sizeof(addr));
  4307. addr.sin_family = AF_INET;
  4308. addr.sin_addr.s_addr = inet_addr(IP);
  4309. addr.sin_port = htons(Port);
  4310. invoke_data->CallbackPtr = CallbackPtr;
  4311. invoke_data->User = user;
  4312. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_ListPresets_Sink, service, invoke_data);
  4313. FREE(IP);
  4314. FREE(Path);
  4315. }
  4316. void RNDInvoke_RenderingControl_SetVolumeDB_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4317. {
  4318. struct UPnPService *Service = (struct UPnPService*)_service;
  4319. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4320. if(done==0){return;}
  4321. if(_InvokeData->CallbackPtr==NULL)
  4322. {
  4323. RNDRelease(Service->Parent);
  4324. FREE(_InvokeData);
  4325. return;
  4326. }
  4327. else
  4328. {
  4329. if(header==NULL)
  4330. {
  4331. /* Connection Failed */
  4332. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4333. RNDRelease(Service->Parent);
  4334. FREE(_InvokeData);
  4335. return;
  4336. }
  4337. else if(header->StatusCode!=200)
  4338. {
  4339. /* SOAP Fault */
  4340. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4341. RNDRelease(Service->Parent);
  4342. FREE(_InvokeData);
  4343. return;
  4344. }
  4345. }
  4346. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4347. RNDRelease(Service->Parent);
  4348. FREE(_InvokeData);
  4349. }
  4350. void RNDInvoke_RenderingControl_SetVolumeDB(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Channel, short DesiredVolume)
  4351. {
  4352. int headerLength;
  4353. char *headerBuffer;
  4354. char *SoapBodyTemplate;
  4355. char* buffer;
  4356. int bufferLength;
  4357. char* IP;
  4358. unsigned short Port;
  4359. char* Path;
  4360. struct sockaddr_in addr;
  4361. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4362. if(service==NULL)
  4363. {
  4364. FREE(invoke_data);
  4365. return;
  4366. }
  4367. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+345);
  4368. SoapBodyTemplate = "%sSetVolumeDB xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel><DesiredVolume>%d</DesiredVolume></u:SetVolumeDB%s";
  4369. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel, DesiredVolume,UPNPCP_SOAP_BodyTail);
  4370. RNDAddRef(service->Parent);
  4371. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4372. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4373. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetVolumeDB",bufferLength);
  4374. memset((char *)&addr, 0, sizeof(addr));
  4375. addr.sin_family = AF_INET;
  4376. addr.sin_addr.s_addr = inet_addr(IP);
  4377. addr.sin_port = htons(Port);
  4378. invoke_data->CallbackPtr = CallbackPtr;
  4379. invoke_data->User = user;
  4380. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetVolumeDB_Sink, service, invoke_data);
  4381. FREE(IP);
  4382. FREE(Path);
  4383. }
  4384. void RNDInvoke_RenderingControl_SetRedVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4385. {
  4386. struct UPnPService *Service = (struct UPnPService*)_service;
  4387. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4388. if(done==0){return;}
  4389. if(_InvokeData->CallbackPtr==NULL)
  4390. {
  4391. RNDRelease(Service->Parent);
  4392. FREE(_InvokeData);
  4393. return;
  4394. }
  4395. else
  4396. {
  4397. if(header==NULL)
  4398. {
  4399. /* Connection Failed */
  4400. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4401. RNDRelease(Service->Parent);
  4402. FREE(_InvokeData);
  4403. return;
  4404. }
  4405. else if(header->StatusCode!=200)
  4406. {
  4407. /* SOAP Fault */
  4408. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4409. RNDRelease(Service->Parent);
  4410. FREE(_InvokeData);
  4411. return;
  4412. }
  4413. }
  4414. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4415. RNDRelease(Service->Parent);
  4416. FREE(_InvokeData);
  4417. }
  4418. void RNDInvoke_RenderingControl_SetRedVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredRedVideoBlackLevel)
  4419. {
  4420. int headerLength;
  4421. char *headerBuffer;
  4422. char *SoapBodyTemplate;
  4423. char* buffer;
  4424. int bufferLength;
  4425. char* IP;
  4426. unsigned short Port;
  4427. char* Path;
  4428. struct sockaddr_in addr;
  4429. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4430. if(service==NULL)
  4431. {
  4432. FREE(invoke_data);
  4433. return;
  4434. }
  4435. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+369);
  4436. SoapBodyTemplate = "%sSetRedVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredRedVideoBlackLevel>%u</DesiredRedVideoBlackLevel></u:SetRedVideoBlackLevel%s";
  4437. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredRedVideoBlackLevel,UPNPCP_SOAP_BodyTail);
  4438. RNDAddRef(service->Parent);
  4439. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4440. headerBuffer = (char*)MALLOC(174 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4441. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetRedVideoBlackLevel",bufferLength);
  4442. memset((char *)&addr, 0, sizeof(addr));
  4443. addr.sin_family = AF_INET;
  4444. addr.sin_addr.s_addr = inet_addr(IP);
  4445. addr.sin_port = htons(Port);
  4446. invoke_data->CallbackPtr = CallbackPtr;
  4447. invoke_data->User = user;
  4448. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetRedVideoBlackLevel_Sink, service, invoke_data);
  4449. FREE(IP);
  4450. FREE(Path);
  4451. }
  4452. void RNDInvoke_RenderingControl_SetContrast_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4453. {
  4454. struct UPnPService *Service = (struct UPnPService*)_service;
  4455. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4456. if(done==0){return;}
  4457. if(_InvokeData->CallbackPtr==NULL)
  4458. {
  4459. RNDRelease(Service->Parent);
  4460. FREE(_InvokeData);
  4461. return;
  4462. }
  4463. else
  4464. {
  4465. if(header==NULL)
  4466. {
  4467. /* Connection Failed */
  4468. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4469. RNDRelease(Service->Parent);
  4470. FREE(_InvokeData);
  4471. return;
  4472. }
  4473. else if(header->StatusCode!=200)
  4474. {
  4475. /* SOAP Fault */
  4476. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4477. RNDRelease(Service->Parent);
  4478. FREE(_InvokeData);
  4479. return;
  4480. }
  4481. }
  4482. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4483. RNDRelease(Service->Parent);
  4484. FREE(_InvokeData);
  4485. }
  4486. void RNDInvoke_RenderingControl_SetContrast(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredContrast)
  4487. {
  4488. int headerLength;
  4489. char *headerBuffer;
  4490. char *SoapBodyTemplate;
  4491. char* buffer;
  4492. int bufferLength;
  4493. char* IP;
  4494. unsigned short Port;
  4495. char* Path;
  4496. struct sockaddr_in addr;
  4497. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4498. if(service==NULL)
  4499. {
  4500. FREE(invoke_data);
  4501. return;
  4502. }
  4503. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+329);
  4504. SoapBodyTemplate = "%sSetContrast xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredContrast>%u</DesiredContrast></u:SetContrast%s";
  4505. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredContrast,UPNPCP_SOAP_BodyTail);
  4506. RNDAddRef(service->Parent);
  4507. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4508. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4509. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetContrast",bufferLength);
  4510. memset((char *)&addr, 0, sizeof(addr));
  4511. addr.sin_family = AF_INET;
  4512. addr.sin_addr.s_addr = inet_addr(IP);
  4513. addr.sin_port = htons(Port);
  4514. invoke_data->CallbackPtr = CallbackPtr;
  4515. invoke_data->User = user;
  4516. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetContrast_Sink, service, invoke_data);
  4517. FREE(IP);
  4518. FREE(Path);
  4519. }
  4520. void RNDInvoke_RenderingControl_SetLoudness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4521. {
  4522. struct UPnPService *Service = (struct UPnPService*)_service;
  4523. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4524. if(done==0){return;}
  4525. if(_InvokeData->CallbackPtr==NULL)
  4526. {
  4527. RNDRelease(Service->Parent);
  4528. FREE(_InvokeData);
  4529. return;
  4530. }
  4531. else
  4532. {
  4533. if(header==NULL)
  4534. {
  4535. /* Connection Failed */
  4536. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4537. RNDRelease(Service->Parent);
  4538. FREE(_InvokeData);
  4539. return;
  4540. }
  4541. else if(header->StatusCode!=200)
  4542. {
  4543. /* SOAP Fault */
  4544. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4545. RNDRelease(Service->Parent);
  4546. FREE(_InvokeData);
  4547. return;
  4548. }
  4549. }
  4550. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4551. RNDRelease(Service->Parent);
  4552. FREE(_InvokeData);
  4553. }
  4554. void RNDInvoke_RenderingControl_SetLoudness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Channel, int DesiredLoudness)
  4555. {
  4556. int headerLength;
  4557. char *headerBuffer;
  4558. char *SoapBodyTemplate;
  4559. char* buffer;
  4560. int bufferLength;
  4561. char* IP;
  4562. unsigned short Port;
  4563. char* Path;
  4564. struct sockaddr_in addr;
  4565. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4566. char* __DesiredLoudness;
  4567. if(service==NULL)
  4568. {
  4569. FREE(invoke_data);
  4570. return;
  4571. }
  4572. (DesiredLoudness!=0)?(__DesiredLoudness="true"):(__DesiredLoudness="false");
  4573. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+348);
  4574. SoapBodyTemplate = "%sSetLoudness xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel><DesiredLoudness>%s</DesiredLoudness></u:SetLoudness%s";
  4575. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel, __DesiredLoudness,UPNPCP_SOAP_BodyTail);
  4576. RNDAddRef(service->Parent);
  4577. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4578. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4579. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetLoudness",bufferLength);
  4580. memset((char *)&addr, 0, sizeof(addr));
  4581. addr.sin_family = AF_INET;
  4582. addr.sin_addr.s_addr = inet_addr(IP);
  4583. addr.sin_port = htons(Port);
  4584. invoke_data->CallbackPtr = CallbackPtr;
  4585. invoke_data->User = user;
  4586. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetLoudness_Sink, service, invoke_data);
  4587. FREE(IP);
  4588. FREE(Path);
  4589. }
  4590. void RNDInvoke_RenderingControl_SetBrightness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4591. {
  4592. struct UPnPService *Service = (struct UPnPService*)_service;
  4593. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4594. if(done==0){return;}
  4595. if(_InvokeData->CallbackPtr==NULL)
  4596. {
  4597. RNDRelease(Service->Parent);
  4598. FREE(_InvokeData);
  4599. return;
  4600. }
  4601. else
  4602. {
  4603. if(header==NULL)
  4604. {
  4605. /* Connection Failed */
  4606. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  4607. RNDRelease(Service->Parent);
  4608. FREE(_InvokeData);
  4609. return;
  4610. }
  4611. else if(header->StatusCode!=200)
  4612. {
  4613. /* SOAP Fault */
  4614. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  4615. RNDRelease(Service->Parent);
  4616. FREE(_InvokeData);
  4617. return;
  4618. }
  4619. }
  4620. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  4621. RNDRelease(Service->Parent);
  4622. FREE(_InvokeData);
  4623. }
  4624. void RNDInvoke_RenderingControl_SetBrightness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredBrightness)
  4625. {
  4626. int headerLength;
  4627. char *headerBuffer;
  4628. char *SoapBodyTemplate;
  4629. char* buffer;
  4630. int bufferLength;
  4631. char* IP;
  4632. unsigned short Port;
  4633. char* Path;
  4634. struct sockaddr_in addr;
  4635. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4636. if(service==NULL)
  4637. {
  4638. FREE(invoke_data);
  4639. return;
  4640. }
  4641. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+337);
  4642. SoapBodyTemplate = "%sSetBrightness xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredBrightness>%u</DesiredBrightness></u:SetBrightness%s";
  4643. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredBrightness,UPNPCP_SOAP_BodyTail);
  4644. RNDAddRef(service->Parent);
  4645. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4646. headerBuffer = (char*)MALLOC(166 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4647. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetBrightness",bufferLength);
  4648. memset((char *)&addr, 0, sizeof(addr));
  4649. addr.sin_family = AF_INET;
  4650. addr.sin_addr.s_addr = inet_addr(IP);
  4651. addr.sin_port = htons(Port);
  4652. invoke_data->CallbackPtr = CallbackPtr;
  4653. invoke_data->User = user;
  4654. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetBrightness_Sink, service, invoke_data);
  4655. FREE(IP);
  4656. FREE(Path);
  4657. }
  4658. void RNDInvoke_RenderingControl_GetLoudness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4659. {
  4660. struct UPnPService *Service = (struct UPnPService*)_service;
  4661. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4662. int ArgLeft = 1;
  4663. struct ILibXMLNode *xml;
  4664. struct ILibXMLNode *__xml;
  4665. char *tempBuffer;
  4666. int tempBufferLength;
  4667. int CurrentLoudness = 0;
  4668. if(done==0){return;}
  4669. if(_InvokeData->CallbackPtr==NULL)
  4670. {
  4671. RNDRelease(Service->Parent);
  4672. FREE(_InvokeData);
  4673. return;
  4674. }
  4675. else
  4676. {
  4677. if(header==NULL)
  4678. {
  4679. /* Connection Failed */
  4680. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  4681. RNDRelease(Service->Parent);
  4682. FREE(_InvokeData);
  4683. return;
  4684. }
  4685. else if(header->StatusCode!=200)
  4686. {
  4687. /* SOAP Fault */
  4688. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  4689. RNDRelease(Service->Parent);
  4690. FREE(_InvokeData);
  4691. return;
  4692. }
  4693. }
  4694. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  4695. ILibProcessXMLNodeList(xml);
  4696. while(xml!=NULL)
  4697. {
  4698. if(xml->NameLength==19 && memcmp(xml->Name,"GetLoudnessResponse",19)==0)
  4699. {
  4700. xml = xml->Next;
  4701. while(xml!=NULL)
  4702. {
  4703. if(xml->NameLength==15 && memcmp(xml->Name,"CurrentLoudness",15) == 0)
  4704. {
  4705. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  4706. --ArgLeft;
  4707. CurrentLoudness = 1;
  4708. if(strncasecmp(tempBuffer,"false",5)==0 || strncmp(tempBuffer,"0",1)==0 || strncasecmp(tempBuffer,"no",2)==0)
  4709. {
  4710. CurrentLoudness = 0;
  4711. }
  4712. }
  4713. xml = xml->Peer;
  4714. }
  4715. }
  4716. if(xml!=NULL) {xml = xml->Next;}
  4717. }
  4718. ILibDestructXMLNodeList(__xml);
  4719. if(ArgLeft!=0)
  4720. {
  4721. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  4722. }
  4723. else
  4724. {
  4725. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentLoudness);
  4726. }
  4727. RNDRelease(Service->Parent);
  4728. FREE(_InvokeData);
  4729. }
  4730. void RNDInvoke_RenderingControl_GetLoudness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,int), void* user, unsigned int InstanceID, char* Channel)
  4731. {
  4732. int headerLength;
  4733. char *headerBuffer;
  4734. char *SoapBodyTemplate;
  4735. char* buffer;
  4736. int bufferLength;
  4737. char* IP;
  4738. unsigned short Port;
  4739. char* Path;
  4740. struct sockaddr_in addr;
  4741. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4742. if(service==NULL)
  4743. {
  4744. FREE(invoke_data);
  4745. return;
  4746. }
  4747. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+308);
  4748. SoapBodyTemplate = "%sGetLoudness xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel></u:GetLoudness%s";
  4749. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel,UPNPCP_SOAP_BodyTail);
  4750. RNDAddRef(service->Parent);
  4751. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4752. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4753. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetLoudness",bufferLength);
  4754. memset((char *)&addr, 0, sizeof(addr));
  4755. addr.sin_family = AF_INET;
  4756. addr.sin_addr.s_addr = inet_addr(IP);
  4757. addr.sin_port = htons(Port);
  4758. invoke_data->CallbackPtr = CallbackPtr;
  4759. invoke_data->User = user;
  4760. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetLoudness_Sink, service, invoke_data);
  4761. FREE(IP);
  4762. FREE(Path);
  4763. }
  4764. void RNDInvoke_RenderingControl_GetColorTemperature_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4765. {
  4766. struct UPnPService *Service = (struct UPnPService*)_service;
  4767. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4768. int ArgLeft = 1;
  4769. struct ILibXMLNode *xml;
  4770. struct ILibXMLNode *__xml;
  4771. char *tempBuffer;
  4772. int tempBufferLength;
  4773. unsigned long TempULong;
  4774. unsigned short CurrentColorTemperature = 0;
  4775. if(done==0){return;}
  4776. if(_InvokeData->CallbackPtr==NULL)
  4777. {
  4778. RNDRelease(Service->Parent);
  4779. FREE(_InvokeData);
  4780. return;
  4781. }
  4782. else
  4783. {
  4784. if(header==NULL)
  4785. {
  4786. /* Connection Failed */
  4787. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  4788. RNDRelease(Service->Parent);
  4789. FREE(_InvokeData);
  4790. return;
  4791. }
  4792. else if(header->StatusCode!=200)
  4793. {
  4794. /* SOAP Fault */
  4795. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  4796. RNDRelease(Service->Parent);
  4797. FREE(_InvokeData);
  4798. return;
  4799. }
  4800. }
  4801. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  4802. ILibProcessXMLNodeList(xml);
  4803. while(xml!=NULL)
  4804. {
  4805. if(xml->NameLength==27 && memcmp(xml->Name,"GetColorTemperatureResponse",27)==0)
  4806. {
  4807. xml = xml->Next;
  4808. while(xml!=NULL)
  4809. {
  4810. if(xml->NameLength==23 && memcmp(xml->Name,"CurrentColorTemperature",23) == 0)
  4811. {
  4812. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  4813. --ArgLeft;
  4814. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  4815. {
  4816. CurrentColorTemperature = (unsigned short) TempULong;
  4817. }
  4818. }
  4819. xml = xml->Peer;
  4820. }
  4821. }
  4822. if(xml!=NULL) {xml = xml->Next;}
  4823. }
  4824. ILibDestructXMLNodeList(__xml);
  4825. if(ArgLeft!=0)
  4826. {
  4827. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  4828. }
  4829. else
  4830. {
  4831. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentColorTemperature);
  4832. }
  4833. RNDRelease(Service->Parent);
  4834. FREE(_InvokeData);
  4835. }
  4836. void RNDInvoke_RenderingControl_GetColorTemperature(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  4837. {
  4838. int headerLength;
  4839. char *headerBuffer;
  4840. char *SoapBodyTemplate;
  4841. char* buffer;
  4842. int bufferLength;
  4843. char* IP;
  4844. unsigned short Port;
  4845. char* Path;
  4846. struct sockaddr_in addr;
  4847. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4848. if(service==NULL)
  4849. {
  4850. FREE(invoke_data);
  4851. return;
  4852. }
  4853. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+305);
  4854. SoapBodyTemplate = "%sGetColorTemperature xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetColorTemperature%s";
  4855. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  4856. RNDAddRef(service->Parent);
  4857. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4858. headerBuffer = (char*)MALLOC(172 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4859. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetColorTemperature",bufferLength);
  4860. memset((char *)&addr, 0, sizeof(addr));
  4861. addr.sin_family = AF_INET;
  4862. addr.sin_addr.s_addr = inet_addr(IP);
  4863. addr.sin_port = htons(Port);
  4864. invoke_data->CallbackPtr = CallbackPtr;
  4865. invoke_data->User = user;
  4866. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetColorTemperature_Sink, service, invoke_data);
  4867. FREE(IP);
  4868. FREE(Path);
  4869. }
  4870. void RNDInvoke_RenderingControl_GetSharpness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4871. {
  4872. struct UPnPService *Service = (struct UPnPService*)_service;
  4873. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4874. int ArgLeft = 1;
  4875. struct ILibXMLNode *xml;
  4876. struct ILibXMLNode *__xml;
  4877. char *tempBuffer;
  4878. int tempBufferLength;
  4879. unsigned long TempULong;
  4880. unsigned short CurrentSharpness = 0;
  4881. if(done==0){return;}
  4882. if(_InvokeData->CallbackPtr==NULL)
  4883. {
  4884. RNDRelease(Service->Parent);
  4885. FREE(_InvokeData);
  4886. return;
  4887. }
  4888. else
  4889. {
  4890. if(header==NULL)
  4891. {
  4892. /* Connection Failed */
  4893. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  4894. RNDRelease(Service->Parent);
  4895. FREE(_InvokeData);
  4896. return;
  4897. }
  4898. else if(header->StatusCode!=200)
  4899. {
  4900. /* SOAP Fault */
  4901. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  4902. RNDRelease(Service->Parent);
  4903. FREE(_InvokeData);
  4904. return;
  4905. }
  4906. }
  4907. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  4908. ILibProcessXMLNodeList(xml);
  4909. while(xml!=NULL)
  4910. {
  4911. if(xml->NameLength==20 && memcmp(xml->Name,"GetSharpnessResponse",20)==0)
  4912. {
  4913. xml = xml->Next;
  4914. while(xml!=NULL)
  4915. {
  4916. if(xml->NameLength==16 && memcmp(xml->Name,"CurrentSharpness",16) == 0)
  4917. {
  4918. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  4919. --ArgLeft;
  4920. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  4921. {
  4922. CurrentSharpness = (unsigned short) TempULong;
  4923. }
  4924. }
  4925. xml = xml->Peer;
  4926. }
  4927. }
  4928. if(xml!=NULL) {xml = xml->Next;}
  4929. }
  4930. ILibDestructXMLNodeList(__xml);
  4931. if(ArgLeft!=0)
  4932. {
  4933. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  4934. }
  4935. else
  4936. {
  4937. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentSharpness);
  4938. }
  4939. RNDRelease(Service->Parent);
  4940. FREE(_InvokeData);
  4941. }
  4942. void RNDInvoke_RenderingControl_GetSharpness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  4943. {
  4944. int headerLength;
  4945. char *headerBuffer;
  4946. char *SoapBodyTemplate;
  4947. char* buffer;
  4948. int bufferLength;
  4949. char* IP;
  4950. unsigned short Port;
  4951. char* Path;
  4952. struct sockaddr_in addr;
  4953. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  4954. if(service==NULL)
  4955. {
  4956. FREE(invoke_data);
  4957. return;
  4958. }
  4959. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+291);
  4960. SoapBodyTemplate = "%sGetSharpness xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetSharpness%s";
  4961. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  4962. RNDAddRef(service->Parent);
  4963. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  4964. headerBuffer = (char*)MALLOC(165 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  4965. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetSharpness",bufferLength);
  4966. memset((char *)&addr, 0, sizeof(addr));
  4967. addr.sin_family = AF_INET;
  4968. addr.sin_addr.s_addr = inet_addr(IP);
  4969. addr.sin_port = htons(Port);
  4970. invoke_data->CallbackPtr = CallbackPtr;
  4971. invoke_data->User = user;
  4972. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetSharpness_Sink, service, invoke_data);
  4973. FREE(IP);
  4974. FREE(Path);
  4975. }
  4976. void RNDInvoke_RenderingControl_GetContrast_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  4977. {
  4978. struct UPnPService *Service = (struct UPnPService*)_service;
  4979. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  4980. int ArgLeft = 1;
  4981. struct ILibXMLNode *xml;
  4982. struct ILibXMLNode *__xml;
  4983. char *tempBuffer;
  4984. int tempBufferLength;
  4985. unsigned long TempULong;
  4986. unsigned short CurrentContrast = 0;
  4987. if(done==0){return;}
  4988. if(_InvokeData->CallbackPtr==NULL)
  4989. {
  4990. RNDRelease(Service->Parent);
  4991. FREE(_InvokeData);
  4992. return;
  4993. }
  4994. else
  4995. {
  4996. if(header==NULL)
  4997. {
  4998. /* Connection Failed */
  4999. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5000. RNDRelease(Service->Parent);
  5001. FREE(_InvokeData);
  5002. return;
  5003. }
  5004. else if(header->StatusCode!=200)
  5005. {
  5006. /* SOAP Fault */
  5007. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5008. RNDRelease(Service->Parent);
  5009. FREE(_InvokeData);
  5010. return;
  5011. }
  5012. }
  5013. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5014. ILibProcessXMLNodeList(xml);
  5015. while(xml!=NULL)
  5016. {
  5017. if(xml->NameLength==19 && memcmp(xml->Name,"GetContrastResponse",19)==0)
  5018. {
  5019. xml = xml->Next;
  5020. while(xml!=NULL)
  5021. {
  5022. if(xml->NameLength==15 && memcmp(xml->Name,"CurrentContrast",15) == 0)
  5023. {
  5024. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5025. --ArgLeft;
  5026. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  5027. {
  5028. CurrentContrast = (unsigned short) TempULong;
  5029. }
  5030. }
  5031. xml = xml->Peer;
  5032. }
  5033. }
  5034. if(xml!=NULL) {xml = xml->Next;}
  5035. }
  5036. ILibDestructXMLNodeList(__xml);
  5037. if(ArgLeft!=0)
  5038. {
  5039. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5040. }
  5041. else
  5042. {
  5043. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentContrast);
  5044. }
  5045. RNDRelease(Service->Parent);
  5046. FREE(_InvokeData);
  5047. }
  5048. void RNDInvoke_RenderingControl_GetContrast(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  5049. {
  5050. int headerLength;
  5051. char *headerBuffer;
  5052. char *SoapBodyTemplate;
  5053. char* buffer;
  5054. int bufferLength;
  5055. char* IP;
  5056. unsigned short Port;
  5057. char* Path;
  5058. struct sockaddr_in addr;
  5059. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5060. if(service==NULL)
  5061. {
  5062. FREE(invoke_data);
  5063. return;
  5064. }
  5065. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+289);
  5066. SoapBodyTemplate = "%sGetContrast xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetContrast%s";
  5067. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  5068. RNDAddRef(service->Parent);
  5069. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5070. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5071. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetContrast",bufferLength);
  5072. memset((char *)&addr, 0, sizeof(addr));
  5073. addr.sin_family = AF_INET;
  5074. addr.sin_addr.s_addr = inet_addr(IP);
  5075. addr.sin_port = htons(Port);
  5076. invoke_data->CallbackPtr = CallbackPtr;
  5077. invoke_data->User = user;
  5078. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetContrast_Sink, service, invoke_data);
  5079. FREE(IP);
  5080. FREE(Path);
  5081. }
  5082. void RNDInvoke_RenderingControl_GetGreenVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5083. {
  5084. struct UPnPService *Service = (struct UPnPService*)_service;
  5085. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5086. int ArgLeft = 1;
  5087. struct ILibXMLNode *xml;
  5088. struct ILibXMLNode *__xml;
  5089. char *tempBuffer;
  5090. int tempBufferLength;
  5091. unsigned long TempULong;
  5092. unsigned short CurrentGreenVideoGain = 0;
  5093. if(done==0){return;}
  5094. if(_InvokeData->CallbackPtr==NULL)
  5095. {
  5096. RNDRelease(Service->Parent);
  5097. FREE(_InvokeData);
  5098. return;
  5099. }
  5100. else
  5101. {
  5102. if(header==NULL)
  5103. {
  5104. /* Connection Failed */
  5105. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5106. RNDRelease(Service->Parent);
  5107. FREE(_InvokeData);
  5108. return;
  5109. }
  5110. else if(header->StatusCode!=200)
  5111. {
  5112. /* SOAP Fault */
  5113. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5114. RNDRelease(Service->Parent);
  5115. FREE(_InvokeData);
  5116. return;
  5117. }
  5118. }
  5119. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5120. ILibProcessXMLNodeList(xml);
  5121. while(xml!=NULL)
  5122. {
  5123. if(xml->NameLength==25 && memcmp(xml->Name,"GetGreenVideoGainResponse",25)==0)
  5124. {
  5125. xml = xml->Next;
  5126. while(xml!=NULL)
  5127. {
  5128. if(xml->NameLength==21 && memcmp(xml->Name,"CurrentGreenVideoGain",21) == 0)
  5129. {
  5130. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5131. --ArgLeft;
  5132. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  5133. {
  5134. CurrentGreenVideoGain = (unsigned short) TempULong;
  5135. }
  5136. }
  5137. xml = xml->Peer;
  5138. }
  5139. }
  5140. if(xml!=NULL) {xml = xml->Next;}
  5141. }
  5142. ILibDestructXMLNodeList(__xml);
  5143. if(ArgLeft!=0)
  5144. {
  5145. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5146. }
  5147. else
  5148. {
  5149. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentGreenVideoGain);
  5150. }
  5151. RNDRelease(Service->Parent);
  5152. FREE(_InvokeData);
  5153. }
  5154. void RNDInvoke_RenderingControl_GetGreenVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  5155. {
  5156. int headerLength;
  5157. char *headerBuffer;
  5158. char *SoapBodyTemplate;
  5159. char* buffer;
  5160. int bufferLength;
  5161. char* IP;
  5162. unsigned short Port;
  5163. char* Path;
  5164. struct sockaddr_in addr;
  5165. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5166. if(service==NULL)
  5167. {
  5168. FREE(invoke_data);
  5169. return;
  5170. }
  5171. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+301);
  5172. SoapBodyTemplate = "%sGetGreenVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetGreenVideoGain%s";
  5173. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  5174. RNDAddRef(service->Parent);
  5175. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5176. headerBuffer = (char*)MALLOC(170 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5177. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetGreenVideoGain",bufferLength);
  5178. memset((char *)&addr, 0, sizeof(addr));
  5179. addr.sin_family = AF_INET;
  5180. addr.sin_addr.s_addr = inet_addr(IP);
  5181. addr.sin_port = htons(Port);
  5182. invoke_data->CallbackPtr = CallbackPtr;
  5183. invoke_data->User = user;
  5184. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetGreenVideoGain_Sink, service, invoke_data);
  5185. FREE(IP);
  5186. FREE(Path);
  5187. }
  5188. void RNDInvoke_RenderingControl_SetRedVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5189. {
  5190. struct UPnPService *Service = (struct UPnPService*)_service;
  5191. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5192. if(done==0){return;}
  5193. if(_InvokeData->CallbackPtr==NULL)
  5194. {
  5195. RNDRelease(Service->Parent);
  5196. FREE(_InvokeData);
  5197. return;
  5198. }
  5199. else
  5200. {
  5201. if(header==NULL)
  5202. {
  5203. /* Connection Failed */
  5204. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  5205. RNDRelease(Service->Parent);
  5206. FREE(_InvokeData);
  5207. return;
  5208. }
  5209. else if(header->StatusCode!=200)
  5210. {
  5211. /* SOAP Fault */
  5212. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  5213. RNDRelease(Service->Parent);
  5214. FREE(_InvokeData);
  5215. return;
  5216. }
  5217. }
  5218. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  5219. RNDRelease(Service->Parent);
  5220. FREE(_InvokeData);
  5221. }
  5222. void RNDInvoke_RenderingControl_SetRedVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredRedVideoGain)
  5223. {
  5224. int headerLength;
  5225. char *headerBuffer;
  5226. char *SoapBodyTemplate;
  5227. char* buffer;
  5228. int bufferLength;
  5229. char* IP;
  5230. unsigned short Port;
  5231. char* Path;
  5232. struct sockaddr_in addr;
  5233. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5234. if(service==NULL)
  5235. {
  5236. FREE(invoke_data);
  5237. return;
  5238. }
  5239. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+345);
  5240. SoapBodyTemplate = "%sSetRedVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredRedVideoGain>%u</DesiredRedVideoGain></u:SetRedVideoGain%s";
  5241. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredRedVideoGain,UPNPCP_SOAP_BodyTail);
  5242. RNDAddRef(service->Parent);
  5243. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5244. headerBuffer = (char*)MALLOC(168 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5245. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetRedVideoGain",bufferLength);
  5246. memset((char *)&addr, 0, sizeof(addr));
  5247. addr.sin_family = AF_INET;
  5248. addr.sin_addr.s_addr = inet_addr(IP);
  5249. addr.sin_port = htons(Port);
  5250. invoke_data->CallbackPtr = CallbackPtr;
  5251. invoke_data->User = user;
  5252. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetRedVideoGain_Sink, service, invoke_data);
  5253. FREE(IP);
  5254. FREE(Path);
  5255. }
  5256. void RNDInvoke_RenderingControl_SetGreenVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5257. {
  5258. struct UPnPService *Service = (struct UPnPService*)_service;
  5259. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5260. if(done==0){return;}
  5261. if(_InvokeData->CallbackPtr==NULL)
  5262. {
  5263. RNDRelease(Service->Parent);
  5264. FREE(_InvokeData);
  5265. return;
  5266. }
  5267. else
  5268. {
  5269. if(header==NULL)
  5270. {
  5271. /* Connection Failed */
  5272. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  5273. RNDRelease(Service->Parent);
  5274. FREE(_InvokeData);
  5275. return;
  5276. }
  5277. else if(header->StatusCode!=200)
  5278. {
  5279. /* SOAP Fault */
  5280. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  5281. RNDRelease(Service->Parent);
  5282. FREE(_InvokeData);
  5283. return;
  5284. }
  5285. }
  5286. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  5287. RNDRelease(Service->Parent);
  5288. FREE(_InvokeData);
  5289. }
  5290. void RNDInvoke_RenderingControl_SetGreenVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredGreenVideoBlackLevel)
  5291. {
  5292. int headerLength;
  5293. char *headerBuffer;
  5294. char *SoapBodyTemplate;
  5295. char* buffer;
  5296. int bufferLength;
  5297. char* IP;
  5298. unsigned short Port;
  5299. char* Path;
  5300. struct sockaddr_in addr;
  5301. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5302. if(service==NULL)
  5303. {
  5304. FREE(invoke_data);
  5305. return;
  5306. }
  5307. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+377);
  5308. SoapBodyTemplate = "%sSetGreenVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredGreenVideoBlackLevel>%u</DesiredGreenVideoBlackLevel></u:SetGreenVideoBlackLevel%s";
  5309. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredGreenVideoBlackLevel,UPNPCP_SOAP_BodyTail);
  5310. RNDAddRef(service->Parent);
  5311. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5312. headerBuffer = (char*)MALLOC(176 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5313. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetGreenVideoBlackLevel",bufferLength);
  5314. memset((char *)&addr, 0, sizeof(addr));
  5315. addr.sin_family = AF_INET;
  5316. addr.sin_addr.s_addr = inet_addr(IP);
  5317. addr.sin_port = htons(Port);
  5318. invoke_data->CallbackPtr = CallbackPtr;
  5319. invoke_data->User = user;
  5320. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetGreenVideoBlackLevel_Sink, service, invoke_data);
  5321. FREE(IP);
  5322. FREE(Path);
  5323. }
  5324. void RNDInvoke_RenderingControl_GetVolumeDBRange_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5325. {
  5326. struct UPnPService *Service = (struct UPnPService*)_service;
  5327. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5328. int ArgLeft = 2;
  5329. struct ILibXMLNode *xml;
  5330. struct ILibXMLNode *__xml;
  5331. char *tempBuffer;
  5332. int tempBufferLength;
  5333. long TempLong;
  5334. short MinValue = 0;
  5335. short MaxValue = 0;
  5336. if(done==0){return;}
  5337. if(_InvokeData->CallbackPtr==NULL)
  5338. {
  5339. RNDRelease(Service->Parent);
  5340. FREE(_InvokeData);
  5341. return;
  5342. }
  5343. else
  5344. {
  5345. if(header==NULL)
  5346. {
  5347. /* Connection Failed */
  5348. ((void (*)(struct UPnPService*,int,void*,short,short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  5349. RNDRelease(Service->Parent);
  5350. FREE(_InvokeData);
  5351. return;
  5352. }
  5353. else if(header->StatusCode!=200)
  5354. {
  5355. /* SOAP Fault */
  5356. ((void (*)(struct UPnPService*,int,void*,short,short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA,INVALID_DATA);
  5357. RNDRelease(Service->Parent);
  5358. FREE(_InvokeData);
  5359. return;
  5360. }
  5361. }
  5362. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5363. ILibProcessXMLNodeList(xml);
  5364. while(xml!=NULL)
  5365. {
  5366. if(xml->NameLength==24 && memcmp(xml->Name,"GetVolumeDBRangeResponse",24)==0)
  5367. {
  5368. xml = xml->Next;
  5369. while(xml!=NULL)
  5370. {
  5371. if(xml->NameLength==8 && memcmp(xml->Name,"MinValue",8) == 0)
  5372. {
  5373. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5374. --ArgLeft;
  5375. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  5376. {
  5377. MinValue = (short) TempLong;
  5378. }
  5379. }
  5380. else
  5381. if(xml->NameLength==8 && memcmp(xml->Name,"MaxValue",8) == 0)
  5382. {
  5383. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5384. --ArgLeft;
  5385. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  5386. {
  5387. MaxValue = (short) TempLong;
  5388. }
  5389. }
  5390. xml = xml->Peer;
  5391. }
  5392. }
  5393. if(xml!=NULL) {xml = xml->Next;}
  5394. }
  5395. ILibDestructXMLNodeList(__xml);
  5396. if(ArgLeft!=0)
  5397. {
  5398. ((void (*)(struct UPnPService*,int,void*,short,short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA,INVALID_DATA);
  5399. }
  5400. else
  5401. {
  5402. ((void (*)(struct UPnPService*,int,void*,short,short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,MinValue,MaxValue);
  5403. }
  5404. RNDRelease(Service->Parent);
  5405. FREE(_InvokeData);
  5406. }
  5407. void RNDInvoke_RenderingControl_GetVolumeDBRange(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,short,short), void* user, unsigned int InstanceID, char* Channel)
  5408. {
  5409. int headerLength;
  5410. char *headerBuffer;
  5411. char *SoapBodyTemplate;
  5412. char* buffer;
  5413. int bufferLength;
  5414. char* IP;
  5415. unsigned short Port;
  5416. char* Path;
  5417. struct sockaddr_in addr;
  5418. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5419. if(service==NULL)
  5420. {
  5421. FREE(invoke_data);
  5422. return;
  5423. }
  5424. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+318);
  5425. SoapBodyTemplate = "%sGetVolumeDBRange xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel></u:GetVolumeDBRange%s";
  5426. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel,UPNPCP_SOAP_BodyTail);
  5427. RNDAddRef(service->Parent);
  5428. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5429. headerBuffer = (char*)MALLOC(169 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5430. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetVolumeDBRange",bufferLength);
  5431. memset((char *)&addr, 0, sizeof(addr));
  5432. addr.sin_family = AF_INET;
  5433. addr.sin_addr.s_addr = inet_addr(IP);
  5434. addr.sin_port = htons(Port);
  5435. invoke_data->CallbackPtr = CallbackPtr;
  5436. invoke_data->User = user;
  5437. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetVolumeDBRange_Sink, service, invoke_data);
  5438. FREE(IP);
  5439. FREE(Path);
  5440. }
  5441. void RNDInvoke_RenderingControl_GetRedVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5442. {
  5443. struct UPnPService *Service = (struct UPnPService*)_service;
  5444. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5445. int ArgLeft = 1;
  5446. struct ILibXMLNode *xml;
  5447. struct ILibXMLNode *__xml;
  5448. char *tempBuffer;
  5449. int tempBufferLength;
  5450. unsigned long TempULong;
  5451. unsigned short CurrentRedVideoBlackLevel = 0;
  5452. if(done==0){return;}
  5453. if(_InvokeData->CallbackPtr==NULL)
  5454. {
  5455. RNDRelease(Service->Parent);
  5456. FREE(_InvokeData);
  5457. return;
  5458. }
  5459. else
  5460. {
  5461. if(header==NULL)
  5462. {
  5463. /* Connection Failed */
  5464. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5465. RNDRelease(Service->Parent);
  5466. FREE(_InvokeData);
  5467. return;
  5468. }
  5469. else if(header->StatusCode!=200)
  5470. {
  5471. /* SOAP Fault */
  5472. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5473. RNDRelease(Service->Parent);
  5474. FREE(_InvokeData);
  5475. return;
  5476. }
  5477. }
  5478. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5479. ILibProcessXMLNodeList(xml);
  5480. while(xml!=NULL)
  5481. {
  5482. if(xml->NameLength==29 && memcmp(xml->Name,"GetRedVideoBlackLevelResponse",29)==0)
  5483. {
  5484. xml = xml->Next;
  5485. while(xml!=NULL)
  5486. {
  5487. if(xml->NameLength==25 && memcmp(xml->Name,"CurrentRedVideoBlackLevel",25) == 0)
  5488. {
  5489. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5490. --ArgLeft;
  5491. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  5492. {
  5493. CurrentRedVideoBlackLevel = (unsigned short) TempULong;
  5494. }
  5495. }
  5496. xml = xml->Peer;
  5497. }
  5498. }
  5499. if(xml!=NULL) {xml = xml->Next;}
  5500. }
  5501. ILibDestructXMLNodeList(__xml);
  5502. if(ArgLeft!=0)
  5503. {
  5504. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5505. }
  5506. else
  5507. {
  5508. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentRedVideoBlackLevel);
  5509. }
  5510. RNDRelease(Service->Parent);
  5511. FREE(_InvokeData);
  5512. }
  5513. void RNDInvoke_RenderingControl_GetRedVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  5514. {
  5515. int headerLength;
  5516. char *headerBuffer;
  5517. char *SoapBodyTemplate;
  5518. char* buffer;
  5519. int bufferLength;
  5520. char* IP;
  5521. unsigned short Port;
  5522. char* Path;
  5523. struct sockaddr_in addr;
  5524. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5525. if(service==NULL)
  5526. {
  5527. FREE(invoke_data);
  5528. return;
  5529. }
  5530. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+309);
  5531. SoapBodyTemplate = "%sGetRedVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetRedVideoBlackLevel%s";
  5532. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  5533. RNDAddRef(service->Parent);
  5534. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5535. headerBuffer = (char*)MALLOC(174 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5536. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetRedVideoBlackLevel",bufferLength);
  5537. memset((char *)&addr, 0, sizeof(addr));
  5538. addr.sin_family = AF_INET;
  5539. addr.sin_addr.s_addr = inet_addr(IP);
  5540. addr.sin_port = htons(Port);
  5541. invoke_data->CallbackPtr = CallbackPtr;
  5542. invoke_data->User = user;
  5543. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetRedVideoBlackLevel_Sink, service, invoke_data);
  5544. FREE(IP);
  5545. FREE(Path);
  5546. }
  5547. void RNDInvoke_RenderingControl_GetBlueVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5548. {
  5549. struct UPnPService *Service = (struct UPnPService*)_service;
  5550. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5551. int ArgLeft = 1;
  5552. struct ILibXMLNode *xml;
  5553. struct ILibXMLNode *__xml;
  5554. char *tempBuffer;
  5555. int tempBufferLength;
  5556. unsigned long TempULong;
  5557. unsigned short CurrentBlueVideoBlackLevel = 0;
  5558. if(done==0){return;}
  5559. if(_InvokeData->CallbackPtr==NULL)
  5560. {
  5561. RNDRelease(Service->Parent);
  5562. FREE(_InvokeData);
  5563. return;
  5564. }
  5565. else
  5566. {
  5567. if(header==NULL)
  5568. {
  5569. /* Connection Failed */
  5570. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5571. RNDRelease(Service->Parent);
  5572. FREE(_InvokeData);
  5573. return;
  5574. }
  5575. else if(header->StatusCode!=200)
  5576. {
  5577. /* SOAP Fault */
  5578. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5579. RNDRelease(Service->Parent);
  5580. FREE(_InvokeData);
  5581. return;
  5582. }
  5583. }
  5584. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5585. ILibProcessXMLNodeList(xml);
  5586. while(xml!=NULL)
  5587. {
  5588. if(xml->NameLength==30 && memcmp(xml->Name,"GetBlueVideoBlackLevelResponse",30)==0)
  5589. {
  5590. xml = xml->Next;
  5591. while(xml!=NULL)
  5592. {
  5593. if(xml->NameLength==26 && memcmp(xml->Name,"CurrentBlueVideoBlackLevel",26) == 0)
  5594. {
  5595. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5596. --ArgLeft;
  5597. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  5598. {
  5599. CurrentBlueVideoBlackLevel = (unsigned short) TempULong;
  5600. }
  5601. }
  5602. xml = xml->Peer;
  5603. }
  5604. }
  5605. if(xml!=NULL) {xml = xml->Next;}
  5606. }
  5607. ILibDestructXMLNodeList(__xml);
  5608. if(ArgLeft!=0)
  5609. {
  5610. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5611. }
  5612. else
  5613. {
  5614. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentBlueVideoBlackLevel);
  5615. }
  5616. RNDRelease(Service->Parent);
  5617. FREE(_InvokeData);
  5618. }
  5619. void RNDInvoke_RenderingControl_GetBlueVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  5620. {
  5621. int headerLength;
  5622. char *headerBuffer;
  5623. char *SoapBodyTemplate;
  5624. char* buffer;
  5625. int bufferLength;
  5626. char* IP;
  5627. unsigned short Port;
  5628. char* Path;
  5629. struct sockaddr_in addr;
  5630. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5631. if(service==NULL)
  5632. {
  5633. FREE(invoke_data);
  5634. return;
  5635. }
  5636. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+311);
  5637. SoapBodyTemplate = "%sGetBlueVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetBlueVideoBlackLevel%s";
  5638. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  5639. RNDAddRef(service->Parent);
  5640. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5641. headerBuffer = (char*)MALLOC(175 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5642. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetBlueVideoBlackLevel",bufferLength);
  5643. memset((char *)&addr, 0, sizeof(addr));
  5644. addr.sin_family = AF_INET;
  5645. addr.sin_addr.s_addr = inet_addr(IP);
  5646. addr.sin_port = htons(Port);
  5647. invoke_data->CallbackPtr = CallbackPtr;
  5648. invoke_data->User = user;
  5649. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetBlueVideoBlackLevel_Sink, service, invoke_data);
  5650. FREE(IP);
  5651. FREE(Path);
  5652. }
  5653. void RNDInvoke_RenderingControl_GetBlueVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5654. {
  5655. struct UPnPService *Service = (struct UPnPService*)_service;
  5656. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5657. int ArgLeft = 1;
  5658. struct ILibXMLNode *xml;
  5659. struct ILibXMLNode *__xml;
  5660. char *tempBuffer;
  5661. int tempBufferLength;
  5662. unsigned long TempULong;
  5663. unsigned short CurrentBlueVideoGain = 0;
  5664. if(done==0){return;}
  5665. if(_InvokeData->CallbackPtr==NULL)
  5666. {
  5667. RNDRelease(Service->Parent);
  5668. FREE(_InvokeData);
  5669. return;
  5670. }
  5671. else
  5672. {
  5673. if(header==NULL)
  5674. {
  5675. /* Connection Failed */
  5676. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5677. RNDRelease(Service->Parent);
  5678. FREE(_InvokeData);
  5679. return;
  5680. }
  5681. else if(header->StatusCode!=200)
  5682. {
  5683. /* SOAP Fault */
  5684. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5685. RNDRelease(Service->Parent);
  5686. FREE(_InvokeData);
  5687. return;
  5688. }
  5689. }
  5690. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5691. ILibProcessXMLNodeList(xml);
  5692. while(xml!=NULL)
  5693. {
  5694. if(xml->NameLength==24 && memcmp(xml->Name,"GetBlueVideoGainResponse",24)==0)
  5695. {
  5696. xml = xml->Next;
  5697. while(xml!=NULL)
  5698. {
  5699. if(xml->NameLength==20 && memcmp(xml->Name,"CurrentBlueVideoGain",20) == 0)
  5700. {
  5701. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5702. --ArgLeft;
  5703. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  5704. {
  5705. CurrentBlueVideoGain = (unsigned short) TempULong;
  5706. }
  5707. }
  5708. xml = xml->Peer;
  5709. }
  5710. }
  5711. if(xml!=NULL) {xml = xml->Next;}
  5712. }
  5713. ILibDestructXMLNodeList(__xml);
  5714. if(ArgLeft!=0)
  5715. {
  5716. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5717. }
  5718. else
  5719. {
  5720. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentBlueVideoGain);
  5721. }
  5722. RNDRelease(Service->Parent);
  5723. FREE(_InvokeData);
  5724. }
  5725. void RNDInvoke_RenderingControl_GetBlueVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  5726. {
  5727. int headerLength;
  5728. char *headerBuffer;
  5729. char *SoapBodyTemplate;
  5730. char* buffer;
  5731. int bufferLength;
  5732. char* IP;
  5733. unsigned short Port;
  5734. char* Path;
  5735. struct sockaddr_in addr;
  5736. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5737. if(service==NULL)
  5738. {
  5739. FREE(invoke_data);
  5740. return;
  5741. }
  5742. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+299);
  5743. SoapBodyTemplate = "%sGetBlueVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetBlueVideoGain%s";
  5744. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  5745. RNDAddRef(service->Parent);
  5746. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5747. headerBuffer = (char*)MALLOC(169 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5748. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetBlueVideoGain",bufferLength);
  5749. memset((char *)&addr, 0, sizeof(addr));
  5750. addr.sin_family = AF_INET;
  5751. addr.sin_addr.s_addr = inet_addr(IP);
  5752. addr.sin_port = htons(Port);
  5753. invoke_data->CallbackPtr = CallbackPtr;
  5754. invoke_data->User = user;
  5755. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetBlueVideoGain_Sink, service, invoke_data);
  5756. FREE(IP);
  5757. FREE(Path);
  5758. }
  5759. void RNDInvoke_RenderingControl_SetBlueVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5760. {
  5761. struct UPnPService *Service = (struct UPnPService*)_service;
  5762. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5763. if(done==0){return;}
  5764. if(_InvokeData->CallbackPtr==NULL)
  5765. {
  5766. RNDRelease(Service->Parent);
  5767. FREE(_InvokeData);
  5768. return;
  5769. }
  5770. else
  5771. {
  5772. if(header==NULL)
  5773. {
  5774. /* Connection Failed */
  5775. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  5776. RNDRelease(Service->Parent);
  5777. FREE(_InvokeData);
  5778. return;
  5779. }
  5780. else if(header->StatusCode!=200)
  5781. {
  5782. /* SOAP Fault */
  5783. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  5784. RNDRelease(Service->Parent);
  5785. FREE(_InvokeData);
  5786. return;
  5787. }
  5788. }
  5789. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  5790. RNDRelease(Service->Parent);
  5791. FREE(_InvokeData);
  5792. }
  5793. void RNDInvoke_RenderingControl_SetBlueVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredBlueVideoBlackLevel)
  5794. {
  5795. int headerLength;
  5796. char *headerBuffer;
  5797. char *SoapBodyTemplate;
  5798. char* buffer;
  5799. int bufferLength;
  5800. char* IP;
  5801. unsigned short Port;
  5802. char* Path;
  5803. struct sockaddr_in addr;
  5804. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5805. if(service==NULL)
  5806. {
  5807. FREE(invoke_data);
  5808. return;
  5809. }
  5810. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+373);
  5811. SoapBodyTemplate = "%sSetBlueVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredBlueVideoBlackLevel>%u</DesiredBlueVideoBlackLevel></u:SetBlueVideoBlackLevel%s";
  5812. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredBlueVideoBlackLevel,UPNPCP_SOAP_BodyTail);
  5813. RNDAddRef(service->Parent);
  5814. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5815. headerBuffer = (char*)MALLOC(175 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5816. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetBlueVideoBlackLevel",bufferLength);
  5817. memset((char *)&addr, 0, sizeof(addr));
  5818. addr.sin_family = AF_INET;
  5819. addr.sin_addr.s_addr = inet_addr(IP);
  5820. addr.sin_port = htons(Port);
  5821. invoke_data->CallbackPtr = CallbackPtr;
  5822. invoke_data->User = user;
  5823. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetBlueVideoBlackLevel_Sink, service, invoke_data);
  5824. FREE(IP);
  5825. FREE(Path);
  5826. }
  5827. void RNDInvoke_RenderingControl_GetMute_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5828. {
  5829. struct UPnPService *Service = (struct UPnPService*)_service;
  5830. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5831. int ArgLeft = 1;
  5832. struct ILibXMLNode *xml;
  5833. struct ILibXMLNode *__xml;
  5834. char *tempBuffer;
  5835. int tempBufferLength;
  5836. int CurrentMute = 0;
  5837. if(done==0){return;}
  5838. if(_InvokeData->CallbackPtr==NULL)
  5839. {
  5840. RNDRelease(Service->Parent);
  5841. FREE(_InvokeData);
  5842. return;
  5843. }
  5844. else
  5845. {
  5846. if(header==NULL)
  5847. {
  5848. /* Connection Failed */
  5849. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  5850. RNDRelease(Service->Parent);
  5851. FREE(_InvokeData);
  5852. return;
  5853. }
  5854. else if(header->StatusCode!=200)
  5855. {
  5856. /* SOAP Fault */
  5857. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  5858. RNDRelease(Service->Parent);
  5859. FREE(_InvokeData);
  5860. return;
  5861. }
  5862. }
  5863. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  5864. ILibProcessXMLNodeList(xml);
  5865. while(xml!=NULL)
  5866. {
  5867. if(xml->NameLength==15 && memcmp(xml->Name,"GetMuteResponse",15)==0)
  5868. {
  5869. xml = xml->Next;
  5870. while(xml!=NULL)
  5871. {
  5872. if(xml->NameLength==11 && memcmp(xml->Name,"CurrentMute",11) == 0)
  5873. {
  5874. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  5875. --ArgLeft;
  5876. CurrentMute = 1;
  5877. if(strncasecmp(tempBuffer,"false",5)==0 || strncmp(tempBuffer,"0",1)==0 || strncasecmp(tempBuffer,"no",2)==0)
  5878. {
  5879. CurrentMute = 0;
  5880. }
  5881. }
  5882. xml = xml->Peer;
  5883. }
  5884. }
  5885. if(xml!=NULL) {xml = xml->Next;}
  5886. }
  5887. ILibDestructXMLNodeList(__xml);
  5888. if(ArgLeft!=0)
  5889. {
  5890. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  5891. }
  5892. else
  5893. {
  5894. ((void (*)(struct UPnPService*,int,void*,int))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentMute);
  5895. }
  5896. RNDRelease(Service->Parent);
  5897. FREE(_InvokeData);
  5898. }
  5899. void RNDInvoke_RenderingControl_GetMute(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,int), void* user, unsigned int InstanceID, char* Channel)
  5900. {
  5901. int headerLength;
  5902. char *headerBuffer;
  5903. char *SoapBodyTemplate;
  5904. char* buffer;
  5905. int bufferLength;
  5906. char* IP;
  5907. unsigned short Port;
  5908. char* Path;
  5909. struct sockaddr_in addr;
  5910. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5911. if(service==NULL)
  5912. {
  5913. FREE(invoke_data);
  5914. return;
  5915. }
  5916. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+300);
  5917. SoapBodyTemplate = "%sGetMute xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel></u:GetMute%s";
  5918. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel,UPNPCP_SOAP_BodyTail);
  5919. RNDAddRef(service->Parent);
  5920. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5921. headerBuffer = (char*)MALLOC(160 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5922. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetMute",bufferLength);
  5923. memset((char *)&addr, 0, sizeof(addr));
  5924. addr.sin_family = AF_INET;
  5925. addr.sin_addr.s_addr = inet_addr(IP);
  5926. addr.sin_port = htons(Port);
  5927. invoke_data->CallbackPtr = CallbackPtr;
  5928. invoke_data->User = user;
  5929. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetMute_Sink, service, invoke_data);
  5930. FREE(IP);
  5931. FREE(Path);
  5932. }
  5933. void RNDInvoke_RenderingControl_SetBlueVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  5934. {
  5935. struct UPnPService *Service = (struct UPnPService*)_service;
  5936. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  5937. if(done==0){return;}
  5938. if(_InvokeData->CallbackPtr==NULL)
  5939. {
  5940. RNDRelease(Service->Parent);
  5941. FREE(_InvokeData);
  5942. return;
  5943. }
  5944. else
  5945. {
  5946. if(header==NULL)
  5947. {
  5948. /* Connection Failed */
  5949. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  5950. RNDRelease(Service->Parent);
  5951. FREE(_InvokeData);
  5952. return;
  5953. }
  5954. else if(header->StatusCode!=200)
  5955. {
  5956. /* SOAP Fault */
  5957. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  5958. RNDRelease(Service->Parent);
  5959. FREE(_InvokeData);
  5960. return;
  5961. }
  5962. }
  5963. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  5964. RNDRelease(Service->Parent);
  5965. FREE(_InvokeData);
  5966. }
  5967. void RNDInvoke_RenderingControl_SetBlueVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredBlueVideoGain)
  5968. {
  5969. int headerLength;
  5970. char *headerBuffer;
  5971. char *SoapBodyTemplate;
  5972. char* buffer;
  5973. int bufferLength;
  5974. char* IP;
  5975. unsigned short Port;
  5976. char* Path;
  5977. struct sockaddr_in addr;
  5978. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  5979. if(service==NULL)
  5980. {
  5981. FREE(invoke_data);
  5982. return;
  5983. }
  5984. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+349);
  5985. SoapBodyTemplate = "%sSetBlueVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredBlueVideoGain>%u</DesiredBlueVideoGain></u:SetBlueVideoGain%s";
  5986. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredBlueVideoGain,UPNPCP_SOAP_BodyTail);
  5987. RNDAddRef(service->Parent);
  5988. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  5989. headerBuffer = (char*)MALLOC(169 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  5990. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetBlueVideoGain",bufferLength);
  5991. memset((char *)&addr, 0, sizeof(addr));
  5992. addr.sin_family = AF_INET;
  5993. addr.sin_addr.s_addr = inet_addr(IP);
  5994. addr.sin_port = htons(Port);
  5995. invoke_data->CallbackPtr = CallbackPtr;
  5996. invoke_data->User = user;
  5997. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetBlueVideoGain_Sink, service, invoke_data);
  5998. FREE(IP);
  5999. FREE(Path);
  6000. }
  6001. void RNDInvoke_RenderingControl_GetVerticalKeystone_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6002. {
  6003. struct UPnPService *Service = (struct UPnPService*)_service;
  6004. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6005. int ArgLeft = 1;
  6006. struct ILibXMLNode *xml;
  6007. struct ILibXMLNode *__xml;
  6008. char *tempBuffer;
  6009. int tempBufferLength;
  6010. long TempLong;
  6011. short CurrentVerticalKeystone = 0;
  6012. if(done==0){return;}
  6013. if(_InvokeData->CallbackPtr==NULL)
  6014. {
  6015. RNDRelease(Service->Parent);
  6016. FREE(_InvokeData);
  6017. return;
  6018. }
  6019. else
  6020. {
  6021. if(header==NULL)
  6022. {
  6023. /* Connection Failed */
  6024. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  6025. RNDRelease(Service->Parent);
  6026. FREE(_InvokeData);
  6027. return;
  6028. }
  6029. else if(header->StatusCode!=200)
  6030. {
  6031. /* SOAP Fault */
  6032. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  6033. RNDRelease(Service->Parent);
  6034. FREE(_InvokeData);
  6035. return;
  6036. }
  6037. }
  6038. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  6039. ILibProcessXMLNodeList(xml);
  6040. while(xml!=NULL)
  6041. {
  6042. if(xml->NameLength==27 && memcmp(xml->Name,"GetVerticalKeystoneResponse",27)==0)
  6043. {
  6044. xml = xml->Next;
  6045. while(xml!=NULL)
  6046. {
  6047. if(xml->NameLength==23 && memcmp(xml->Name,"CurrentVerticalKeystone",23) == 0)
  6048. {
  6049. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  6050. --ArgLeft;
  6051. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  6052. {
  6053. CurrentVerticalKeystone = (short) TempLong;
  6054. }
  6055. }
  6056. xml = xml->Peer;
  6057. }
  6058. }
  6059. if(xml!=NULL) {xml = xml->Next;}
  6060. }
  6061. ILibDestructXMLNodeList(__xml);
  6062. if(ArgLeft!=0)
  6063. {
  6064. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  6065. }
  6066. else
  6067. {
  6068. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentVerticalKeystone);
  6069. }
  6070. RNDRelease(Service->Parent);
  6071. FREE(_InvokeData);
  6072. }
  6073. void RNDInvoke_RenderingControl_GetVerticalKeystone(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,short), void* user, unsigned int InstanceID)
  6074. {
  6075. int headerLength;
  6076. char *headerBuffer;
  6077. char *SoapBodyTemplate;
  6078. char* buffer;
  6079. int bufferLength;
  6080. char* IP;
  6081. unsigned short Port;
  6082. char* Path;
  6083. struct sockaddr_in addr;
  6084. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6085. if(service==NULL)
  6086. {
  6087. FREE(invoke_data);
  6088. return;
  6089. }
  6090. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+305);
  6091. SoapBodyTemplate = "%sGetVerticalKeystone xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetVerticalKeystone%s";
  6092. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  6093. RNDAddRef(service->Parent);
  6094. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6095. headerBuffer = (char*)MALLOC(172 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6096. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetVerticalKeystone",bufferLength);
  6097. memset((char *)&addr, 0, sizeof(addr));
  6098. addr.sin_family = AF_INET;
  6099. addr.sin_addr.s_addr = inet_addr(IP);
  6100. addr.sin_port = htons(Port);
  6101. invoke_data->CallbackPtr = CallbackPtr;
  6102. invoke_data->User = user;
  6103. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetVerticalKeystone_Sink, service, invoke_data);
  6104. FREE(IP);
  6105. FREE(Path);
  6106. }
  6107. void RNDInvoke_RenderingControl_SetVerticalKeystone_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6108. {
  6109. struct UPnPService *Service = (struct UPnPService*)_service;
  6110. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6111. if(done==0){return;}
  6112. if(_InvokeData->CallbackPtr==NULL)
  6113. {
  6114. RNDRelease(Service->Parent);
  6115. FREE(_InvokeData);
  6116. return;
  6117. }
  6118. else
  6119. {
  6120. if(header==NULL)
  6121. {
  6122. /* Connection Failed */
  6123. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6124. RNDRelease(Service->Parent);
  6125. FREE(_InvokeData);
  6126. return;
  6127. }
  6128. else if(header->StatusCode!=200)
  6129. {
  6130. /* SOAP Fault */
  6131. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6132. RNDRelease(Service->Parent);
  6133. FREE(_InvokeData);
  6134. return;
  6135. }
  6136. }
  6137. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6138. RNDRelease(Service->Parent);
  6139. FREE(_InvokeData);
  6140. }
  6141. void RNDInvoke_RenderingControl_SetVerticalKeystone(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, short DesiredVerticalKeystone)
  6142. {
  6143. int headerLength;
  6144. char *headerBuffer;
  6145. char *SoapBodyTemplate;
  6146. char* buffer;
  6147. int bufferLength;
  6148. char* IP;
  6149. unsigned short Port;
  6150. char* Path;
  6151. struct sockaddr_in addr;
  6152. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6153. if(service==NULL)
  6154. {
  6155. FREE(invoke_data);
  6156. return;
  6157. }
  6158. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+362);
  6159. SoapBodyTemplate = "%sSetVerticalKeystone xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredVerticalKeystone>%d</DesiredVerticalKeystone></u:SetVerticalKeystone%s";
  6160. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredVerticalKeystone,UPNPCP_SOAP_BodyTail);
  6161. RNDAddRef(service->Parent);
  6162. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6163. headerBuffer = (char*)MALLOC(172 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6164. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetVerticalKeystone",bufferLength);
  6165. memset((char *)&addr, 0, sizeof(addr));
  6166. addr.sin_family = AF_INET;
  6167. addr.sin_addr.s_addr = inet_addr(IP);
  6168. addr.sin_port = htons(Port);
  6169. invoke_data->CallbackPtr = CallbackPtr;
  6170. invoke_data->User = user;
  6171. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetVerticalKeystone_Sink, service, invoke_data);
  6172. FREE(IP);
  6173. FREE(Path);
  6174. }
  6175. void RNDInvoke_RenderingControl_GetBrightness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6176. {
  6177. struct UPnPService *Service = (struct UPnPService*)_service;
  6178. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6179. int ArgLeft = 1;
  6180. struct ILibXMLNode *xml;
  6181. struct ILibXMLNode *__xml;
  6182. char *tempBuffer;
  6183. int tempBufferLength;
  6184. unsigned long TempULong;
  6185. unsigned short CurrentBrightness = 0;
  6186. if(done==0){return;}
  6187. if(_InvokeData->CallbackPtr==NULL)
  6188. {
  6189. RNDRelease(Service->Parent);
  6190. FREE(_InvokeData);
  6191. return;
  6192. }
  6193. else
  6194. {
  6195. if(header==NULL)
  6196. {
  6197. /* Connection Failed */
  6198. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  6199. RNDRelease(Service->Parent);
  6200. FREE(_InvokeData);
  6201. return;
  6202. }
  6203. else if(header->StatusCode!=200)
  6204. {
  6205. /* SOAP Fault */
  6206. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  6207. RNDRelease(Service->Parent);
  6208. FREE(_InvokeData);
  6209. return;
  6210. }
  6211. }
  6212. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  6213. ILibProcessXMLNodeList(xml);
  6214. while(xml!=NULL)
  6215. {
  6216. if(xml->NameLength==21 && memcmp(xml->Name,"GetBrightnessResponse",21)==0)
  6217. {
  6218. xml = xml->Next;
  6219. while(xml!=NULL)
  6220. {
  6221. if(xml->NameLength==17 && memcmp(xml->Name,"CurrentBrightness",17) == 0)
  6222. {
  6223. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  6224. --ArgLeft;
  6225. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  6226. {
  6227. CurrentBrightness = (unsigned short) TempULong;
  6228. }
  6229. }
  6230. xml = xml->Peer;
  6231. }
  6232. }
  6233. if(xml!=NULL) {xml = xml->Next;}
  6234. }
  6235. ILibDestructXMLNodeList(__xml);
  6236. if(ArgLeft!=0)
  6237. {
  6238. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  6239. }
  6240. else
  6241. {
  6242. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentBrightness);
  6243. }
  6244. RNDRelease(Service->Parent);
  6245. FREE(_InvokeData);
  6246. }
  6247. void RNDInvoke_RenderingControl_GetBrightness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  6248. {
  6249. int headerLength;
  6250. char *headerBuffer;
  6251. char *SoapBodyTemplate;
  6252. char* buffer;
  6253. int bufferLength;
  6254. char* IP;
  6255. unsigned short Port;
  6256. char* Path;
  6257. struct sockaddr_in addr;
  6258. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6259. if(service==NULL)
  6260. {
  6261. FREE(invoke_data);
  6262. return;
  6263. }
  6264. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+293);
  6265. SoapBodyTemplate = "%sGetBrightness xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetBrightness%s";
  6266. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  6267. RNDAddRef(service->Parent);
  6268. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6269. headerBuffer = (char*)MALLOC(166 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6270. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetBrightness",bufferLength);
  6271. memset((char *)&addr, 0, sizeof(addr));
  6272. addr.sin_family = AF_INET;
  6273. addr.sin_addr.s_addr = inet_addr(IP);
  6274. addr.sin_port = htons(Port);
  6275. invoke_data->CallbackPtr = CallbackPtr;
  6276. invoke_data->User = user;
  6277. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetBrightness_Sink, service, invoke_data);
  6278. FREE(IP);
  6279. FREE(Path);
  6280. }
  6281. void RNDInvoke_RenderingControl_GetVolumeDB_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6282. {
  6283. struct UPnPService *Service = (struct UPnPService*)_service;
  6284. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6285. int ArgLeft = 1;
  6286. struct ILibXMLNode *xml;
  6287. struct ILibXMLNode *__xml;
  6288. char *tempBuffer;
  6289. int tempBufferLength;
  6290. long TempLong;
  6291. short CurrentVolume = 0;
  6292. if(done==0){return;}
  6293. if(_InvokeData->CallbackPtr==NULL)
  6294. {
  6295. RNDRelease(Service->Parent);
  6296. FREE(_InvokeData);
  6297. return;
  6298. }
  6299. else
  6300. {
  6301. if(header==NULL)
  6302. {
  6303. /* Connection Failed */
  6304. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  6305. RNDRelease(Service->Parent);
  6306. FREE(_InvokeData);
  6307. return;
  6308. }
  6309. else if(header->StatusCode!=200)
  6310. {
  6311. /* SOAP Fault */
  6312. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  6313. RNDRelease(Service->Parent);
  6314. FREE(_InvokeData);
  6315. return;
  6316. }
  6317. }
  6318. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  6319. ILibProcessXMLNodeList(xml);
  6320. while(xml!=NULL)
  6321. {
  6322. if(xml->NameLength==19 && memcmp(xml->Name,"GetVolumeDBResponse",19)==0)
  6323. {
  6324. xml = xml->Next;
  6325. while(xml!=NULL)
  6326. {
  6327. if(xml->NameLength==13 && memcmp(xml->Name,"CurrentVolume",13) == 0)
  6328. {
  6329. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  6330. --ArgLeft;
  6331. if(ILibGetLong(tempBuffer,tempBufferLength,&TempLong)==0)
  6332. {
  6333. CurrentVolume = (short) TempLong;
  6334. }
  6335. }
  6336. xml = xml->Peer;
  6337. }
  6338. }
  6339. if(xml!=NULL) {xml = xml->Next;}
  6340. }
  6341. ILibDestructXMLNodeList(__xml);
  6342. if(ArgLeft!=0)
  6343. {
  6344. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  6345. }
  6346. else
  6347. {
  6348. ((void (*)(struct UPnPService*,int,void*,short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentVolume);
  6349. }
  6350. RNDRelease(Service->Parent);
  6351. FREE(_InvokeData);
  6352. }
  6353. void RNDInvoke_RenderingControl_GetVolumeDB(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,short), void* user, unsigned int InstanceID, char* Channel)
  6354. {
  6355. int headerLength;
  6356. char *headerBuffer;
  6357. char *SoapBodyTemplate;
  6358. char* buffer;
  6359. int bufferLength;
  6360. char* IP;
  6361. unsigned short Port;
  6362. char* Path;
  6363. struct sockaddr_in addr;
  6364. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6365. if(service==NULL)
  6366. {
  6367. FREE(invoke_data);
  6368. return;
  6369. }
  6370. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+308);
  6371. SoapBodyTemplate = "%sGetVolumeDB xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel></u:GetVolumeDB%s";
  6372. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel,UPNPCP_SOAP_BodyTail);
  6373. RNDAddRef(service->Parent);
  6374. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6375. headerBuffer = (char*)MALLOC(164 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6376. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetVolumeDB",bufferLength);
  6377. memset((char *)&addr, 0, sizeof(addr));
  6378. addr.sin_family = AF_INET;
  6379. addr.sin_addr.s_addr = inet_addr(IP);
  6380. addr.sin_port = htons(Port);
  6381. invoke_data->CallbackPtr = CallbackPtr;
  6382. invoke_data->User = user;
  6383. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetVolumeDB_Sink, service, invoke_data);
  6384. FREE(IP);
  6385. FREE(Path);
  6386. }
  6387. void RNDInvoke_RenderingControl_GetGreenVideoBlackLevel_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6388. {
  6389. struct UPnPService *Service = (struct UPnPService*)_service;
  6390. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6391. int ArgLeft = 1;
  6392. struct ILibXMLNode *xml;
  6393. struct ILibXMLNode *__xml;
  6394. char *tempBuffer;
  6395. int tempBufferLength;
  6396. unsigned long TempULong;
  6397. unsigned short CurrentGreenVideoBlackLevel = 0;
  6398. if(done==0){return;}
  6399. if(_InvokeData->CallbackPtr==NULL)
  6400. {
  6401. RNDRelease(Service->Parent);
  6402. FREE(_InvokeData);
  6403. return;
  6404. }
  6405. else
  6406. {
  6407. if(header==NULL)
  6408. {
  6409. /* Connection Failed */
  6410. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  6411. RNDRelease(Service->Parent);
  6412. FREE(_InvokeData);
  6413. return;
  6414. }
  6415. else if(header->StatusCode!=200)
  6416. {
  6417. /* SOAP Fault */
  6418. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  6419. RNDRelease(Service->Parent);
  6420. FREE(_InvokeData);
  6421. return;
  6422. }
  6423. }
  6424. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  6425. ILibProcessXMLNodeList(xml);
  6426. while(xml!=NULL)
  6427. {
  6428. if(xml->NameLength==31 && memcmp(xml->Name,"GetGreenVideoBlackLevelResponse",31)==0)
  6429. {
  6430. xml = xml->Next;
  6431. while(xml!=NULL)
  6432. {
  6433. if(xml->NameLength==27 && memcmp(xml->Name,"CurrentGreenVideoBlackLevel",27) == 0)
  6434. {
  6435. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  6436. --ArgLeft;
  6437. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  6438. {
  6439. CurrentGreenVideoBlackLevel = (unsigned short) TempULong;
  6440. }
  6441. }
  6442. xml = xml->Peer;
  6443. }
  6444. }
  6445. if(xml!=NULL) {xml = xml->Next;}
  6446. }
  6447. ILibDestructXMLNodeList(__xml);
  6448. if(ArgLeft!=0)
  6449. {
  6450. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  6451. }
  6452. else
  6453. {
  6454. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentGreenVideoBlackLevel);
  6455. }
  6456. RNDRelease(Service->Parent);
  6457. FREE(_InvokeData);
  6458. }
  6459. void RNDInvoke_RenderingControl_GetGreenVideoBlackLevel(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  6460. {
  6461. int headerLength;
  6462. char *headerBuffer;
  6463. char *SoapBodyTemplate;
  6464. char* buffer;
  6465. int bufferLength;
  6466. char* IP;
  6467. unsigned short Port;
  6468. char* Path;
  6469. struct sockaddr_in addr;
  6470. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6471. if(service==NULL)
  6472. {
  6473. FREE(invoke_data);
  6474. return;
  6475. }
  6476. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+313);
  6477. SoapBodyTemplate = "%sGetGreenVideoBlackLevel xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetGreenVideoBlackLevel%s";
  6478. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  6479. RNDAddRef(service->Parent);
  6480. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6481. headerBuffer = (char*)MALLOC(176 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6482. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetGreenVideoBlackLevel",bufferLength);
  6483. memset((char *)&addr, 0, sizeof(addr));
  6484. addr.sin_family = AF_INET;
  6485. addr.sin_addr.s_addr = inet_addr(IP);
  6486. addr.sin_port = htons(Port);
  6487. invoke_data->CallbackPtr = CallbackPtr;
  6488. invoke_data->User = user;
  6489. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetGreenVideoBlackLevel_Sink, service, invoke_data);
  6490. FREE(IP);
  6491. FREE(Path);
  6492. }
  6493. void RNDInvoke_RenderingControl_GetRedVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6494. {
  6495. struct UPnPService *Service = (struct UPnPService*)_service;
  6496. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6497. int ArgLeft = 1;
  6498. struct ILibXMLNode *xml;
  6499. struct ILibXMLNode *__xml;
  6500. char *tempBuffer;
  6501. int tempBufferLength;
  6502. unsigned long TempULong;
  6503. unsigned short CurrentRedVideoGain = 0;
  6504. if(done==0){return;}
  6505. if(_InvokeData->CallbackPtr==NULL)
  6506. {
  6507. RNDRelease(Service->Parent);
  6508. FREE(_InvokeData);
  6509. return;
  6510. }
  6511. else
  6512. {
  6513. if(header==NULL)
  6514. {
  6515. /* Connection Failed */
  6516. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User,INVALID_DATA);
  6517. RNDRelease(Service->Parent);
  6518. FREE(_InvokeData);
  6519. return;
  6520. }
  6521. else if(header->StatusCode!=200)
  6522. {
  6523. /* SOAP Fault */
  6524. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User,INVALID_DATA);
  6525. RNDRelease(Service->Parent);
  6526. FREE(_InvokeData);
  6527. return;
  6528. }
  6529. }
  6530. __xml = xml = ILibParseXML(buffer,0,EndPointer-(*p_BeginPointer));
  6531. ILibProcessXMLNodeList(xml);
  6532. while(xml!=NULL)
  6533. {
  6534. if(xml->NameLength==23 && memcmp(xml->Name,"GetRedVideoGainResponse",23)==0)
  6535. {
  6536. xml = xml->Next;
  6537. while(xml!=NULL)
  6538. {
  6539. if(xml->NameLength==19 && memcmp(xml->Name,"CurrentRedVideoGain",19) == 0)
  6540. {
  6541. tempBufferLength = ILibReadInnerXML(xml,&tempBuffer);
  6542. --ArgLeft;
  6543. if(ILibGetULong(tempBuffer,tempBufferLength,&TempULong)==0)
  6544. {
  6545. CurrentRedVideoGain = (unsigned short) TempULong;
  6546. }
  6547. }
  6548. xml = xml->Peer;
  6549. }
  6550. }
  6551. if(xml!=NULL) {xml = xml->Next;}
  6552. }
  6553. ILibDestructXMLNodeList(__xml);
  6554. if(ArgLeft!=0)
  6555. {
  6556. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,-2,_InvokeData->User,INVALID_DATA);
  6557. }
  6558. else
  6559. {
  6560. ((void (*)(struct UPnPService*,int,void*,unsigned short))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User,CurrentRedVideoGain);
  6561. }
  6562. RNDRelease(Service->Parent);
  6563. FREE(_InvokeData);
  6564. }
  6565. void RNDInvoke_RenderingControl_GetRedVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*,unsigned short), void* user, unsigned int InstanceID)
  6566. {
  6567. int headerLength;
  6568. char *headerBuffer;
  6569. char *SoapBodyTemplate;
  6570. char* buffer;
  6571. int bufferLength;
  6572. char* IP;
  6573. unsigned short Port;
  6574. char* Path;
  6575. struct sockaddr_in addr;
  6576. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6577. if(service==NULL)
  6578. {
  6579. FREE(invoke_data);
  6580. return;
  6581. }
  6582. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+297);
  6583. SoapBodyTemplate = "%sGetRedVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID></u:GetRedVideoGain%s";
  6584. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID,UPNPCP_SOAP_BodyTail);
  6585. RNDAddRef(service->Parent);
  6586. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6587. headerBuffer = (char*)MALLOC(168 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6588. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"GetRedVideoGain",bufferLength);
  6589. memset((char *)&addr, 0, sizeof(addr));
  6590. addr.sin_family = AF_INET;
  6591. addr.sin_addr.s_addr = inet_addr(IP);
  6592. addr.sin_port = htons(Port);
  6593. invoke_data->CallbackPtr = CallbackPtr;
  6594. invoke_data->User = user;
  6595. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_GetRedVideoGain_Sink, service, invoke_data);
  6596. FREE(IP);
  6597. FREE(Path);
  6598. }
  6599. void RNDInvoke_RenderingControl_SetMute_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6600. {
  6601. struct UPnPService *Service = (struct UPnPService*)_service;
  6602. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6603. if(done==0){return;}
  6604. if(_InvokeData->CallbackPtr==NULL)
  6605. {
  6606. RNDRelease(Service->Parent);
  6607. FREE(_InvokeData);
  6608. return;
  6609. }
  6610. else
  6611. {
  6612. if(header==NULL)
  6613. {
  6614. /* Connection Failed */
  6615. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6616. RNDRelease(Service->Parent);
  6617. FREE(_InvokeData);
  6618. return;
  6619. }
  6620. else if(header->StatusCode!=200)
  6621. {
  6622. /* SOAP Fault */
  6623. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6624. RNDRelease(Service->Parent);
  6625. FREE(_InvokeData);
  6626. return;
  6627. }
  6628. }
  6629. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6630. RNDRelease(Service->Parent);
  6631. FREE(_InvokeData);
  6632. }
  6633. void RNDInvoke_RenderingControl_SetMute(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, char* Channel, int DesiredMute)
  6634. {
  6635. int headerLength;
  6636. char *headerBuffer;
  6637. char *SoapBodyTemplate;
  6638. char* buffer;
  6639. int bufferLength;
  6640. char* IP;
  6641. unsigned short Port;
  6642. char* Path;
  6643. struct sockaddr_in addr;
  6644. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6645. char* __DesiredMute;
  6646. if(service==NULL)
  6647. {
  6648. FREE(invoke_data);
  6649. return;
  6650. }
  6651. (DesiredMute!=0)?(__DesiredMute="true"):(__DesiredMute="false");
  6652. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+(int)strlen(Channel)+332);
  6653. SoapBodyTemplate = "%sSetMute xmlns:u=\"%s\"><InstanceID>%u</InstanceID><Channel>%s</Channel><DesiredMute>%s</DesiredMute></u:SetMute%s";
  6654. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, Channel, __DesiredMute,UPNPCP_SOAP_BodyTail);
  6655. RNDAddRef(service->Parent);
  6656. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6657. headerBuffer = (char*)MALLOC(160 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6658. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetMute",bufferLength);
  6659. memset((char *)&addr, 0, sizeof(addr));
  6660. addr.sin_family = AF_INET;
  6661. addr.sin_addr.s_addr = inet_addr(IP);
  6662. addr.sin_port = htons(Port);
  6663. invoke_data->CallbackPtr = CallbackPtr;
  6664. invoke_data->User = user;
  6665. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetMute_Sink, service, invoke_data);
  6666. FREE(IP);
  6667. FREE(Path);
  6668. }
  6669. void RNDInvoke_RenderingControl_SetGreenVideoGain_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6670. {
  6671. struct UPnPService *Service = (struct UPnPService*)_service;
  6672. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6673. if(done==0){return;}
  6674. if(_InvokeData->CallbackPtr==NULL)
  6675. {
  6676. RNDRelease(Service->Parent);
  6677. FREE(_InvokeData);
  6678. return;
  6679. }
  6680. else
  6681. {
  6682. if(header==NULL)
  6683. {
  6684. /* Connection Failed */
  6685. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6686. RNDRelease(Service->Parent);
  6687. FREE(_InvokeData);
  6688. return;
  6689. }
  6690. else if(header->StatusCode!=200)
  6691. {
  6692. /* SOAP Fault */
  6693. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6694. RNDRelease(Service->Parent);
  6695. FREE(_InvokeData);
  6696. return;
  6697. }
  6698. }
  6699. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6700. RNDRelease(Service->Parent);
  6701. FREE(_InvokeData);
  6702. }
  6703. void RNDInvoke_RenderingControl_SetGreenVideoGain(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredGreenVideoGain)
  6704. {
  6705. int headerLength;
  6706. char *headerBuffer;
  6707. char *SoapBodyTemplate;
  6708. char* buffer;
  6709. int bufferLength;
  6710. char* IP;
  6711. unsigned short Port;
  6712. char* Path;
  6713. struct sockaddr_in addr;
  6714. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6715. if(service==NULL)
  6716. {
  6717. FREE(invoke_data);
  6718. return;
  6719. }
  6720. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+353);
  6721. SoapBodyTemplate = "%sSetGreenVideoGain xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredGreenVideoGain>%u</DesiredGreenVideoGain></u:SetGreenVideoGain%s";
  6722. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredGreenVideoGain,UPNPCP_SOAP_BodyTail);
  6723. RNDAddRef(service->Parent);
  6724. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6725. headerBuffer = (char*)MALLOC(170 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6726. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetGreenVideoGain",bufferLength);
  6727. memset((char *)&addr, 0, sizeof(addr));
  6728. addr.sin_family = AF_INET;
  6729. addr.sin_addr.s_addr = inet_addr(IP);
  6730. addr.sin_port = htons(Port);
  6731. invoke_data->CallbackPtr = CallbackPtr;
  6732. invoke_data->User = user;
  6733. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetGreenVideoGain_Sink, service, invoke_data);
  6734. FREE(IP);
  6735. FREE(Path);
  6736. }
  6737. void RNDInvoke_RenderingControl_SetSharpness_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6738. {
  6739. struct UPnPService *Service = (struct UPnPService*)_service;
  6740. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6741. if(done==0){return;}
  6742. if(_InvokeData->CallbackPtr==NULL)
  6743. {
  6744. RNDRelease(Service->Parent);
  6745. FREE(_InvokeData);
  6746. return;
  6747. }
  6748. else
  6749. {
  6750. if(header==NULL)
  6751. {
  6752. /* Connection Failed */
  6753. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6754. RNDRelease(Service->Parent);
  6755. FREE(_InvokeData);
  6756. return;
  6757. }
  6758. else if(header->StatusCode!=200)
  6759. {
  6760. /* SOAP Fault */
  6761. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6762. RNDRelease(Service->Parent);
  6763. FREE(_InvokeData);
  6764. return;
  6765. }
  6766. }
  6767. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6768. RNDRelease(Service->Parent);
  6769. FREE(_InvokeData);
  6770. }
  6771. void RNDInvoke_RenderingControl_SetSharpness(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredSharpness)
  6772. {
  6773. int headerLength;
  6774. char *headerBuffer;
  6775. char *SoapBodyTemplate;
  6776. char* buffer;
  6777. int bufferLength;
  6778. char* IP;
  6779. unsigned short Port;
  6780. char* Path;
  6781. struct sockaddr_in addr;
  6782. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6783. if(service==NULL)
  6784. {
  6785. FREE(invoke_data);
  6786. return;
  6787. }
  6788. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+333);
  6789. SoapBodyTemplate = "%sSetSharpness xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredSharpness>%u</DesiredSharpness></u:SetSharpness%s";
  6790. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredSharpness,UPNPCP_SOAP_BodyTail);
  6791. RNDAddRef(service->Parent);
  6792. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6793. headerBuffer = (char*)MALLOC(165 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6794. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetSharpness",bufferLength);
  6795. memset((char *)&addr, 0, sizeof(addr));
  6796. addr.sin_family = AF_INET;
  6797. addr.sin_addr.s_addr = inet_addr(IP);
  6798. addr.sin_port = htons(Port);
  6799. invoke_data->CallbackPtr = CallbackPtr;
  6800. invoke_data->User = user;
  6801. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetSharpness_Sink, service, invoke_data);
  6802. FREE(IP);
  6803. FREE(Path);
  6804. }
  6805. void RNDInvoke_RenderingControl_SetHorizontalKeystone_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6806. {
  6807. struct UPnPService *Service = (struct UPnPService*)_service;
  6808. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6809. if(done==0){return;}
  6810. if(_InvokeData->CallbackPtr==NULL)
  6811. {
  6812. RNDRelease(Service->Parent);
  6813. FREE(_InvokeData);
  6814. return;
  6815. }
  6816. else
  6817. {
  6818. if(header==NULL)
  6819. {
  6820. /* Connection Failed */
  6821. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6822. RNDRelease(Service->Parent);
  6823. FREE(_InvokeData);
  6824. return;
  6825. }
  6826. else if(header->StatusCode!=200)
  6827. {
  6828. /* SOAP Fault */
  6829. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6830. RNDRelease(Service->Parent);
  6831. FREE(_InvokeData);
  6832. return;
  6833. }
  6834. }
  6835. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6836. RNDRelease(Service->Parent);
  6837. FREE(_InvokeData);
  6838. }
  6839. void RNDInvoke_RenderingControl_SetHorizontalKeystone(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, short DesiredHorizontalKeystone)
  6840. {
  6841. int headerLength;
  6842. char *headerBuffer;
  6843. char *SoapBodyTemplate;
  6844. char* buffer;
  6845. int bufferLength;
  6846. char* IP;
  6847. unsigned short Port;
  6848. char* Path;
  6849. struct sockaddr_in addr;
  6850. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6851. if(service==NULL)
  6852. {
  6853. FREE(invoke_data);
  6854. return;
  6855. }
  6856. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+370);
  6857. SoapBodyTemplate = "%sSetHorizontalKeystone xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredHorizontalKeystone>%d</DesiredHorizontalKeystone></u:SetHorizontalKeystone%s";
  6858. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredHorizontalKeystone,UPNPCP_SOAP_BodyTail);
  6859. RNDAddRef(service->Parent);
  6860. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6861. headerBuffer = (char*)MALLOC(174 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6862. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetHorizontalKeystone",bufferLength);
  6863. memset((char *)&addr, 0, sizeof(addr));
  6864. addr.sin_family = AF_INET;
  6865. addr.sin_addr.s_addr = inet_addr(IP);
  6866. addr.sin_port = htons(Port);
  6867. invoke_data->CallbackPtr = CallbackPtr;
  6868. invoke_data->User = user;
  6869. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetHorizontalKeystone_Sink, service, invoke_data);
  6870. FREE(IP);
  6871. FREE(Path);
  6872. }
  6873. void RNDInvoke_RenderingControl_SetColorTemperature_Sink(void *reader, struct packetheader *header, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* _service, void *state)
  6874. {
  6875. struct UPnPService *Service = (struct UPnPService*)_service;
  6876. struct InvokeStruct *_InvokeData = (struct InvokeStruct*)state;
  6877. if(done==0){return;}
  6878. if(_InvokeData->CallbackPtr==NULL)
  6879. {
  6880. RNDRelease(Service->Parent);
  6881. FREE(_InvokeData);
  6882. return;
  6883. }
  6884. else
  6885. {
  6886. if(header==NULL)
  6887. {
  6888. /* Connection Failed */
  6889. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,-1,_InvokeData->User);
  6890. RNDRelease(Service->Parent);
  6891. FREE(_InvokeData);
  6892. return;
  6893. }
  6894. else if(header->StatusCode!=200)
  6895. {
  6896. /* SOAP Fault */
  6897. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,RNDGetErrorCode(buffer,EndPointer-(*p_BeginPointer)),_InvokeData->User);
  6898. RNDRelease(Service->Parent);
  6899. FREE(_InvokeData);
  6900. return;
  6901. }
  6902. }
  6903. ((void (*)(struct UPnPService*,int,void*))_InvokeData->CallbackPtr)(Service,0,_InvokeData->User);
  6904. RNDRelease(Service->Parent);
  6905. FREE(_InvokeData);
  6906. }
  6907. void RNDInvoke_RenderingControl_SetColorTemperature(struct UPnPService *service,void (*CallbackPtr)(struct UPnPService*,int,void*), void* user, unsigned int InstanceID, unsigned short DesiredColorTemperature)
  6908. {
  6909. int headerLength;
  6910. char *headerBuffer;
  6911. char *SoapBodyTemplate;
  6912. char* buffer;
  6913. int bufferLength;
  6914. char* IP;
  6915. unsigned short Port;
  6916. char* Path;
  6917. struct sockaddr_in addr;
  6918. struct InvokeStruct *invoke_data = (struct InvokeStruct*)MALLOC(sizeof(struct InvokeStruct));
  6919. if(service==NULL)
  6920. {
  6921. FREE(invoke_data);
  6922. return;
  6923. }
  6924. buffer = (char*)MALLOC((int)strlen(service->ServiceType)+361);
  6925. SoapBodyTemplate = "%sSetColorTemperature xmlns:u=\"%s\"><InstanceID>%u</InstanceID><DesiredColorTemperature>%u</DesiredColorTemperature></u:SetColorTemperature%s";
  6926. bufferLength = sprintf(buffer,SoapBodyTemplate,UPNPCP_SOAP_BodyHead,service->ServiceType, InstanceID, DesiredColorTemperature,UPNPCP_SOAP_BodyTail);
  6927. RNDAddRef(service->Parent);
  6928. RNDParseUri(service->ControlURL,&IP,&Port,&Path);
  6929. headerBuffer = (char*)MALLOC(172 + (int)strlen(Path) + (int)strlen(IP) + (int)strlen(service->ServiceType));
  6930. headerLength = sprintf(headerBuffer,UPNPCP_SOAP_Header,Path,IP,Port,service->ServiceType,"SetColorTemperature",bufferLength);
  6931. memset((char *)&addr, 0, sizeof(addr));
  6932. addr.sin_family = AF_INET;
  6933. addr.sin_addr.s_addr = inet_addr(IP);
  6934. addr.sin_port = htons(Port);
  6935. invoke_data->CallbackPtr = CallbackPtr;
  6936. invoke_data->User = user;
  6937. ILibAddRequest_DirectEx(((struct RNDCP*)service->Parent->CP)->HTTP, headerBuffer,headerLength,buffer,bufferLength,&addr, &RNDInvoke_RenderingControl_SetColorTemperature_Sink, service, invoke_data);
  6938. FREE(IP);
  6939. FREE(Path);
  6940. }
  6941. void RNDSubscribeForUPnPEvents(struct UPnPService *service, void(*callbackPtr)(struct UPnPService* service,int OK))
  6942. {
  6943. char* callback;
  6944. char *IP;
  6945. char *Path;
  6946. unsigned short Port;
  6947. struct packetheader *p;
  6948. char* TempString;
  6949. struct sockaddr_in destaddr;
  6950. RNDParseUri(service->SubscriptionURL,&IP,&Port,&Path);
  6951. p = ILibCreateEmptyPacket();
  6952. ILibSetDirective(p,"SUBSCRIBE",9,Path,(int)strlen(Path));
  6953. TempString = (char*)MALLOC((int)strlen(IP)+7);
  6954. sprintf(TempString,"%s:%d",IP,Port);
  6955. ILibAddHeaderLine(p,"HOST",4,TempString,(int)strlen(TempString));
  6956. FREE(TempString);
  6957. ILibAddHeaderLine(p,"NT",2,"upnp:event",10);
  6958. ILibAddHeaderLine(p,"TIMEOUT",7,"Second-180",10);
  6959. ILibAddHeaderLine(p,"User-Agent",10,"POSIX, UPnP/1.0, Intel MicroStack/1.0.1189",42);
  6960. callback = (char*)MALLOC(10+(int)strlen(service->Parent->InterfaceToHost)+6+(int)strlen(Path));
  6961. sprintf(callback,"<http://%s:%d%s>",service->Parent->InterfaceToHost,ILibGetMiniWebServerPortNumber(((struct RNDCP*)service->Parent->CP)->WebServer),Path);
  6962. ILibAddHeaderLine(p,"CALLBACK",8,callback,(int)strlen(callback));
  6963. FREE(callback);
  6964. memset((char *)&destaddr, 0,sizeof(destaddr));
  6965. destaddr.sin_family = AF_INET;
  6966. destaddr.sin_addr.s_addr = inet_addr(IP);
  6967. destaddr.sin_port = htons(Port);
  6968. RNDAddRef(service->Parent);
  6969. ILibAddRequest(((struct RNDCP*)service->Parent->CP)->HTTP, p,&destaddr, &RNDOnSubscribeSink, (void*)service,service->Parent->CP);
  6970. FREE(IP);
  6971. FREE(Path);
  6972. }