(Following up on my comment, too long to post as one.)
$\frac{(\alpha) ^2+(\beta) ^2}{\alpha+\beta} = (\alpha+\beta) -\frac{2\alpha \beta}{(\alpha+\beta) }$
Also using that $\,\alpha\beta=-r /\gamma\,$ and $\,\alpha+\beta=-p-\gamma\,$:
$$
A = \sum \frac{\alpha ^2+\beta ^2}{\alpha+\beta} = \sum \left((\alpha+\beta) -\frac{2\alpha \beta}{\alpha+\beta} \right) = 2 \underbrace{\,\sum \alpha\,}_{=\,-p} + 2r \underbrace{\,\sum \frac{1}{\alpha(p+\alpha)}\,}_{= \,B}
$$
Since $\,\dfrac{1}{\alpha(p+\alpha)}=\dfrac{1}{p}\left(\dfrac{1}{\alpha}-\dfrac{1}{p+\alpha}\right)\,$:
$$
B = \frac{1}{p}\left(\underbrace{\,\sum \frac{1}{\alpha}\,}_{=C} - \underbrace{\,\sum \frac{1}{p+\alpha}\,}_{= D}\right)
$$
$\dfrac{1}{\alpha}\,$ are the roots of the reciprocal polynomial $\,x^3 f\left(\frac{1}{x}\right) = 1+px+qx^2+rx^3\,$, so:
$$
C = \sum \frac{1}{\alpha} = -\frac{q}{r}
$$
$p+\alpha$ are the roots of $\,f(x-p) = x^3 - 2 p x^2 + (p^2 + q) x - p q + r\,$, so:
$$
D = \sum \frac{1}{p+\alpha}=-\frac{p^2 + q}{- p q + r}
$$
What's left is to piece it all back together, and also cover the special cases like $\,r=0\,$.