github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

dieb / eupnp

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 351f02d

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

UPnP library for the Enlightenment project. — Read more

  cancel

http://genuinepulse.blogspot.com

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Implemented Event Bus module, fixed init and shutdown on SSDP module and 
modified example to demonstrate the event bus usage. 
dieb (author)
Mon Jun 01 17:18:04 -0700 2009
commit  351f02d6b6b6aba9ee6e7ed50fbe7041e6ed3241
tree    6c648ff2c9b9d2e50803a36c6193a04915511ea1
parent  4e4faa629d1fd639c105f0affce5d6211d426cd2
eupnp / src / bin / eupnp_basic_control_point.c src/bin/eupnp_basic_control_point.c
100644 105 lines (87 sloc) 2.204 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
 
#include <Eina.h>
#include <eupnp.h>
#include <eupnp_error.h>
#include <eupnp_ssdp.h>
#include <eupnp_control_point.h>
#include <eupnp_event_bus.h>
 
int sock;
int exit_req = 0;
 
void terminate(int p)
{
   exit_req = 1;
}
 
Eina_Bool on_device_found(Eupnp_Event *e)
{
   INFO("Received event type %d\n", e->type);
   return EINA_TRUE;
}
 
Eina_Bool on_device_gone_singleshot(Eupnp_Event *e)
{
   INFO("Received event type %d\n", e->type);
   INFO("Returning FALSE to remove the subscription..\n");
   return EINA_FALSE;
}
 
/*
* Sends a test search and listens for datagrams. Tests MSearch and SSDP
* server.
*
* Run with "EINA_ERROR_LEVEL=3 ./eupnp_basic_control_point" for watching debug
* messages.
*/
int main(void)
{
   signal(SIGTERM, terminate);
   signal(SIGINT, terminate);
   eupnp_init();
 
   int ret;
   fd_set r, w, ex;
   Eupnp_Control_Point *c;
 
   c = eupnp_control_point_new();
 
   if (!c)
     {
eupnp_shutdown();
return -1;
     }
 
   eupnp_event_bus_subscribe(EUPNP_EVENT_DEVICE_FOUND,
EUPNP_CALLBACK(on_device_found));
   eupnp_event_bus_subscribe(EUPNP_EVENT_DEVICE_GONE,
EUPNP_CALLBACK(on_device_gone_singleshot));
 
   /* Send a test search */
   if (!eupnp_control_point_discovery_request_send(c, 5, "ssdp:all"))
     {
EINA_ERROR_PWARN("Failed to perform MSearch.\n");
     }
    else
EINA_ERROR_PDBG("MSearch sent sucessfully.\n");
 
   sock = eupnp_control_point_ssdp_socket_get(c);
 
   while (!exit_req)
     {
FD_ZERO(&r);
FD_ZERO(&w);
FD_ZERO(&ex);
FD_SET(sock, &r);
ret = select(sock+1, &r, NULL, NULL, NULL);
 
if (ret < 0)
{
perror("Select error");
break;
}
 
if (exit_req)
break;
 
if (FD_ISSET(sock, &r))
{
/* This is the event handler that will be added to the event loop.
* For example, when integrating eupnp+ecore, this socket will
* internally be added with ecore_fd_handler_add and the handler
* passed will be a wrapper of _eupnp_ssdp_on_datagram_available.
*/
_eupnp_ssdp_on_datagram_available(c->ssdp_server);
          }
     }
 
   eupnp_control_point_free(c);
   eupnp_shutdown();
   return 0;
}
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server