home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mkabook.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.2 KB  |  86 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. // 
  19. // mkabook.cpp -- Handles "addbook:" " URLs for core Navigator, without
  20. //               requiring libmsg. mkabook is intended for adding 
  21. //               to the address-book.
  22. //
  23. //
  24.  
  25. #include "mkutils.h" 
  26.  
  27. #include "xp.h"
  28. #include "xp_str.h"
  29.  
  30. #include "mkgeturl.h"
  31. #include "mkabook.h"
  32. #include "addrbook.h"
  33.  
  34. //
  35. // Callbacks from NET_GetURL 
  36. //
  37.  
  38. extern "C" int32 net_AddressBookLoad (ActiveEntry *ce)
  39. {
  40.     char * url = ce->URL_s->address;
  41.     char * path = NET_ParseURL(url, GET_PATH_PART);
  42.     char * search = NET_ParseURL(url, GET_SEARCH_PART);
  43.     if (!XP_STRNCASECMP(path,"add",3)) {
  44.         if (!XP_STRNCASECMP (search, "?vcard=", 7)) {
  45.             ABook* addressbook = FE_GetAddressBook(NULL);
  46.             if (addressbook)
  47.                 AB_ImportFromVcardURL(addressbook, ce->window_id, NET_UnEscape(search+7));
  48.         }
  49.     }
  50.  
  51.     return -1;
  52. }
  53.  
  54.  
  55. extern "C" int32 net_ProcessAddressBook (ActiveEntry *ce)
  56. {
  57.     XP_ASSERT(0);
  58.     return -1;
  59. }
  60.  
  61.  
  62. extern "C" int32 net_InterruptAddressBook (ActiveEntry * ce)
  63. {
  64.     XP_ASSERT(0);
  65.     return -1;
  66. }
  67.  
  68. extern "C" void
  69. net_CleanupAddressBook(void)
  70. {
  71. }
  72.  
  73. MODULE_PRIVATE void
  74. NET_InitAddressBookProtocol(void)
  75. {
  76.     static NET_ProtoImpl abook_proto_impl;
  77.  
  78.     abook_proto_impl.init = net_AddressBookLoad;
  79.     abook_proto_impl.process = net_ProcessAddressBook;
  80.     abook_proto_impl.interrupt = net_InterruptAddressBook;
  81.     abook_proto_impl.cleanup = net_CleanupAddressBook;
  82.  
  83.     NET_RegisterProtocolImplementation(&abook_proto_impl, ADDRESS_BOOK_TYPE_URL);
  84. }
  85.  
  86.