summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-04-15 20:20:08 +0200
committerDave Andreoli <dave@gurumeditation.it>2017-04-15 20:20:08 +0200
commit4557daa602e259e77afc92c6c3a631d6540e8536 (patch)
treef698621968caf39688c97ea34f73ce3a9b89c0b1
parenta70c42e6814a5368164e749ff497c215519314a4 (diff)
EcoreConUrl is no more an Eo object :(
#FollowTheWhiteRabbit
-rw-r--r--efl/ecore_con/efl.ecore_con_url.pxi98
-rw-r--r--include/efl.ecore_con.pxd5
2 files changed, 62 insertions, 41 deletions
diff --git a/efl/ecore_con/efl.ecore_con_url.pxi b/efl/ecore_con/efl.ecore_con_url.pxi
index 1b38f6c..468f14d 100644
--- a/efl/ecore_con/efl.ecore_con_url.pxi
+++ b/efl/ecore_con/efl.ecore_con_url.pxi
@@ -37,7 +37,7 @@ cdef class EventUrlProgress(Event):
37 cdef Ecore_Con_Event_Url_Progress *event 37 cdef Ecore_Con_Event_Url_Progress *event
38 event = <Ecore_Con_Event_Url_Progress*>ev 38 event = <Ecore_Con_Event_Url_Progress*>ev
39 39
40 self.url = object_from_instance(event.url_con) 40 self.url = <Url>ecore_con_url_data_get(event.url_con)
41 self.down_total = event.down.total 41 self.down_total = event.down.total
42 self.down_now = event.down.now 42 self.down_now = event.down.now
43 self.up_total = event.up.total 43 self.up_total = event.up.total
@@ -61,7 +61,7 @@ cdef class EventUrlComplete(Event):
61 cdef Ecore_Con_Event_Url_Complete *event 61 cdef Ecore_Con_Event_Url_Complete *event
62 event = <Ecore_Con_Event_Url_Complete*>ev 62 event = <Ecore_Con_Event_Url_Complete*>ev
63 63
64 self.url = object_from_instance(event.url_con) 64 self.url = <Url>ecore_con_url_data_get(event.url_con)
65 self.status = event.status 65 self.status = event.status
66 return 1 66 return 1
67 67
@@ -87,7 +87,7 @@ cdef class EventUrlData(Event):
87 cdef Ecore_Con_Event_Url_Data *event 87 cdef Ecore_Con_Event_Url_Data *event
88 event = <Ecore_Con_Event_Url_Data*>ev 88 event = <Ecore_Con_Event_Url_Data*>ev
89 89
90 self.url = object_from_instance(event.url_con) 90 self.url = <Url>ecore_con_url_data_get(event.url_con)
91 self.size = event.size 91 self.size = event.size
92 self.data = event.data[:event.size] #raw string copy 92 self.data = event.data[:event.size] #raw string copy
93 return 1 93 return 1
@@ -211,15 +211,22 @@ cdef class Url(Eo):
211 """ 211 """
212 if isinstance(url, unicode): url = PyUnicode_AsUTF8String(url) 212 if isinstance(url, unicode): url = PyUnicode_AsUTF8String(url)
213 if custom_request is None: 213 if custom_request is None:
214 self._set_obj(ecore_con_url_new( 214 # From efl 1.19 url are no more Eo objects in C, thus
215 <const char *>url if url is not None else NULL)) 215 # we cannot use Eo.obj and _set_obj() anymore :(
216 # self._set_obj(ecore_con_url_new(
217 # <const char *>url if url is not None else NULL))
218 self.obj2 = ecore_con_url_new(
219 <const char *>url if url is not None else NULL)
220
216 else: 221 else:
217 if isinstance(custom_request, unicode): 222 if isinstance(custom_request, unicode):
218 custom_request = PyUnicode_AsUTF8String(custom_request) 223 custom_request = PyUnicode_AsUTF8String(custom_request)
219 self._set_obj(ecore_con_url_custom_new( 224 self.obj2 = ecore_con_url_custom_new(
220 <const char *>url if url is not None else NULL, 225 <const char *>url if url is not None else NULL,
221 <const char *>custom_request if custom_request is not None else NULL)) 226 <const char *>custom_request if custom_request is not None else NULL)
222 227
228 ecore_con_url_data_set(self.obj2, <void *>self)
229 Py_INCREF(self)
223 self._set_properties_from_keyword_args(kargs) 230 self._set_properties_from_keyword_args(kargs)
224 231
225 def __repr__(self): 232 def __repr__(self):
@@ -235,7 +242,18 @@ cdef class Url(Eo):
235 242
236 """ 243 """
237 GEF.callback_del_full(self) 244 GEF.callback_del_full(self)
238 ecore_con_url_free(self.obj) 245 ecore_con_url_free(self.obj2)
246 self.obj2 = NULL
247 Py_DECREF(self)
248
249 def is_deleted(self):
250 """Check if the object has been deleted thus leaving the object shallow.
251
252 :return: True if the object has been deleted yet, False otherwise.
253 :rtype: bool
254
255 """
256 return bool(self.obj2 == NULL)
239 257
240 property fd: 258 property fd:
241 """Set up a file to have response data written into. 259 """Set up a file to have response data written into.
@@ -254,7 +272,7 @@ cdef class Url(Eo):
254 272
255 """ 273 """
256 def __set__(self, int fd): 274 def __set__(self, int fd):
257 ecore_con_url_fd_set(self.obj, fd) 275 ecore_con_url_fd_set(self.obj2, fd)
258 276
259 def get(self): 277 def get(self):
260 """Send a GET request. 278 """Send a GET request.
@@ -266,7 +284,7 @@ cdef class Url(Eo):
266 :return: ``True`` on success, ``False`` on error. 284 :return: ``True`` on success, ``False`` on error.
267 285
268 """ 286 """
269 return bool(ecore_con_url_get(self.obj)) 287 return bool(ecore_con_url_get(self.obj2))
270 288
271 def head(self): 289 def head(self):
272 """Send a HEAD request. 290 """Send a HEAD request.
@@ -278,7 +296,7 @@ cdef class Url(Eo):
278 :return: ``True`` on success, ``False`` on error. 296 :return: ``True`` on success, ``False`` on error.
279 297
280 """ 298 """
281 return bool(ecore_con_url_head(self.obj)) 299 return bool(ecore_con_url_head(self.obj2))
282 300
283 def post(self, bytes data, content_type): 301 def post(self, bytes data, content_type):
284 """Send a post request. 302 """Send a post request.
@@ -298,7 +316,7 @@ cdef class Url(Eo):
298 """ 316 """
299 if isinstance(content_type, unicode): 317 if isinstance(content_type, unicode):
300 content_type = PyUnicode_AsUTF8String(content_type) 318 content_type = PyUnicode_AsUTF8String(content_type)
301 return bool(ecore_con_url_post(self.obj, 319 return bool(ecore_con_url_post(self.obj2,
302 <const void*><const char *>data if data is not None else NULL, 320 <const void*><const char *>data if data is not None else NULL,
303 len(data), 321 len(data),
304 <const char *>content_type if content_type is not None else NULL)) 322 <const char *>content_type if content_type is not None else NULL))
@@ -317,7 +335,7 @@ cdef class Url(Eo):
317 :type timestamp: double 335 :type timestamp: double
318 336
319 """ 337 """
320 ecore_con_url_time(self.obj, time_condition, timestamp) 338 ecore_con_url_time(self.obj2, time_condition, timestamp)
321 339
322 def ftp_upload(self, filename, user, passwd, upload_dir): 340 def ftp_upload(self, filename, user, passwd, upload_dir):
323 """Upload a file to an ftp site. 341 """Upload a file to an ftp site.
@@ -335,7 +353,7 @@ cdef class Url(Eo):
335 if isinstance(user, unicode): user = PyUnicode_AsUTF8String(user) 353 if isinstance(user, unicode): user = PyUnicode_AsUTF8String(user)
336 if isinstance(passwd, unicode): passwd = PyUnicode_AsUTF8String(passwd) 354 if isinstance(passwd, unicode): passwd = PyUnicode_AsUTF8String(passwd)
337 if isinstance(upload_dir, unicode): upload_dir = PyUnicode_AsUTF8String(upload_dir) 355 if isinstance(upload_dir, unicode): upload_dir = PyUnicode_AsUTF8String(upload_dir)
338 return bool(ecore_con_url_ftp_upload(self.obj, 356 return bool(ecore_con_url_ftp_upload(self.obj2,
339 <const char *>filename if filename is not None else NULL, 357 <const char *>filename if filename is not None else NULL,
340 <const char *>user if user is not None else NULL, 358 <const char *>user if user is not None else NULL,
341 <const char *>passwd if passwd is not None else NULL, 359 <const char *>passwd if passwd is not None else NULL,
@@ -348,7 +366,7 @@ cdef class Url(Eo):
348 366
349 """ 367 """
350 def __set__(self, bint use_epsv): 368 def __set__(self, bint use_epsv):
351 ecore_con_url_ftp_use_epsv_set(self.obj, use_epsv) 369 ecore_con_url_ftp_use_epsv_set(self.obj2, use_epsv)
352 370
353 def cookies_init(self): 371 def cookies_init(self):
354 """Enable the cookie engine for subsequent HTTP requests. 372 """Enable the cookie engine for subsequent HTTP requests.
@@ -358,7 +376,7 @@ cdef class Url(Eo):
358 in new HTTP requests. 376 in new HTTP requests.
359 377
360 """ 378 """
361 ecore_con_url_cookies_init(self.obj) 379 ecore_con_url_cookies_init(self.obj2)
362 380
363 def cookies_clear(self): 381 def cookies_clear(self):
364 """Clear currently loaded cookies. 382 """Clear currently loaded cookies.
@@ -380,7 +398,7 @@ cdef class Url(Eo):
380 this handler. 398 this handler.
381 399
382 """ 400 """
383 ecore_con_url_cookies_clear(self.obj) 401 ecore_con_url_cookies_clear(self.obj2)
384 402
385 def cookies_session_clear(self): 403 def cookies_session_clear(self):
386 """Clear currently loaded session cookies. 404 """Clear currently loaded session cookies.
@@ -407,7 +425,7 @@ cdef class Url(Eo):
407 :attr:`cookies_ignore_old_session`. 425 :attr:`cookies_ignore_old_session`.
408 426
409 """ 427 """
410 ecore_con_url_cookies_session_clear(self.obj) 428 ecore_con_url_cookies_session_clear(self.obj2)
411 429
412 def cookies_file_add(self, file_name): 430 def cookies_file_add(self, file_name):
413 """Add a file to the list of files from which to load cookies. 431 """Add a file to the list of files from which to load cookies.
@@ -435,7 +453,7 @@ cdef class Url(Eo):
435 """ 453 """
436 if isinstance(file_name, unicode): 454 if isinstance(file_name, unicode):
437 file_name = PyUnicode_AsUTF8String(file_name) 455 file_name = PyUnicode_AsUTF8String(file_name)
438 ecore_con_url_cookies_file_add(self.obj, 456 ecore_con_url_cookies_file_add(self.obj2,
439 <const char *>file_name if file_name is not None else NULL) 457 <const char *>file_name if file_name is not None else NULL)
440 458
441 property cookies_jar_file: 459 property cookies_jar_file:
@@ -460,11 +478,11 @@ cdef class Url(Eo):
460 def __set__(self, cookiejar_file): 478 def __set__(self, cookiejar_file):
461 if isinstance(cookiejar_file, unicode): 479 if isinstance(cookiejar_file, unicode):
462 cookiejar_file = PyUnicode_AsUTF8String(cookiejar_file) 480 cookiejar_file = PyUnicode_AsUTF8String(cookiejar_file)
463 ecore_con_url_cookies_jar_file_set(self.obj, 481 ecore_con_url_cookies_jar_file_set(self.obj2,
464 <const char *>cookiejar_file if cookiejar_file is not None else NULL) 482 <const char *>cookiejar_file if cookiejar_file is not None else NULL)
465 if isinstance(cookiejar_file, unicode): 483 if isinstance(cookiejar_file, unicode):
466 cookiejar_file = PyUnicode_AsUTF8String(cookiejar_file) 484 cookiejar_file = PyUnicode_AsUTF8String(cookiejar_file)
467 ecore_con_url_cookies_jar_file_set(self.obj, 485 ecore_con_url_cookies_jar_file_set(self.obj2,
468 <const char *>cookiejar_file if cookiejar_file is not None else NULL) 486 <const char *>cookiejar_file if cookiejar_file is not None else NULL)
469 487
470 def cookies_jar_write(self): 488 def cookies_jar_write(self):
@@ -480,7 +498,7 @@ cdef class Url(Eo):
480 .. seealso:: :attr:`cookies_jar_file` 498 .. seealso:: :attr:`cookies_jar_file`
481 499
482 """ 500 """
483 ecore_con_url_cookies_jar_write(self.obj) 501 ecore_con_url_cookies_jar_write(self.obj2)
484 502
485 property cookies_ignore_old_session: 503 property cookies_ignore_old_session:
486 """Control whether session cookies from previous sessions shall be loaded. 504 """Control whether session cookies from previous sessions shall be loaded.
@@ -500,7 +518,7 @@ cdef class Url(Eo):
500 518
501 """ 519 """
502 def __set__(self, bint ignore): 520 def __set__(self, bint ignore):
503 ecore_con_url_cookies_ignore_old_session_set(self.obj, ignore) 521 ecore_con_url_cookies_ignore_old_session_set(self.obj2, ignore)
504 522
505 property ssl_verify_peer: 523 property ssl_verify_peer:
506 """Toggle libcurl's verify peer's certificate option. 524 """Toggle libcurl's verify peer's certificate option.
@@ -513,7 +531,7 @@ cdef class Url(Eo):
513 531
514 """ 532 """
515 def __set__(self, bint verify): 533 def __set__(self, bint verify):
516 ecore_con_url_ssl_verify_peer_set(self.obj, verify) 534 ecore_con_url_ssl_verify_peer_set(self.obj2, verify)
517 535
518 property ssl_ca: 536 property ssl_ca:
519 """Set a custom CA to trust for SSL/TLS connections. 537 """Set a custom CA to trust for SSL/TLS connections.
@@ -532,7 +550,7 @@ cdef class Url(Eo):
532 def __set__(self, ca_path): 550 def __set__(self, ca_path):
533 if isinstance(ca_path, unicode): 551 if isinstance(ca_path, unicode):
534 ca_path = PyUnicode_AsUTF8String(ca_path) 552 ca_path = PyUnicode_AsUTF8String(ca_path)
535 ecore_con_url_ssl_ca_set(self.obj, 553 ecore_con_url_ssl_ca_set(self.obj2,
536 <const char *>ca_path if ca_path is not None else NULL) 554 <const char *>ca_path if ca_path is not None else NULL)
537 555
538 property proxy: 556 property proxy:
@@ -552,7 +570,7 @@ cdef class Url(Eo):
552 """ 570 """
553 def __set__(self, proxy): 571 def __set__(self, proxy):
554 if isinstance(proxy, unicode): proxy = PyUnicode_AsUTF8String(proxy) 572 if isinstance(proxy, unicode): proxy = PyUnicode_AsUTF8String(proxy)
555 ecore_con_url_proxy_set(self.obj, 573 ecore_con_url_proxy_set(self.obj2,
556 <const char *>proxy if proxy is not None else NULL) 574 <const char *>proxy if proxy is not None else NULL)
557 575
558 property proxy_username: 576 property proxy_username:
@@ -566,7 +584,7 @@ cdef class Url(Eo):
566 """ 584 """
567 def __set__(self, user): 585 def __set__(self, user):
568 if isinstance(user, unicode): user = PyUnicode_AsUTF8String(user) 586 if isinstance(user, unicode): user = PyUnicode_AsUTF8String(user)
569 ecore_con_url_proxy_username_set(self.obj, 587 ecore_con_url_proxy_username_set(self.obj2,
570 <const char *>user if user is not None else NULL) 588 <const char *>user if user is not None else NULL)
571 589
572 property proxy_password: 590 property proxy_password:
@@ -580,7 +598,7 @@ cdef class Url(Eo):
580 """ 598 """
581 def __set__(self, passwd): 599 def __set__(self, passwd):
582 if isinstance(passwd, unicode): passwd = PyUnicode_AsUTF8String(passwd) 600 if isinstance(passwd, unicode): passwd = PyUnicode_AsUTF8String(passwd)
583 ecore_con_url_proxy_username_set(self.obj, 601 ecore_con_url_proxy_username_set(self.obj2,
584 <const char *>passwd if passwd is not None else NULL) 602 <const char *>passwd if passwd is not None else NULL)
585 603
586 property timeout: 604 property timeout:
@@ -595,7 +613,7 @@ cdef class Url(Eo):
595 613
596 """ 614 """
597 def __set__(self, double timeout): 615 def __set__(self, double timeout):
598 ecore_con_url_timeout_set(self.obj, timeout) 616 ecore_con_url_timeout_set(self.obj2, timeout)
599 617
600 property http_version: 618 property http_version:
601 """The HTTP version used for the request. 619 """The HTTP version used for the request.
@@ -607,7 +625,7 @@ cdef class Url(Eo):
607 625
608 """ 626 """
609 def __set__(self, Ecore_Con_Url_Http_Version version): 627 def __set__(self, Ecore_Con_Url_Http_Version version):
610 ecore_con_url_http_version_set(self.obj, version) 628 ecore_con_url_http_version_set(self.obj2, version)
611 629
612 property status_code: 630 property status_code:
613 """The returned HTTP STATUS code. 631 """The returned HTTP STATUS code.
@@ -619,7 +637,7 @@ cdef class Url(Eo):
619 637
620 """ 638 """
621 def __get__(self): 639 def __get__(self):
622 return ecore_con_url_status_code_get(self.obj) 640 return ecore_con_url_status_code_get(self.obj2)
623 641
624 property url: 642 property url:
625 """Controls the URL to send the request to. 643 """Controls the URL to send the request to.
@@ -628,11 +646,11 @@ cdef class Url(Eo):
628 646
629 """ 647 """
630 def __get__(self): 648 def __get__(self):
631 return _ctouni(ecore_con_url_url_get(self.obj)) 649 return _ctouni(ecore_con_url_url_get(self.obj2))
632 650
633 def __set__(self, url): 651 def __set__(self, url):
634 if isinstance(url, unicode): url = PyUnicode_AsUTF8String(url) 652 if isinstance(url, unicode): url = PyUnicode_AsUTF8String(url)
635 ecore_con_url_url_set(self.obj, <const char *>url if url is not None else NULL) 653 ecore_con_url_url_set(self.obj2, <const char *>url if url is not None else NULL)
636 654
637 property verbose: 655 property verbose:
638 """Toggle libcurl's verbose output. 656 """Toggle libcurl's verbose output.
@@ -645,7 +663,7 @@ cdef class Url(Eo):
645 663
646 """ 664 """
647 def __set__(self, bint verbose): 665 def __set__(self, bint verbose):
648 ecore_con_url_verbose_set(self.obj, verbose) 666 ecore_con_url_verbose_set(self.obj2, verbose)
649 667
650 def additional_header_add(self, key, value): 668 def additional_header_add(self, key, value):
651 """Add an additional header to the request connection object. 669 """Add an additional header to the request connection object.
@@ -662,7 +680,7 @@ cdef class Url(Eo):
662 """ 680 """
663 if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key) 681 if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
664 if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value) 682 if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
665 ecore_con_url_additional_header_add(self.obj, 683 ecore_con_url_additional_header_add(self.obj2,
666 <const char *>key if key is not None else NULL, 684 <const char *>key if key is not None else NULL,
667 <const char *>value if value is not None else NULL) 685 <const char *>value if value is not None else NULL)
668 686
@@ -673,7 +691,7 @@ cdef class Url(Eo):
673 (previously added with :func:additional_header_add`). 691 (previously added with :func:additional_header_add`).
674 692
675 """ 693 """
676 ecore_con_url_additional_headers_clear(self.obj) 694 ecore_con_url_additional_headers_clear(self.obj2)
677 695
678 property response_headers: 696 property response_headers:
679 """The headers from last request sent. 697 """The headers from last request sent.
@@ -687,7 +705,7 @@ cdef class Url(Eo):
687 """ 705 """
688 def __get__(self): 706 def __get__(self):
689 return eina_list_strings_to_python_list( 707 return eina_list_strings_to_python_list(
690 ecore_con_url_response_headers_get(self.obj)) 708 ecore_con_url_response_headers_get(self.obj2))
691 709
692 property received_bytes: 710 property received_bytes:
693 """The number of bytes received. 711 """The number of bytes received.
@@ -699,7 +717,7 @@ cdef class Url(Eo):
699 717
700 """ 718 """
701 def __get__(self): 719 def __get__(self):
702 return ecore_con_url_received_bytes_get(self.obj) 720 return ecore_con_url_received_bytes_get(self.obj2)
703 721
704 def httpauth_set(self, username, password, bint safe): 722 def httpauth_set(self, username, password, bint safe):
705 """Set to use http auth, with given username and password 723 """Set to use http auth, with given username and password
@@ -719,7 +737,7 @@ cdef class Url(Eo):
719 username = PyUnicode_AsUTF8String(username) 737 username = PyUnicode_AsUTF8String(username)
720 if isinstance(password, unicode): 738 if isinstance(password, unicode):
721 password = PyUnicode_AsUTF8String(password) 739 password = PyUnicode_AsUTF8String(password)
722 return bool(ecore_con_url_httpauth_set(self.obj, 740 return bool(ecore_con_url_httpauth_set(self.obj2,
723 <const char *>username if username is not None else NULL, 741 <const char *>username if username is not None else NULL,
724 <const char *>password if password is not None else NULL, 742 <const char *>password if password is not None else NULL,
725 safe)) 743 safe))
diff --git a/include/efl.ecore_con.pxd b/include/efl.ecore_con.pxd
index 3617c6d..c2e9bab 100644
--- a/include/efl.ecore_con.pxd
+++ b/include/efl.ecore_con.pxd
@@ -71,6 +71,8 @@ cdef extern from "Ecore_Con.h":
71 void ecore_con_url_pipeline_set(Eina_Bool enable) 71 void ecore_con_url_pipeline_set(Eina_Bool enable)
72 Eina_Bool ecore_con_url_pipeline_get() 72 Eina_Bool ecore_con_url_pipeline_get()
73 Eina_Bool ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data) 73 Eina_Bool ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data)
74 void ecore_con_url_data_set(Ecore_Con_Url *url_con, void *data)
75 void *ecore_con_url_data_get(Ecore_Con_Url *url_con)
74 76
75 Ecore_Con_Url *ecore_con_url_new(const char *url) 77 Ecore_Con_Url *ecore_con_url_new(const char *url)
76 void ecore_con_url_free(Ecore_Con_Url *url_obj) 78 void ecore_con_url_free(Ecore_Con_Url *url_obj)
@@ -113,7 +115,8 @@ cdef extern from "Ecore_Con.h":
113 115
114 116
115cdef class Url(Eo): 117cdef class Url(Eo):
116 pass 118 # we cannot use Eo.obj here because Url is no more eo objects in C
119 cdef Ecore_Con_Url *obj2
117 120
118cdef class Lookup(object): 121cdef class Lookup(object):
119 cdef object done_cb 122 cdef object done_cb