Diff for /chimera/BookmarksService.mm between versions 1.19 and 1.20

version 1.19, 2002/04/14 08:43:03 version 1.20, 2002/04/14 21:41:21
Line 60 Line 60
 {  {
     [super init];      [super init];
     mBookmarks = nsnull;      mBookmarks = nsnull;
       mCachedParent = nsnull;
       mCachedHref = nil;
     return self;      return self;
 }  }
   
Line 114 Line 116
     mBookmarks->GetRootContent(getter_AddRefs(content));      mBookmarks->GetRootContent(getter_AddRefs(content));
   
   nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));    nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
  nsCOMPtr<nsIDOMElement> elt;  
  domDoc->CreateElementNS(NS_LITERAL_STRING("http://chimera.mozdev.org/bookmarks"), 
                          NS_LITERAL_STRING("bookmark"), 
                          getter_AddRefs(elt)); 
 
   // Fetch the title of the current page and the URL.    // Fetch the title of the current page and the URL.
   nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);    nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);
   nsCOMPtr<nsIDOMWindow> window;    nsCOMPtr<nsIDOMWindow> window;
Line 136 Line 134
     href.AssignWithConversion(spec.get());      href.AssignWithConversion(spec.get());
   }    }
   
     mCachedHref = [NSString stringWithCharacters: href.get() length: nsCRT::strlen(href.get())];
     [mCachedHref retain];
     
     mCachedParent = content;
     
   nsAutoString title;    nsAutoString title;
   nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));    nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));
   if (htmlDocument)    if (htmlDocument)
     htmlDocument->GetTitle(title);      htmlDocument->GetTitle(title);
   if (title.IsEmpty())    if (title.IsEmpty())
     title = href;      title = href;
     
     NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
     [textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]];
   
     [mBrowserWindowController cacheBookmarkDS: self];
     
     [NSApp beginSheet:    [mBrowserWindowController getAddBookmarkSheetWindow]
        modalForWindow:    [mBrowserWindowController window]
         modalDelegate:    nil //self
        didEndSelector:    nil //@selector(sheetDidEnd:)
           contextInfo:    nil];
   }
   
   -(void)endAddBookmark: (int)aCode
   {
     if (aCode == 0)
       return;
     
     const char* titleC = [[[mBrowserWindowController getAddBookmarkTitle] stringValue] cString];
     nsAutoString title; title.AssignWithConversion(titleC);
   
     nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
     nsCOMPtr<nsIDOMElement> elt;
     domDoc->CreateElementNS(NS_LITERAL_STRING("http://chimera.mozdev.org/bookmarks"),
                             NS_LITERAL_STRING("bookmark"),
                             getter_AddRefs(elt));
   
   elt->SetAttribute(NS_LITERAL_STRING("name"), title);    elt->SetAttribute(NS_LITERAL_STRING("name"), title);
     nsAutoString href; href.AssignWithConversion([mCachedHref cString]);
     [mCachedHref release];
     
   elt->SetAttribute(NS_LITERAL_STRING("href"), href);    elt->SetAttribute(NS_LITERAL_STRING("href"), href);
   
  nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(content));  nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(mCachedParent));
   nsCOMPtr<nsIDOMNode> dummy;    nsCOMPtr<nsIDOMNode> dummy;
   parent->AppendChild(elt, getter_AddRefs(dummy));    parent->AppendChild(elt, getter_AddRefs(dummy));
   
   nsCOMPtr<nsIContent> childContent(do_QueryInterface(elt));    nsCOMPtr<nsIContent> childContent(do_QueryInterface(elt));
  mBookmarks->BookmarkAdded(content, childContent);  mBookmarks->BookmarkAdded(mCachedParent, childContent);
 }  }
   
 -(IBAction)deleteBookmark: (id)aSender  -(IBAction)deleteBookmark: (id)aSender

Removed from v.1.19  
changed lines
  Added in v.1.20


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>