Closed
Bug 186731
Opened 22 years ago
Closed 13 years ago
various cleanup in nsPop3Service.cpp ("pop service NewURI should rely on + concatenation" no longer valid)
Categories
(MailNews Core :: Networking: POP, enhancement)
MailNews Core
Networking: POP
Tracking
(Not tracked)
RESOLVED
FIXED
Thunderbird 13.0
People
(Reporter: timeless, Assigned: aceman)
References
()
Details
Attachments
(1 file, 4 obsolete files)
22.28 KB,
patch
|
aceman
:
review+
|
Details | Diff | Splinter Review |
the concatenation operator is supposed to be better than sequential appends.
Attachment #110932 -
Attachment is obsolete: true
Updated•20 years ago
|
Product: MailNews → Core
Updated•16 years ago
|
Product: Core → MailNews Core
Updated•16 years ago
|
QA Contact: esther → networking.pop
Comment 4•13 years ago
|
||
(In reply to :aceman from comment #3)
> This was never reviewed. Is it still relevant?
It's extremely bit-rotted, and I think moving to frozen linkages might make this not doable.
Comment 5•13 years ago
|
||
Yeah I can't remember from the frozen linkages aspect, maybe Neil can.
Comment 6•13 years ago
|
||
Indeed, nsStringAPI doesn't support operator+().
Comment 8•13 years ago
|
||
Comment on attachment 111146 [details] [diff] [review]
+ fix tabs, correct PR_...free, early returns,
>- if (!((const char *)popHost))
>+ if (popHost.IsEmpty())
Already landed.
> ? PR_smprintf("pop3://%s@%s:%d", (const char *)escapedUsername, (const char *)popHost, popPort)
> : PR_smprintf("pop3://%s@%s:%d/?check", (const char *)escapedUsername, (const char *)popHost, popPort);
> rv = BuildPop3Url(urlSpec, aInbox, aPopServer, aUrlListener, getter_AddRefs(url), aMsgWindow);
>- PR_Free(urlSpec);
>+ PR_smprintf_free(urlSpec);
Useful.
>- rv = pop3Url->QueryInterface(NS_GET_IID(nsIURI), (void **) aUrl);
>+ rv = CallQueryInterface(pop3Url, aUrl);
Good.
>- aScheme = "pop3";
>+ aScheme = NS_LITERAL_CSTRING("pop3");
But .AssignLiteral would be better still.
>- rv = protocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
>+ rv = CallQueryInterface(protocol, _retval);
Good.
Attachment #111146 -
Attachment description: + fix tabs, correct PR_...free, early returns, → + fix tabs, correct PR_...free, early returns,
Thanks.
So I assume the talk in comment 6 was about this part:
- nsCAutoString popSpec("pop://");
- popSpec += escapedUsername;
- popSpec += "@";
- popSpec += hostname;
- popSpec += ":";
+ nsCAutoString popSpec;
+ popSpec = NS_LITERAL_CSTRING("pop://")
+ + nsDependentCString(escapedUsername)
+ + NS_LITERAL_CSTRING("@")
+ + nsDependentCString(hostname)
+ + NS_LITERAL_CSTRING(":");
popSpec.AppendInt(port);
- popSpec += "?";
+ popSpec += NS_LITERAL_CSTRING("?");
I'll drop that but refresh the other changes.
Assignee: timeless → acelists
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Hardware: x86 → All
Summary: pop service NewURI should rely on + concatenation → various cleanup in nsPop3Service.cpp ("pop service NewURI should rely on + concatenation" no longer valid)
![]() |
Assignee | |
Comment 10•13 years ago
|
||
Attachment #111146 -
Attachment is obsolete: true
Attachment #591240 -
Flags: review?(neil)
Comment 11•13 years ago
|
||
Comment on attachment 591240 [details] [diff] [review]
patch
I don't see any technical errors in these changes although I can't vouch for the correctness of the style changes so punting the review over to bienvenu.
>+ nsPop3Protocol *protocol = new nsPop3Protocol(aURI);
>+ NS_ENSURE_TRUE(protocol, NS_ERROR_OUT_OF_MEMORY);
>+
>+ NS_ADDREF(protocol);
>+ rv = protocol->Initialize(aURI);
>+ if (NS_FAILED(rv))
> {
>+ NS_RELEASE(protocol);
>+ return rv;
> }
>+ protocol->SetUsername(realUserName.get());
>+
>+ rv = CallQueryInterface(protocol, _retval);
>+ NS_RELEASE(protocol);
>
> return rv;
> }
We can actually improve further on this using nsRefPtr<nsPop3Protocol> protocol which allows us to remove the NS_ADDREF and NS_RELEASE lines.
Attachment #591240 -
Flags: review?(neil) → review?(dbienvenu)
![]() |
Assignee | |
Comment 12•13 years ago
|
||
Sorry, I can't do that, do not understand those ns pointers yet.
But if you can write it I can include it in the patch. Or you'd need to do in another bug.
Comment 13•13 years ago
|
||
You basically need to do exactly what Neil said ;-) :
Replace nsPop3Protocol *protocol with nsRefPtr<nsPop3Protocol> protocol, and then drop all the NS_ADDREF and NS_RELEASE lines that work on protocol.
![]() |
Assignee | |
Comment 14•13 years ago
|
||
Comment on attachment 591240 [details] [diff] [review]
patch
Oh, "break and then tweak until it compiles somehow"-method again :)
Will do.
Attachment #591240 -
Flags: review?(dbienvenu)
![]() |
Assignee | |
Comment 15•13 years ago
|
||
Attachment #591240 -
Attachment is obsolete: true
Attachment #592191 -
Flags: review?(dbienvenu)
Comment 16•13 years ago
|
||
looks good, thx, a few nits:
+
+ rv = CallQueryInterface(protocol, _retval);
return rv;
this can be just return CallQueryInterface...
I think using kNotFound instead of -1 makes Neil unhappy w.r.t. frozen linkages - please correct me if I'm wrong, Neil.
please fix the space after nsCOMPtr...
+ nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(aUrlToRun);
+ if (url)
+ AlertServerBusy(url);
+ rv = NS_ERROR_FAILURE;
Comment 17•13 years ago
|
||
kNotFound should be fine, we #define it to -1 in nsMsgUtils.h for you.
Comment 18•13 years ago
|
||
Comment on attachment 592191 [details] [diff] [review]
patch v2
r=me, modulo the kNotFound comment
Attachment #592191 -
Flags: review?(dbienvenu) → review+
![]() |
Assignee | |
Comment 19•13 years ago
|
||
Fixes nits and keeps r=dbienvenu.
Attachment #592191 -
Attachment is obsolete: true
Attachment #594766 -
Flags: review+
Keywords: checkin-needed
Comment 20•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 13.0
You need to log in
before you can comment on or make changes to this bug.
Description
•